Windows Host Enumeration & Privilege Escalation
Windows privilege escalation involves identifying configuration weaknesses, vulnerable services, weak filesystem permissions, or abused token privileges on a local Windows host to transition from a standard user context to NT AUTHORITY\SYSTEM.
Initial Situational Awareness
Section titled “Initial Situational Awareness”Upon gaining initial low-privilege access to a Windows system, gather baseline host, user, network, and architecture data.
Command Prompt & PowerShell Triage
Section titled “Command Prompt & PowerShell Triage”:: Current user identity, security identifiers (SIDs), and token privilegeswhoami /all
:: Operating system version, patch level, and system architecturesysteminfo | findstr /B /C:"OS Name" /C:"OS Version" /C:"System Type"
:: Local users and group membershipsnet usernet localgroup Administrators
:: Active network connections and listening socketsnetstat -ano | findstr LISTENING
:: Environment variables and execution pathset PATHCritical User Privileges to Inspect
Section titled “Critical User Privileges to Inspect”When inspecting the output of whoami /priv, look for high-value access token rights:
| Privilege Name | Default State | Escalation Vector / Significance |
|---|---|---|
SeImpersonatePrivilege |
Disabled / Enabled | Allows token impersonation from elevated processes (Potato exploits). Common in IIS service accounts (iis apppool). |
SeBackupPrivilege |
Disabled | Grants read access to any file on the system, bypassing ACLs (allows reading NTDS.dit or SAM/SYSTEM hives). |
SeRestorePrivilege |
Disabled | Grants write access to any file on the system, allowing replacement of service binaries. |
SeDebugPrivilege |
Disabled | Allows attaching debuggers to arbitrary processes, including lsass.exe. |
Service Misconfigurations
Section titled “Service Misconfigurations”Windows services run in high-privilege accounts (often NT AUTHORITY\SYSTEM). When services are configured with permissive permissions or unquoted paths, local users can manipulate execution flows.
1. Unquoted Service Paths
Section titled “1. Unquoted Service Paths”An unquoted service path occurs when a service binary path containing spaces is stored without enclosing quotes in the Windows Registry.
For example, given:
C:\Program Files\Development Tools\ServiceApp\engine.exe
Windows attempts execution in this order:
C:\Program.exeC:\Program Files\Development.exeC:\Program Files\Development Tools\ServiceApp\engine.exe
If an unprivileged user has write access to C:\, dropping Program.exe will execute when the service starts.
Detecting Unquoted Service Paths via Command Prompt:
wmic service get name,displayname,pathname,startmode | findstr /i /v "c:\windows\\" | findstr /i /v """Querying Configuration via sc:
sc qc CustomService2. Weak Service Permissions & Modifiable Binaries
Section titled “2. Weak Service Permissions & Modifiable Binaries”If low-privilege users possess SERVICE_CHANGE_CONFIG or SERVICE_ALL_ACCESS rights over a service, they can modify the service binary path (binPath) directly:
# Inspecting service permissions using Sysinternals AccessChk (in authorized labs)accesschk.exe -uwcqv "Users" *
# Modifying binary path of a vulnerable servicesc config VulnerableService binpath= "C:\path\to\custom_binary.exe"sc stop VulnerableServicesc start VulnerableServiceRegistry Autoruns & AlwaysInstallElevated
Section titled “Registry Autoruns & AlwaysInstallElevated”AlwaysInstallElevated
Section titled “AlwaysInstallElevated”If the AlwaysInstallElevated registry policy is enabled, Windows allows any user to install Windows Installer package (.msi) files with full elevated administrative privileges:
reg query HKCU\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedreg query HKLM\SOFTWARE\Policies\Microsoft\Windows\Installer /v AlwaysInstallElevatedIf both return 0x1, any .msi package runs under NT AUTHORITY\SYSTEM.
Defensive Remediation: Set both values to 0 or remove the registry key in Group Policy:
Set-ItemProperty -Path "HKLM:\SOFTWARE\Policies\Microsoft\Windows\Installer" -Name "AlwaysInstallElevated" -Value 0Defensive Hardening & Detection
Section titled “Defensive Hardening & Detection”- Principle of Least Privilege for Service Accounts: Configure non-system services to run under managed service accounts (gMSA) or virtual accounts with restricted privileges rather than
LocalSystem. - Quote All Service Paths: Audit registry keys under
HKLM\SYSTEM\CurrentControlSet\Servicesand wrap all binary paths containing spaces in double quotes. - Restrict File & Folder ACLs: Ensure non-administrative users do not possess write or modify permissions over root drive directories (
C:\) or application directories underC:\Program Files\. - Enable PowerShell Script Block Logging: Enable Event ID
4104to record executed script blocks for centralized SIEM analysis.