Rubug is a Ruby interface to the GNU debugger, GDB. It was lightly inspired by the PyDb module in Pedram Amini's PaiMei reversing framework. PaiMei/PyDbg is targetted at Win32 and in particular the Win32 debugging API. Rubug exposes samiliar functionality but against a GDB backend.
Install the latest Ruby gem:
Rubug allows programmatic control of GDB via the GDB
Machine Interface. You may send raw MI commands (using
#recv, or the convenience wrapper
#command). More practically — unless you happen to be
a GDB/MI expert — you can use the methods that mirror the standard
GDB CLI commands (eg
require 'rubug' gdb = Rubug::Gdb.new # Debugger object gdb.file('foo') # CLI command "file" gdb.run('arg1', 'arg2') # CLI command "run" with arguments gdb.register(method :bar) # Register event loop callback gdb.start_event_loop # Run the event loop
Responses to standard CLI commands are automatically checked against expected return values, but if you want to do more with them then you of course can: response contents (eg stack frames) are returned as objects that you can interrogate in your script via the documented API. The event loop callback mechanism allows your program to process command responses and asynchronous debugger notifications as they occur.
A simple command shell is provided for convenient debugging:
$ irb irb(main):001:0> require 'rubug' => true irb(main):002:0> Rubug::Gdb.shell > file foo ^done (gdb) > run aaaaaa ...
Here is an example simple fuzzer that runs the command
with a single argument that gets longer on each iteration until
crashes with segmentation violation. Please see the package
directory for other dastardly ideas.