Skip to content

theicfire/pygdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Features

  • Read function names from binaries
  • Set breakpoints
  • Read registers
  • Continue to next breakpoint
  • Read/Set Memory

Setup

  • Install Vagrant
  • git clone https://github.com/theicfire/pygdb
  • cd pygdb
  • vagrant up -- will take a bit of time
  • vagrant ssh

Now run these commands in the VM:

  • cd /vagrant
  • make test

All the tests should pass!

Example Usage

  • 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 that edx == 0x7, just like the assembly said it should have been.
  • Continue (Should finish): c
  • Quit: q

Future Priorities

  • Get this to run on 64 bit machines
  • Add any number of features that GDB has