martin carpenter

contents

most popular
2012/05/05, updated 2012/12/15
Ubuntu unity lens for vim
2010/04/14
ckwtmpx

rubug

Introduction

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.

Installation

Install the latest Ruby gem:

XXX

What can I do with Rubug?

Rubug allows programmatic control of GDB via the GDB Machine Interface. You may send raw MI commands (using #send and #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 #file and #run).

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 foo with a single argument that gets longer on each iteration until foo crashes with segmentation violation. Please see the package examples directory for other dastardly ideas.

XXX