Security Lab
Windows Privilege Escalation: Techniques, Detection, Hardening
This lab works through how an attacker turns a low-privileged foothold on a Windows host into SYSTEM, and treats each technique from both sides: how it is abused, which logs and event IDs reveal it, and the configuration that removes it. The focus is the defender's view, since the point of learning the attack is to detect and shut it.
Scope: local privilege escalation, after initial access, on a standalone Windows lab VM. Based on hands-on TryHackMe room work. No flags, room answers, or room content are reproduced here; the techniques are well documented and are described generally, mapped to Windows Server 2022 and Windows 11. The console output on this page is illustrative, not from the room. Proof of completion is on my TryHackMe profile.
Context
Why It Matters
Privilege escalation is the step between an initial foothold and full control of a host. An attacker rarely lands as an administrator; they land as a user or a service account and look for a misconfiguration that lifts them to SYSTEM, from where they can dump credentials, disable defences, and move laterally. Every technique here is a misconfiguration a defender can find first. The same enumeration that an attacker runs is the audit that hardens a fleet, and the same actions that escalate are the ones a SIEM can alert on.
Overview
The Escalation Path
The loop is the same for every vector: enumerate the host, find a weakness, abuse it to gain privileges, and confirm the result. Each step leaves traces, so the path up is also a trail a defender can follow back.
SeImpersonatePrivilege on a service account is the entry point for a
potato attack to SYSTEM, and the first thing enumeration looks for.
Approach
Method
The work followed the same loop for every vector: enumerate the host, identify a misconfiguration, abuse it to gain higher privileges, then confirm the result and note how the activity would look to a defender.
Enumeration
- Automated sweeps with winPEAS, PrivescCheck, and Seatbelt.
- Manual checks of services, scheduled tasks, privileges, and credential stores.
whoami /privto read the token's privileges.
Validation
- Escalation confirmed by spawning a process as SYSTEM or an admin.
- Each step mapped to the event IDs and Sysmon signals it generates.
- Hardening tested by re-running the check and confirming the vector was gone.
Vector
Credential Harvesting
The quickest escalation is often a password left on disk. These are read, not exploited, so they leave light traces unless file and PowerShell auditing is on. The usual stores are unattended install files, the credential manager, command history, and application config.
- Abuse: unattended install files (
Unattend.xml,sysprep.inf) with base64 passwords, stored credentials viacmdkey /listthenrunas /savecred, PowerShell history files,web.configconnection strings, and saved PuTTY sessions in the registry. - Detect: object-access auditing (Event ID 4663) on sensitive files such as
Unattend.xmlandweb.config; PowerShell script-block logging (4104) when history files are read; 4688 with command line forcmdkeyandrunas /savecred. - Harden: never leave plaintext secrets in deployment files or scripts; deploy LAPS so local admin passwords are unique and rotated; enable PowerShell transcription and script-block logging; clear sensitive history.
Vector
Service Misconfigurations
Services run as SYSTEM, so a service an unprivileged user can influence is a direct path up. Two classics: unquoted service paths, and weak permissions on the service binary or its registry key.
winPEAS flagging an unquoted service path running as SYSTEM with a writable parent
folder: a planted C:\Program.exe would run at service start.
- Abuse: an unquoted path with spaces lets a planted binary earlier in the path run instead; writable service binaries or
HKLM\...\Serviceskeys let theImagePathor binary be swapped for a payload that runs as SYSTEM at service start. - Detect: new or changed service (Event ID 7045 service installed, 4697 via the Security log); registry modification on a service key (4657); a process starting from an unexpected path (4688); Sysmon 11 (file create) in a service binary directory.
- Harden: quote every service binary path; restrict ACLs on service binaries and their registry keys to admins; remove writable directories from
PATH; run services under least-privilege or managed service accounts.
Vector
Token and Privilege Abuse
Certain privileges are SYSTEM in all but name. Service accounts for IIS and MSSQL
commonly hold SeImpersonatePrivilege, which is the basis of the "potato"
family of attacks, and the backup and ownership privileges open their own paths.
- Abuse:
SeImpersonatePrivilegeis used with a potato technique (named-pipe or token impersonation) to run code as SYSTEM;SeBackupPrivilege/SeRestorePrivilegeread protected files to copy the SAM and SYSTEM hives for offline cracking;SeTakeOwnershipPrivilegeseizes a SYSTEM binary and swaps it. - Detect: Sysmon 17/18 (named-pipe create and connect) is the strongest signal for potato attacks; 4688 showing a child process under a service account; 4672 (special privileges assigned at logon) and 4673/4674 (privileged service called); 4688 for
reg.exe save hklm\samoresentutl/ VSS access to the hives. - Harden: keep service accounts off interactive rights; prefer group-managed service accounts; keep hosts patched, since current Windows mitigates the classic potato routes; enable LSA protection (RunAsPPL) and Credential Guard where supported; alert hard on
SeImpersonateabuse.
Vector
Other Quick Wins
- AlwaysInstallElevated: if both the HKLM and HKCU policy keys are set to
1, any user can install an MSI as SYSTEM. Detect with 4688 formsiexec /quiet /qnand MsiInstaller events; harden by setting both keys to0(or via GPO). - Scheduled tasks: a task that runs as a higher user from a script the attacker can write is a reliable escalation. Detect with 4698 (task created) and 4702 (task updated), plus Task Scheduler Operational log 106/140/141; harden by tightening ACLs on task scripts and binaries.
- Vulnerable software: an outdated local service or client with a public exploit. Detect by inventorying installed versions (
wmic product, endpoint tooling); harden by patching and removing unused software.
Detection
Detection Reference
The signals below assume command-line process auditing (4688 with command line), Sysmon with a sound config, and PowerShell logging are all enabled and forwarded to a SIEM. Two of the highest-value signals look like this:
Potato Attack
The named pipe a potato attack creates shows up in Sysmon Event ID 17, under a service account that has no business opening one. The strongest signal to alert on.
Hive Theft
Exporting the SAM hive for offline cracking is caught by command-line process auditing (Event ID 4688), which is why logging the command line matters.
| Technique | Key signals |
|---|---|
| Credential harvesting | 4663 on sensitive files; 4104 PowerShell script-block; 4688 for cmdkey / runas /savecred |
| Service misconfiguration | 7045 new service; 4697 service installed; 4657 service-key change; 4688 from unexpected path; Sysmon 11 |
| SeImpersonate / potato | Sysmon 17/18 named pipe; 4688 child under service account; 4672 special privileges |
| SAM / SYSTEM hive theft | 4688 for reg.exe save hklm\sam; 4663 on SAM/SYSTEM; VSS or esentutl access |
| AlwaysInstallElevated | 4688 for msiexec /quiet /qn; MsiInstaller events |
| Scheduled task abuse | 4698 task created; 4702 task updated; Task Scheduler Operational 106/140/141 |
| Privilege abuse (SeBackup / SeTakeOwnership) | 4672 / 4673 / 4674 privileged use |
In my lab these events are forwarded to Splunk, where a search for Sysmon Event ID 17
from a service account, or 4688 showing reg save against the SAM hive,
becomes a detection rule rather than a line in a log nobody reads.
Hardening
Hardening Summary
- Least privilege everywhere; avoid granting
SeImpersonateorSeAssignPrimaryTokenbroadly; use managed or virtual service accounts. - Quote all service binary paths; restrict ACLs on service binaries and their registry keys; keep writable directories out of
PATH. - Set
AlwaysInstallElevatedto0in both HKLM and HKCU via GPO. - Audit and tighten scheduled-task script and binary permissions.
- Credential hygiene: no secrets in deployment files or scripts; deploy LAPS; enable PowerShell transcription and script-block logging.
- Protect the LSA (RunAsPPL) and enable Credential Guard where supported.
- Patch third-party software and keep a version inventory.
- Enable command-line process auditing and Sysmon, and forward both to the SIEM so these signals are actually collected.
Tools
Tooling Used
Reflection
What This Lab Demonstrates
This lab shows I can work a Windows host from both sides: find the misconfigurations that hand an attacker SYSTEM, and recognise what each one looks like in the logs. That matters because the checks that find a privilege escalation path in a lab are the same ones that harden a domain-joined fleet, and the event IDs behind them feed the detections that catch it in production.
It maps directly to the Windows Server 2022 and Windows 11 estate I work on, and to the detection and response work I'm building toward with SC-200 and CySA+. The value is not the exploit; it is knowing, for every vector, where it shows up and how to remove it.
Skills