2 Environment Setup

2.1 Lab Baseline

2.1.1 Ubuntu Image Installation

The lab uses Ubuntu 24.04.1 Desktop: ubuntu-24.04.1-desktop-amd64.iso

During installation, I recommend temporarily disconnecting the VM from the Internet. This prevents the installer from pulling newer packages or silently moving the kernel away from the target version.

Before installing any tooling, freeze the lab immediately so the kernel does not drift after a reboot, background timer, or automatic package refresh:

Bash
# Disable unattended upgrades
sudo systemctl disable --now unattended-upgrades.service
sudo systemctl mask unattended-upgrades.service

# Disable APT periodic timers
sudo systemctl disable --now apt-daily.timer apt-daily-upgrade.timer
sudo systemctl mask apt-daily.timer apt-daily-upgrade.timer

# Disable APT periodic services
sudo systemctl disable --now apt-daily.service apt-daily-upgrade.service
sudo systemctl mask apt-daily.service apt-daily-upgrade.service

# Disable APT periodic upgrade policy
sudo tee /etc/apt/apt.conf.d/99-no-auto-upgrades >/dev/null <<'EOF'
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";
EOF

# Hold the current kernel packages
sudo apt-mark hold \
linux-generic \
linux-image-generic \
linux-headers-generic \
linux-modules-extra-$(uname -r) \
linux-image-$(uname -r) \
linux-headers-$(uname -r)

Verify that the automatic upgrade path is disabled:

Bash
systemctl list-unit-files | grep -E 'apt-daily|unattended'
apt-config dump | grep -E 'APT::Periodic'

Confirm the kernel baseline before moving on. In this lab, the target kernel is 6.8.0:

axura @ labyrinth :~
axura@pwnlab:~$ uname -a
Linux pwnlab 6.8.0-41-generic #41-Ubuntu SMP PREEMPT_DYNAMIC Fri Aug  2 20:41:06 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

2.1.2 Tooling Installation

After the frozen baseline snapshot is created, reconnect the network and install the lab tooling.

Do not run any full-system upgrade commands for lab purpose:

Bash
sudo apt upgrade
sudo apt full-upgrade
sudo do-release-upgrade

Install the core build, tracing, debugging, and reversing tools:

Bash
sudo apt update && sudo apt install -y \
    build-essential make cmake nasm \
    gcc-multilib gdb gdb-multiarch \
    git vim curl tmux gawk ripgrep htop jq silversearcher-ag tree unzip bison flex bc ssh \
    strace ltrace vmtouch \
    python3 python3-pip python3-venv python3-dev \
    pkg-config \
    libssl-dev libelf-dev libcapstone-dev libncurses-dev \
    qemu-system-x86 qemu-utils qemu-kvm \
    linux-tools-common linux-tools-generic linux-tools-$(uname -r) \
    bpftrace trace-cmd 

Install Python exploitation tooling:

Bash
pip3 install --break-system-packages \
    pwntools \
    ropper \
    capstone \
    unicorn \
    keystone-engine \
    z3-solver

2.2 Kernel Symbols and Source Mapping

For kernel tracing, source lookup, and structure inspection, install the source and debugging helpers:

Bash
sudo apt install -y \
    python3-drgn \
    crash \
    dwarves \
    systemtap \
    linux-headers-$(uname -r) \
    linux-source

Under /usr/src, the layout should look similar to this:

axura @ labyrinth :~
axura@pwnlab:~$ ls /usr/src/ -l
total 16
drwxr-xr-x 26 root root 4096 May 12  2026 linux-headers-6.8.0-41
drwxr-xr-x  7 root root 4096 May 12  2026 linux-headers-6.8.0-41-generic
drwxr-xr-x  2 root root 4096 May 12 16:10 linux-source-6.8.0
lrwxrwxrwx  1 root root   45 Apr 12 04:54 linux-source-6.8.0.tar.bz2 -> linux-source-6.8.0/linux-source-6.8.0.tar.bz2
drwxr-xr-x  4 root root 4096 May 12 16:03 python3.12

Extract the kernel source into workspace:

Bash
mkdir -p ~/source
cd ~/source
sudo tar -xf /usr/src/linux-source-*.tar.bz2

We should now see the kernel source tree like:

axura @ labyrinth :~
axura@pwnlab:~/source$ tree linux-source-6.8.0/ -L 1
linux-source-6.8.0/
├── arch
├── block
├── certs
├── COPYING
├── CREDITS
├── crypto
├── Documentation
├── drivers
├── dropped.txt
├── fs
├── generic.depmod.log
├── generic.inclusion-list.log
├── include
├── init
├── io_uring
├── ipc
├── Kbuild
├── Kconfig
├── kernel
├── lib
├── LICENSES
├── MAINTAINERS
├── Makefile
├── mm
├── net
├── README
├── rust
├── samples
├── scripts
├── security
├── sound
├── tools
├── ubuntu
├── Ubuntu.md
├── usr
└── virt

26 directories, 11 files