TP4 — Exploitation de CVE-2021-3156, forensique mémoire avec Volatility 3 (LiME) et réponse aux incidents (Hydra, journalctl, iptables). Rapport FR.
Operating Systems Security — CS.ENG.4 — 2025/2026 USTHB — Faculty of Computer Science Student: BOUIKNI Lydia Hana · Supervisor: Pr. Dr. Sofiane HAMRIOUI Session 04 — May 1, 2026
⚠️ Work carried out on an isolated VMware virtual machine, for strictly educational purposes. The real exploitation of these techniques outside a laboratory that you own is illegal.
This lab experiments with three fundamental areas of offensive and defensive cybersecurity:
sudo, followed by application of the patch.| Item | Value |
|---|---|
| Host system | Ubuntu 24.04 LTS (VMware Virtual Platform) |
| Hypervisor | VMware Workstation |
| Kernel | 6.14.0-36-generic |
| Main tools | Volatility 3 (v2.28.0), LiME, Hydra v9.5 |
| User | hana (UID 1000) |
| CVE-2021-3156 — Baron Samedit | |
|---|---|
| Vulnerable versions | sudo ≤ 1.8.31 (Ubuntu Focal 20.04) |
| CVSS Score | 7.8 (High) |
| Impact | Local privilege escalation to root |
CVE-2021-3156 is a heap buffer overflow discovered in sudo. It allows any local user, without a password, to obtain a root shell by exploiting the sudoedit command. This vulnerability affected millions of Linux and Unix systems.
💡 Unlike TP2 (where the exploit failed due to an incompatible
libc-2.39), the environment of this TP4 allows a successful exploitation: the root shell is actually obtained.
whoami # => hana (utilisateur standard)
make # compile l'exploit
./exploit
Figure 4.1 — Standard user hana before exploitation.
Figure 4.2 — Compiling the exploit with make and obtaining the root shell (#).
Figure 4.3 — Root shell obtained: whoami returns root, id confirms uid=0.
✅ The exploit succeeded — a
#(root) shell is obtained without a password.whoamireturnsrootandidconfirmsuid=0(root).
sudo apt update && sudo apt install --only-upgrade sudo
Figure 4.4 — Installing patch sudo.
Figure 4.5 — After patch: ./exploit returns only the usage message of sudoedit.
✅ After updating
sudo, the exploit fails and returns only the usage message ofsudoedit. The attack is no longer possible.
Unlike the planned lab on VirtualBox (VBoxManage), the environment is VMware. The LiME tool (Linux Memory Extractor) was used to capture the RAM.
# Installation des dépendances et compilation de LiME
sudo apt install linux-headers-$(uname -r) build-essential git -y
git clone https://github.com/504ensicsLabs/LiME
cd LiME/src
make
# Génération du dump mémoire
sudo insmod lime-$(uname -r).ko "path=/tmp/memory.lime format=lime"
ls -lh /tmp/memory.lime
Figure 4.6 — Generated memory dump: memory.lime file of 8 GB.
✅ The
/tmp/memory.limefile was created successfully (8.0 GB, = total RAM of the VM). Script:scripts/01_lime_dump.sh
# Environnement virtuel Python
python3 -m venv ~/volatility-env
source ~/volatility-env/bin/activate
pip install volatility3
# Génération du Symbol Table (ISF)
sudo apt install linux-image-$(uname -r)-dbgsym -y
git clone https://github.com/volatilityfoundation/dwarf2json
cd dwarf2json && go build
sudo ./dwarf2json linux --elf /usr/lib/debug/boot/vmlinux-$(uname -r) > ~/linux-$(uname -r).json
cp ~/linux-$(uname -r).json \
~/volatility-env/lib/python3.12/site-packages/volatility3/framework/symbols/linux/
Script:
scripts/02_volatility_setup.sh
📌 Why a Symbol Table (ISF)? Volatility needs to know the exact layout of kernel structures in memory. This information comes from the kernel's debug symbols (
-dbgsym), converted to JSON bydwarf2json. Without this file, the analysis fails (see Figure 4.7).
linux.pslist — Process listvol -f /tmp/memory.lime linux.pslist
Figure 4.7 — First attempt: symbol table error (before ISF generation).
Figure 4.8 — linux.pslist after fixing the symbol table — start of output.
Figure 4.9 — Full output of linux.pslist — list of processes in memory.
Suspicious processes identified
vol -f /tmp/memory.lime linux.pslist | grep -E "nc|bash|sh|insmod|sudo"