
The Windows Print Spooler privilege escalation vulnerability (CVE-2019-1040/CVE-2019-1019) has been implemented as a Reflective DLL for penetration testing.
PrintSpoofer is a tool that performs local privilege escalation by exploiting a vulnerability in the Windows Print Spooler service (CVE-2019-1040 / CVE-2019-1019). This project implements the PrintSpoofer exploit in Reflective DLL format, making it suitable for use with penetration testing frameworks such as Cobalt Strike.
PrintSpoofer exploits a vulnerability in the Windows Print Spooler service that allows a low-privileged user to obtain SYSTEM-level privileges. The exploit abuses the way the Print Spooler service handles named pipes.
PrintSpoofer operates by performing the following steps:
The exploit first checks whether the current token has the SE_IMPERSONATE_NAME privilege. This is required to impersonate another user’s token.
A named pipe is created using a random UUID. The pipe path is:
\\.\pipe\<UUID>\pipe\spoolss
An asynchronous connection is awaited on the created named pipe. An event is created, and the pipe is prepared to accept incoming connections.
In a separate thread, an RPC call is made to the Print Spooler service.
By invoking RpcRemoteFindFirstPrinterChangeNotificationEx, the service attempts to connect to the pipe we created.
When the Print Spooler service (running as SYSTEM) connects to the named pipe, the exploit uses ImpersonateNamedPipeClient to impersonate the service’s token.
This results in obtaining SYSTEM privileges.
With a SYSTEM token, high-privilege actions can now be executed.
The Windows Print Spooler service processes printer notifications through named pipes. Because the service does not properly validate pipe connections, an attacker can coerce it into connecting to a malicious pipe and then impersonate the SYSTEM token.
The project communicates with the Print Spooler service using the MS-RPRN (Print System Remote Protocol). This protocol is defined through an IDL (Interface Definition Language) file and enables RPC calls.
A reflective DLL behaves differently from standard DLLs:
LoadLibrary APIOpen the PrintSpoofer.sln file in Visual Studio.
Select your Solution Platform and Configuration:
x64 or Win32 (depending on the target architecture)Release (production) or Debug (development)Build the solution through Build Solution (Ctrl+Shift+B).
The compiled DLL will be located at:
PrintSpoofer\x64\Release\PrintSpoofer.dll (for x64)
PrintSpoofer\Win32\Release\PrintSpoofer.dll (for x86)
The project uses the following preprocessor definitions:
REFLECTIVE_DLL_EXPORTS: Enables Reflective DLL exportsREFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN: Uses a custom DllMainREFLECTIVEDLLINJECTION_VIA_LOADREMOTELIBRARYR: Enables LoadRemoteLibraryR (in Release mode)PrintSpoofer can be used with Cobalt Strike's elevate command:
elevate PrintSpoofer LISTENER_NAME
Where:
PrintSpoofer: The elevator module nameLISTENER_NAME: The listener that will receive the elevated shellThe DLL can be manually loaded using Reflective DLL Injection techniques.
A successful exploit execution will show:
[+] Found privilege: SeImpersonatePrivilege
[+] Named pipe listening...
[+] ImpersonateNamedPipeClient OK
[+] Exploit successfully, enjoy your shell
dllmain.cppDllMain)PrintSpoofer.cppms-rprn.idlReflectiveLoader.cppThis tool is intended for educational purposes only and for authorized penetration testing.
This project is licensed under the MIT License. For more information, see the LICENSE file.