This is the reason behind the development of many plug-ins that can make the process of reversing and debugging so much easier. Namely, three of the most popular are:
Of course, all of them come with their pros and cons. Maybe for the task, maybe the features, or even the interface. We all have our preferences. Personally, I prefer Pwndbg’s interface more, but seriously Peda’s cyclic pattern creation and offset search functionality are extremely handy.
Still, I hate having to manually change or replace the
.gdbinit file every time I want to use a different plugin. It’s not about the time and effort, but more because it’s a distraction from my primary task, that I would like to avoid.
Therefore, the purpose of this blog post is to describe a very simple way of switching between plugins in a single command.
I have created a bash script that executes the instructions below in one command so for a rapid setup clone the repository below and run
This is a script which installs Pwndbg, GEF, and Peda GDB plugins in a single command. Run install.sh and then use one…
Initially, the plugins need to be downloaded and set up. As such follow the commands below:
git clone https://github.com/pwndbg/pwndbg
mv pwndbg ~/pwndbg-src
echo "source ~/pwndbg-src/gdbinit.py" > ~/.gdbinit_pwndbg
git clone https://github.com/longld/peda.git ~/peda
wget -q -O ~/.gdbinit-gef.py https://github.com/hugsy/gef/raw/master/gef.py
echo source ~/.gdbinit-gef.py >> ~/.gdbinit
Combining all in One
Inherently, these plugins modify the
.gdbinit file and are launched along with gdb. Now, here is the trick, what if we had a
.gdbinit file that contains configurations for all plugins so that they are conditionally activated based on the gdb command? This is exactly what we will be doing.
.gdbinit file, delete any contents and paste the following configuration:
Initializes the PEDA (Python Exploit Development Assistant for GDB) framework
Initializes GEF (GDB Enhanced Features)
Additionally, create the following 3 files in your
/usr/bin/gdb-peda and paste the following:
exec gdb -q -ex init-peda "$@"
exec gdb -q -ex init-pwndbg "$@"
exec gdb -q -ex init-gef "$@"
The last step is to give executable permissions to all three of the files created previously. For that, run:
chmod +x /usr/bin/gdb-*
That was all! You see? Simple.
Now you can test it by running either one of the three commands:
Hope this helps folks. Till next time.