Minimal C Debugger in Python
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
vagrant up-- will take a bit of time
Now run these commands in the VM:
All the tests should pass!
objdump -d hello
- Find somewhere to break. In this case we'll pick the start of the program:
- Start the debugger:
- Load the hello binary:
- Set a breakpoint:
- 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.
- Step one instruction.
- Get the registers again.
regs. Notice that
edx == 0x7, just like the assembly said it should have been.
- Continue (Should finish):
- Get this to run on 64 bit machines
- Add any number of features that GDB has