Ubuntu-Based Environment for PWN

There are several choices for implementing ctf environment for PWN. For example, docker containers or virtual machines including Ubuntu 16 18 20, Kali Linux and so on.

Setting Up

  1. Apt: Tsinghua Mirror
  2. Script Language: Python3 with pip
  3. Editor: Neovim with SpaceVim, Sublime
  4. Dependent Library: 32bit 64bit
  5. Shell: zsh with oh-my-zsh
  6. Toolset: pwntools
  7. GDB: pwndbg peda gef
  8. Gadget: ROPgadget Onegadget
  9. LibcSearcher
  10. Hardware Virtualization: qemu
  11. Multiple Architecture Debugger: gdb-multiarch

1. Set up Apt Sources Mirroring

Tsinghua Mirror: https://mirrors.tuna.tsinghua.edu.cn/help/ubuntu/

Alibaba Mirror: https://developer.aliyun.com/mirror/ubuntu/

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo vim /etc/apt/sources.list

3. Neovim with Spacevim and Sublime

sudo apt install neovim -y
wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text

4. Dependent Library: 32bit

# 32 bit dependent library
sudo apt install lib32ncurses6, lib32z1

5. ZSH with Oh-My-Zsh

sudo apt install git zsh -y
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

Recommended Plugins for oh-my-zsh:

6. Pwntools

sudo apt install python3 python3-pip python3-dev
sudo pip install --upgrade pip
sudo pip install --upgrade pwntools

7. Pwndbg Peda Gef

7.1 pwndbg

Github Repo Address: https://github.com/pwndbg/pwndbg/

git clone https://github.com/pwndbg/pwndbg
cd pwndbg
./setup.sh

7.2 Peda

Github Repo Address: https://github.com/longld/peda/

git clone https://github.com/longld/peda.git ~/peda
echo "source ~/peda/peda.py" >> ~/.gdbinit
echo "DONE! debug your program with gdb and enjoy"

7.3 Gef

Github Repo Address: https://github.com/hugsy/gef/
Documentation: https://gef.readthedocs.io/en/master/

# via the install script
## using curl
$ bash -c "$(curl -fsSL http://gef.blah.cat/sh)"

## using wget
$ bash -c "$(wget http://gef.blah.cat/sh -O -)"

# or manually
$ wget -O ~/.gdbinit-gef.py -q http://gef.blah.cat/py
$ echo source ~/.gdbinit-gef.py >> ~/.gdbinit

# or alternatively from inside gdb directly
$ gdb -q
(gdb) pi import urllib.request as u, tempfile as t; g=t.NamedTemporaryFile(suffix='-gef.py'); open(g.name, 'wb+').write(u.urlopen('https://tinyurl.com/gef-master').read()); gdb.execute('source %s' % g.name)

8. one_gadget

Github Repo Address: https://github.com/david942j/one_gadget/

sudo apt install ruby
sudo gem install one_gadget

9. Libc Tools

LibcSearcher: https://github.com/lieanu/LibcSearcher/
Online-LibcSearcher: https://github.com/eclipse-yes/Online-LibcSearcher/