🖨️ PrintNightmare (SeLoadDriverPrivilege)
Kernel exploits
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.
It is a flaw in RpcAddPrinterDriver which is used to allow for remote printing and driver installation. This function is intended to give users with the Windows privilege SeLoadDriverPrivilege
the ability to add drivers to a remote Print Spooler.
This right is typically reserved for users in the built-in Administrators group and Print Operators who may have a legitimate need to install a printer driver on an end user's machine remotely. The flaw allowed any authenticated user to add a print driver to a Windows system without having the privilege mentioned above, allowing an attacker full remote code execution as SYSTEM on any affected system.
The flaw affects every supported version of Windows, and being that the Print Spooler runs by default on Domain Controllers, Windows 7 and 10, and is often enabled on Windows servers, this presents a massive attack surface, hence "nightmare." Microsoft initially released a patch that did not fix the issue (and early guidance was to disable the Spooler service, which is not practical for many organizations) but released a second patch in July of 2021 along with guidance to check that specific registry settings are either set to
0
or not defined. Once this vulnerability was made public, PoC exploits were released rather quickly.****
cube0x0 exploit
We will be using cube0x0's exploit.
For this exploit to work successfully, we will need to use cube0x0's version of Impacket. Consider the posibility of using pyenv like this:
Enumerating for MS-RPRN:
After confirming this, we can proceed with attempting to use the exploit. We can begin by crafting a DLL payload using msfvenom.
We will then host this payload in an SMB share we create on our attack host using smbserver.py.
Then we will need to open a two new terminals in our attacker machine:
The payload will then call back to our multi handler giving us an elevated SYSTEM shell.
calebstewart Powershell exploit
This PowerShell implementation can be used for quick local privilege escalation. By default, this script adds a new local admin user, but we can also supply a custom DLL to obtain a reverse shell or similar if adding a local admin user is not in scope.
Checking for Spooler Service:
Output:
Adding Local Admin with PrintNightmare PowerShell PoC:
First start by bypassing the execution policy on the target host:
Now we can import the PowerShell script CVE-2021-1675.ps1
and use it to add a new local admin user.
Confirming New Admin User: If all went to plan, we will have a new local admin user under our control. Adding a user is "noisy," We would not want to do this on an engagement where stealth is a consideration. Furthermore, we would want to check with our client to ensure account creation is in scope for the assessment.
Last update: 2025-04-13 Created: January 18, 2025 19:59:20