0x00 漏洞影響面
危害:這個漏洞級別屬於稍次於Zerologon
的打域利器之一. 和以往的打印機協議中繼/委派系列,危害度和利用條件基本在同一維度,
沒全量打補丁且重啟生效的甲方/網管朋友們,得抓緊時間了.
筆者測試線上,全補丁機器依然可打。網管朋友們可以阻斷+感知
同步操作了.
影響版本
Windows Server 2019
Windows Server 2016
Windows Server 2012 R2
Windows Server 2012
Windows Server 2008 R2
Windows Server 2008
0x01 漏洞利用條件
pDriverPath
知道一個驅動的絕對路徑,和系統版本有關
新版exp,有enum驅動絕對路徑的接口,成功率更高講道理: 一個普通域賬號/或者機器賬號權限
如果條件合適, 只需要進入你的辦公網.
網絡權限
獲取機器賬號或中繼,可能的操作:
mitm6 NBT-NS LLMNR wpad等
0x02 前文QA環節
6月的補丁安裝且重啟了,為啥還是被打了?
6月的補丁生效的是本地提權, 遠程條件合適還是可以打,比如DC.
你確定你所有的DC/Exchange大幾十臺,都打了補丁?都重啟生效了?有無正反向的測試驗證 ?
dll
已經看到過來下載了,為啥沒上線?請用
64
位的dll, 本地確保調試OK
windows defender
或其他殺軟,確認繞過了?本地/測試環境確保調試OK

win server 2012 DC
不能打?
筆者多個環境測試成功, 但不保證都可以打.
保持懷疑和審慎態度,github開源的一定就沒問題麼?
測試前 smbclient.py先測試, 如果rpc_s_access_denied, 賬號密碼hash沒有問題, 有沒有可能poc實現的有些許問題?
前面一切正常,就是無法下載dll, 是不是不受影響了?回顯:
ERROR_BAD_NET_RESP - The specified server cannot perform the requested operation.
這是由於
win 10/server 2016 某小版本後安全性提升的結果
, 可本地測試dir \\vnc_host\share
,查看回顯, 如下圖即為該情況. 如圖只可以抵禦一些攻擊的,但不完全免疫此次漏洞。筆者測試了2種方法可以直接bypass, 另有幾種可能的繞過思路未實踐測試。
0x03 止損措施
DC/exchange/域管常登機器/重要資產機器,不需要打印機協議
的, 直接下掉.
//cmd:
net stop spooler && sc config spooler start=disabled
//PowerShell:
Stop-Service -Name Spooler -Force;
Set-Service -Name Spooler -StartupType Disabled
ACL規則
//通過 PowerShell 部署(手動或通過 RMM)創建 ACL
$Path = "C:\Windows\System32\spool\drivers"
$Acl = Get-Acl $Path
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("System", "Modify", "ContainerInherit, ObjectInherit", "None", "Deny")
$Acl.AddAccessRule($Ar)
Set-Acl $Path $Acl
//通過 PowerShell 部署刪除 ACL (thx u/bclimer !)
$Path = "C:\Windows\System32\spool\drivers"
$Acl = Get-Acl $Path
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule("System", "Modify", "ContainerInherit, ObjectInherit", "None", "Deny")
$Acl.RemoveAccessRule($Ar)
Set-Acl $Path $Acl
組策略封禁
域下發組策略
gpmc.msc
//gpedit.msc
計算機配置/管理模板/打印機
//選擇禁用本地組策略
gpedit.msc
Policies/Windows Settings/Security Settings/System Services/Print Spooler
//選擇禁用組策略生效後, 服務自動關閉, 無法繼續攻擊

0x04 檢測和防禦
已有事件日誌分析
安全日誌分析:
Microsoft-Windows-Security-Auditing
分析RelativeTargetName
, 注意bypass的情況.出口smb日誌
Microsoft-Windows-SmbClient/安全
出去的鏈接分析異常 
webdav嘗試等 
Sysmon日誌: 通過
spoolsv.exe
進程尋找 ImageLoad(事件 ID 7)的使用非標事件日誌採集和監控(特異性好)
開啟記錄
$logDeets = Get-LogProperties 'Microsoft-Windows-PrintService/Operational'
$logDeets.Enabled = $true
Set-LogProperties -LogDetails $logDeets事件 ID 316
Microsoft-Windows-PrintService/Operational
Microsoft-Windows-PrintService/Admin
註冊表變動監控
驅動相關:
HKLM\SYSTEM\CurrentControlSet\Control\Print\Environments\Windows x64\Drivers\
文件變動監控(注意bypass的情況/目錄穿透):
目錄路徑
C:\Windows\System32\spool\drivers\x64\*
特定目錄
C:\Windows\System32\spool\drivers\x64\
的*.dll
新增;特定目錄子目錄創建
C:\Windows\System32\spool\drivers\x64\
, 如old
;spoolsv.exe
寫入 (Sysmon 事件id 11) 和刪除 (Sysmon 事件id 23).dll
文件其他弱特徵規則
rpcdump
等的探測規則進程的出網日誌
impacket的協議特徵檢測
nids的相關規則
0x05 參考鏈接
https://doublepulsar.com/zero-day-for-every-supported-windows-os-version-in-the-wild-printnightmare-b3fdb82f840c
https://www.reddit.com/r/msp/comments/ob6y02/critical_vulnerability_printnightmare_exposes/
https://mp.weixin.qq.com/s/k4OwCcJJxm-UHMdVdfBCIw
0x06 申明
以上部分操作,實驗室測試環境執行可以阻斷和檢測部分攻擊,但不保證對生產環境無任何不良影響,請確認和充分測試你的所有變更操作.
由於個人時間和知識有限,如有錯誤和遺漏的,請私聊我.
最後祝大家週末加班快樂. 😄