Windows: Kernel Exploits
Kernel exploits
This site is handy for searching out detailed information about Microsoft security vulnerabilities. This database has 4,733 security vulnerabilities entered at the time of writing, showing the massive attack surface that a Windows environment presents.
MS08-067
MS08-067
- This was a remote code execution vulnerability in the "Server" service due to improper handling of RPC requests. This affected Windows Server 2000, 2003, and 2008 and Windows XP and Vista and allows an unauthenticated attacker to execute arbitrary code with SYSTEM privileges. Though typically encountered in client environments as a remote code execution vulnerability, we may land on a host where the SMB service is blocked via the firewall. We can use this to escalate privileges after forwarding port 445 back to our attack box. Though this is a "legacy" vulnerability, I still do see this pop up from time to time in large organizations, especially those in the medical industry who may be running specific applications that only work on older versions of Windows Server/Desktop. We should not discount older vulnerabilities even in 2021. We will run into every scenario under the sun while performing client assessments and must be ready to account for all possibilities. The box Legacy on the Hack The Box platform showcases this vulnerability from the remote code execution standpoint. There are standalone as well as a Metasploit version of this exploit.
MS17-010 (EternalBlue)
MS17-010
- Also known as EternalBlue is a remote code execution vulnerability that was part of the FuzzBunch toolkit released in the Shadow Brokers leak. This exploit leverages a vulnerability in the SMB protocol because the SMBv1 protocol mishandles packets specially crafted by an attacker, leading to arbitrary code execution on the target host as the SYSTEM account. As with MS08-067, this vulnerability can also be leveraged as a local privilege escalation vector if we land on a host where port 445 is firewalled off. There are various versions of this exploit for the Metasploit Framework as well as standalone exploit scripts. This attack was showcased in the Blue box on Hack The Box, again from the remote standpoint.
ALPC Task Scheduler 0-Day
ALPC Task Scheduler 0-Day
- The ALPC endpoint method used by the Windows Task Scheduler service could be used to write arbitrary DACLs to .job
files located in the C:\Windows\tasks
directory. An attacker could leverage this to create a hard link to a file that the attacker controls. The exploit for this flaw used the SchRpcSetSecurity API function to call a print job using the XPS printer and hijack the DLL as NT AUTHORITY\SYSTEM via the Spooler service. An in-depth writeup is available here. The Hack The Box box Hackback can be used to try out this privilege escalation exploit.
Summer of 2021 revealed a treasure trove of new Windows and Active Directory-related remote code execution and local privilege escalation flaws to the delight of penetration testers (and real-world attackers), and I'm sure groans from our hard-working colleagues on the defense side of things.
🐝 HiveNightmare, aka SeriosSam (CVE-2021-36934)
CVE-2021-36934 HiveNightmare, aka SeriousSam
is a Windows 10 flaw that results in ANY user having rights to read the Windows registry and access sensitive information regardless of privilege level. Researchers quickly developed a PoC exploit to allow reading of the SAM, SYSTEM, and SECURITY registry hives and create copies of them to process offline later and extract password hashes (including local admin) using a tool such as SecretsDump.py. More information about this flaw can be found here and this exploit binary can be used to create copies of the three files to our working directory.
🖨️ PrintNightmare
PrintNightmare
is the nickname given to two vulnerabilities (CVE-2021-34527 and CVE-2021-1675) found in the Print Spooler service that runs on all Windows operating systems.
🏊 Print Spooler
The Print Spooler exploitation leverages the Windows Print Spooler service in conjunction with the SeImpersonatePrivilege privilege. The goal is to impersonate a SYSTEM token to escalate privileges. Tools like PrintSpoofer automate this process effectively. Below are detailed steps for exploiting this vulnerability:
🩹 Enumerating Missing Patches
The first step is looking at installed updates and attempting to find updates that may have been missed, thus, opening up an attack path for us.
Examining Installed Updates: We can examine the installed updates in several ways. Below are three separate commands we can use.
Viewing Installed Updates with WMI
We can search for each KB (Microsoft Knowledge Base ID number) in the Microsoft Update Catalog to get a better idea of what fixes have been installed and how far behind the system may be on security updates. A search for KB5000808
shows us that this is an update from March of 2021, which means the system is likely far behind on security updates.
CVE-2020-0668: Windows Service Tracing
The vulnerability in a nugshell: Windows Service Tracing allows users to troubleshoot issues with running services and modules by generating debug information. Its parameters are configurable using the Windows registry. Setting a custom MaxFileSize value that is smaller than the size of the file prompts the file to be renamed with a .OLD
extension when the service is triggered. This move operation is performed by NT AUTHORITY\SYSTEM
, and can be abused to move a file of our choosing with the help of mount points and symbolic links.
Checking Current User Privileges:
We will use this exploit: https://github.com/RedCursorSecurityConsulting/CVE-2020-0668#:
Move those files to the target machine, for instance to the location C:\Tools\CVE-2020-0668\
At this point, we can use the exploit to create a file of our choosing in a protected folder such as C:\Windows\System32.
For that we need to be able to load a DLL at the location. Are we? No, probably we will need to combine this with other technique that grants us permissions on those binaries. We may think of three:
- UsoDllLoader
- DiagHub
- Abusing a third party software.
1. UsoDllLoader ⚠️ 2020-06-06 Update: this trick no longer works on the latest builds of Windows 10 Insider Preview. This means that, although it still works on the mainstream version of Windows 10, you should expect it to be patched in the coming months.
Starting from Windows 10, Microsoft introduced the Update Session Orchestrator
service. As a regular user, you can interact with this service using COM, and start an "update scan" (i.e. check whether updates are available) or start the download of pending updates for example. There is even an undocumented built-in tool called usoclient.exe
, which serves that purpose.
From an attacker's standpoint, this service is interesting because it runs as NT AUTHORITY\System
and it tries to load a non-existent DLL (windowscoredeviceinfo.dll
) whenever an Update Session is created.
This means that, if we found a privileged file write vulnerability in Windows or in some third-party software, we could copy our own version of windowscoredeviceinfo.dll
into C:\Windows\Sytem32\
and then have it loaded by the USO service to get arbitrary code execution as NT AUTHORITY\System
.
2. Diaghub Loads a custom dll in system32 via diaghub (original | myforked).
3. Third party
We can also look for any third-party software, which can be leveraged, such as the Mozilla Maintenance Service. This service runs in the context of SYSTEM and is startable by unprivileged users. The (non-system protected) binary for this service is located below.
Checking Permissions on Binary:
Generating Malicious Binary:
Hosting the Malicious Binary:
Downloading the Malicious Binary. We need two copies so we run twice:
Next, let's run the exploit. It accepts two arguments, the source and destination files.
Checking Permissions of New File: The exploit runs and executing icacls again shows the following entry for our user: WINLPE-WS02\htb-student:(F). This means that our htb-student user has full control over the maintenanceservice.exe binary, and we can overwrite it with a non-corrupted version of our malicious binary.
Output:
Replacing File with Malicious Binary: We can overwrite the maintenanceservice.exe binary in c:\Program Files (x86)\Mozilla Maintenance Service with a good working copy of our malicious binary created earlier before proceeding to start the service. In this example, we downloaded two copies of the malicious binary to C:\Users\htb-student\Desktop, maintenanceservice.exe and maintenanceservice2.exe. Let's move the good copy that was not corrupted by the exploit maintenanceservice2.exe to the Program Files directory, making sure to rename the file properly and remove the 2 or the service won't start.
The copy command will only work from a cmd.exe window, not a PowerShell console.
Now save the following to a handler.rc file in your kali attacking machine:
And from the kali attacking machine, run:
Start the service, and we should get a session as NT AUTHORITY\SYSTEM.
And now we can:
Last update: 2025-04-13 Created: April 13, 2025 08:35:24