3.5 KiB
Setup pwndbg for Development
Installing pwndbg from source
Run the following:
git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh
Officially supported is Ubuntu 22.04 and later, but the setup script also supports the following distributions:
- Debian-based OSes (via apt-get)
- Fedora and Red Hat (via dnf)
- Clear (via swiped)
- OpenSUSE LEAP (via zypper)
- Arch and Manjaro (via community AUR packages)
- Void (via xbps)
- Gentoo (via emerge)
!!! tip If you have an older ubuntu version you may still use pwndbg:
- for Ubuntu 20.04 use the [2024.08.29 release](https://github.com/pwndbg/pwndbg/releases/tag/2024.08.29)
- for Ubuntu 18.04 use the [2023.07.17: ubuntu18.04-final release](https://github.com/pwndbg/pwndbg/releases/tag/2023.07.17)
however if you wish to contribute, it is recommended you upgrade your distribution.
Running with GDB
Pwndbg requires GDB 12.1 or later. If the GDB version your distro provides is too old, build GDB from source:
sudo apt install libgmp-dev libmpfr-dev libreadline-dev texinfo # required by build
git clone git://sourceware.org/git/binutils-gdb.git
mkdir gdb-build
cd gdb-build
../binutils-gdb/configure --enable-option-checking --disable-nls --disable-werror --with-system-readline --with-python=$(which python3) --with-system-gdbinit=/etc/gdb/gdbinit --enable-targets=all --disable-binutils --disable-ld --disable-gold --disable-gas --disable-sim --disable-gprof
make -j $(nproc)
Since the ./setup.sh script made it so you source pwndbg from your ~/.gdbinit, pwndbg will start up automatically any time you run gdb.
Running with LLDB
Pwndbg requires LLDB 19 or later. You can get it like this on Ubuntu 24.04:
sudo apt install -y lldb-19 liblldb-19-dev
but it will be added to your PATH as lldb-19 so you should either alias it or export it in your shell:
export PATH=/usr/lib/llvm-19/bin/:$PATH
so you can invoke it as lldb. Also export this environment variable:
export LLDB_DEBUGSERVER_PATH=/usr/lib/llvm-19/bin/lldb-server
Pwndbg doesn't use the lldb driver binary directly, it drives its own REPL and interacts with LLDB through liblldb.
You can run pwndbg with lldb by running:
uv run python pwndbg-lldb.py [binary-to-debug]
The development environment
After installing pwndbg like described above, there are a few ways to set up the development environment. The simplest one is by running:
./setup-dev.sh
but you can also use the docker container or develop using nix.
Development from docker
You can create a Docker image with everything already installed for you. You can use docker compose
docker compose run -i main
or build and run the container with
docker build -t pwndbg .
docker run -it --cap-add=SYS_PTRACE --security-opt seccomp=unconfined -v `pwd`:/pwndbg pwndbg bash
Development using Nix
Pwndbg supports development with Nix which installs all the required development dependencies:
- Install Nix with Determinate Nix Installer.
- Enter the development shell with
nix developor automate this withdirenv. - Run local changes with
pwndbgorpwndbg-lldb. Run tests with./tests.sh.