The goal of this project is to make a c debugger, similar to gdb, in python. This is exclusively for educational purposes :)
This debugger works by using the ptrace system call. A good chunk of the theory is here.
- Read function names from binaries
- Set breakpoints
- Read registers
- Continue to next breakpoint
- Read/Set Memory
- Install Vagrant
git clone https://github.com/theicfire/pygdb
cd pygdb
vagrant up
-- will take a bit of timevagrant ssh
Now run these commands in the VM:
cd /vagrant
make test
All the tests should pass!
cd /vagrant
make
objdump -d hello
- Find somewhere to break. In this case we'll pick the start of the program:
8048080
- Start the debugger:
make interactive
- Load the hello binary:
exec-file hello
- Set a breakpoint:
b 0x8048080
- Run the binary:
run
. Nothing will seem to happen, but the program has started to run and hit a breakpoint. - Get the registers. You'll notice eip is one after our breakpoint.
regs
- Step one instruction.
s
. - Get the registers again.
regs
. Notice thatedx == 0x7
, just like the assembly said it should have been. - Continue (Should finish):
c
- Quit:
q
- Get this to run on 64 bit machines
- Add any number of features that GDB has