|
| 1 | +# PrintNightmare_dll_check.ps1 |
| 2 | + |
| 3 | +A quick PowerShell script to recursively scan for unsigned dll in %windir%\system32\spool\drivers. |
| 4 | +The scan path can be quickly changed within the script to any other location. |
| 5 | + |
| 6 | +According to https://github.com/afwu/PrintNightmare a successful PrintNightmare attack places a malicious dll in %windir%\system32\spool\drivers. |
| 7 | +These dll are most likely unsigned (neither AuthentiCode nor directly signed) but this approach will also show up false-positives as well. |
| 8 | + |
| 9 | + |
| 10 | +Manual download of 3rd party tools |
| 11 | +---------------------------------- |
| 12 | + |
| 13 | +For licensing reasons we can't provide the script fully operational including sigcheck64.exe. |
| 14 | +Please manually download sigcheck64.exe from the offical Sysinternal website and place it next to PrintNightmare_dll_check.ps1. |
| 15 | + |
| 16 | +|Download URL: | Extracted filename: | |
| 17 | +| ------------ | ------------------- | |
| 18 | +|https://download.sysinternals.com/files/Sigcheck.zip | SigCheck64.exe | |
| 19 | + |
| 20 | + |
| 21 | +Requirements |
| 22 | +------------ |
| 23 | +-Download of Sysinternals Sigcheck.zip |
| 24 | +-Extracting of sigcheck64.exe from Sigcheck.zip |
| 25 | +-local user rights (Admin permission NOT required) |
| 26 | +-Internet connection for external check of unsigned dll with Virustotal.com (or remove the sigcheck parameters '-v -vt' to stay local) |
| 27 | + |
| 28 | + |
| 29 | +How to run |
| 30 | +---------- |
| 31 | +1. place PrintNightmare_dll_check.ps1 to any directory where the executing user has write permission (e.g. C:\temp or C:\users\%username%\Documents) |
| 32 | +2. place sigcheck64.exe next to PrintNightmare_dll_check.ps1 in the same directory |
| 33 | +3. `cmd` |
| 34 | +4. `powershell.exe -executionpolicy bypass C:\path_to\PrintNightmare_dll_check.ps1` |
| 35 | + |
| 36 | + |
| 37 | +Returncode (%errorlevel%) of script |
| 38 | +----------------------------------- |
| 39 | +0 = NO unsigned dll found |
| 40 | +1 = unsigned dll found -> check logfile for more details |
| 41 | + |
| 42 | + |
| 43 | +Outputs of script |
| 44 | +----------------- |
| 45 | +logfile: C:\path_to\PrintNightmare_dll_check_YYYYMMDD-HHMM.txt |
| 46 | +copy of unsigned dlls: C:\path_to\PrintNightmare_2nd_check_path\ |
| 47 | + |
| 48 | + |
| 49 | +Example of logfile - NO unsigned dll found |
| 50 | +------------------------------------------ |
| 51 | +20210707-1142 |
| 52 | +script start |
| 53 | + |
| 54 | +all dll files provide authenticode or are directly signed |
| 55 | +NO suspicious dll files detetcted |
| 56 | + |
| 57 | +script end |
| 58 | + |
| 59 | + |
| 60 | +Example of logfile - unsigned dll found |
| 61 | +--------------------------------------- |
| 62 | +20210707-1138 |
| 63 | +script start |
| 64 | + |
| 65 | +dll files without authenticode nor directly signed: |
| 66 | +Vix64AllProductsDyn.dll |
| 67 | + |
| 68 | + |
| 69 | +Sigcheck v2.81 - File version and signature viewer |
| 70 | +Copyright (C) 2004-2021 Mark Russinovich |
| 71 | +Sysinternals - www.sysinternals.com |
| 72 | + |
| 73 | +c:\test\printnightmare_2nd_check_path\Vix64AllProductsDyn.dll: |
| 74 | + Verified: Unsigned |
| 75 | + Link date: 14:15 30/04/2021 |
| 76 | + Publisher: n/a |
| 77 | + Company: VMware, Inc. |
| 78 | + Description: VMware application library |
| 79 | + Product: VMware Workstation |
| 80 | + Prod version: 16.1.2 build-17966106 |
| 81 | + File version: 16.1.2 build-17966106 |
| 82 | + MachineType: 64-bit |
| 83 | + MD5: 22F4B8122EBE333200E833E05C2E357C |
| 84 | + SHA1: B858B78C22ECCF9B7DA408C297BB53FAEFED6426 |
| 85 | + PESHA1: 5F20D482AE71A3B78CCF39D98991E2DA6F14DB6F |
| 86 | + PE256: 35AE6215FEAA28DB3A2F4CD5111CE61747481162B013DFCE3377EC4BE9748D0F |
| 87 | + SHA256: 985E8F96133B794A66CB1AF894AC5ED509AC3DE4A54DB73FD85C96505CC5D890 |
| 88 | + IMP: 9FB9711F21857F89F61E06F13A427CA8 |
| 89 | + VT detection: 0/73 |
| 90 | + VT link: https://www.virustotal.com/gui/file/985e8f96133b794a66cb1af894ac5ed509ac3de4a54db73fd85c96505cc5d890/detection |
| 91 | + |
| 92 | +script end |
| 93 | + |
| 94 | + |
| 95 | +How to test the script |
| 96 | +---------------------- |
| 97 | +Copy any unsigned dll from any local installed app (from C:\Program Files) to C:\Windows\System32\spool\drivers and run the script. |
0 commit comments