All Projects → david942j → gdb-ruby

david942j / gdb-ruby

Licence: MIT license
It's time for Ruby lovers to use Ruby in gdb, and gdb in Ruby!

Programming Languages

ruby
36898 projects - #4 most used programming language
python
139335 projects - #7 most used programming language
Makefile
30231 projects
C++
36643 projects - #6 most used programming language

Labels

Projects that are alternatives of or similar to gdb-ruby

gdb-automatic-deadlock-detector
Script adds new command to GDB which allows automatically detect C/C++ thread locking and deadlocks in GDB debugger
Stars: ✭ 60 (+9.09%)
Mutual labels:  gdb
gdb
Unofficial Windows build of gdb with added features.
Stars: ✭ 36 (-34.55%)
Mutual labels:  gdb
minimal gdb
🐛 Lightweight vim -> gdb broker which uses .gdbinit gdb config file to export breakpoints
Stars: ✭ 16 (-70.91%)
Mutual labels:  gdb
bitvisor-gdb
gdbserver implementation on BitVisor
Stars: ✭ 23 (-58.18%)
Mutual labels:  gdb
vim-easydebugger
A VIM multi-language debugger plugin
Stars: ✭ 47 (-14.55%)
Mutual labels:  gdb
xboxpy
Python module to interface with original Xbox hard- and software
Stars: ✭ 23 (-58.18%)
Mutual labels:  gdb
TheVimIDE
Modern Vim IDE with support for C/C++, Java, Python, Lua, PHP, JavaScript, Ruby and much more ...
Stars: ✭ 33 (-40%)
Mutual labels:  gdb
gdb 2 root
This python script adds some usefull command to stripped vmlinux image
Stars: ✭ 20 (-63.64%)
Mutual labels:  gdb
gdb
Go GDB/MI interface
Stars: ✭ 70 (+27.27%)
Mutual labels:  gdb
gdb-dashboard
Modular visual interface for GDB in Python
Stars: ✭ 8,699 (+15716.36%)
Mutual labels:  gdb
gdb-helpers
GDB helper scripts
Stars: ✭ 37 (-32.73%)
Mutual labels:  gdb
Scuffed Low Level Stash
Stash for Binary Exploitation and Reverse Engineering Resources
Stars: ✭ 83 (+50.91%)
Mutual labels:  gdb
gdb graphs
To visualize function call flow for a C/C++ program using gdb and python
Stars: ✭ 61 (+10.91%)
Mutual labels:  gdb
gdbface
GDB web frontend written in Javascript
Stars: ✭ 16 (-70.91%)
Mutual labels:  gdb
vdb
A set of python visual enhancements for gdb.
Stars: ✭ 23 (-58.18%)
Mutual labels:  gdb
OverRide
Binary Exploitation and Reverse-Engineering (from assembly into C)
Stars: ✭ 69 (+25.45%)
Mutual labels:  gdb
exploiting
Exploiting challenges in Linux and Windows
Stars: ✭ 122 (+121.82%)
Mutual labels:  gdb
metal.test
Deprecated, superseded by https://github.com/metal-ci/test
Stars: ✭ 41 (-25.45%)
Mutual labels:  gdb
lldbg
A lightweight native GUI for LLDB.
Stars: ✭ 83 (+50.91%)
Mutual labels:  gdb
kakoune-gdb
gdb integration plugin
Stars: ✭ 44 (-20%)
Mutual labels:  gdb

Build Status Gem Version Code Climate Issue Count Test Coverage Inline docs MIT License

GDB-Ruby

It's time for Ruby lovers to use Ruby in gdb and gdb in Ruby!

Achieve two things in one gem:

  1. Launching Ruby interactive shell (pry) in gdb.
  2. gdb Ruby-binding, i.e. communicate with gdb in Ruby scripts.

Use Ruby in gdb

We provide a binary gdb-ruby (a Ruby script actually) with usage exactly the same as a normal gdb, while has two extra commands: ruby and pry!

See examples below:

$ gdb-ruby -q bash
Reading symbols from bash...(no debugging symbols found)...done.
(gdb) help ruby
Evaluate a Ruby command.
There's an instance 'gdb' for you. See examples.

Syntax: ruby <ruby code>

Examples:
    ruby p 'abcd'
    # "abcd"

Use gdb:
    ruby puts gdb.break('main')
    # Breakpoint 1 at 0x41eed0

Method defined will remain in context:
    ruby def a(b); b * b; end
    ruby p a(9)
    # 81
(gdb) help pry
Enter Ruby interactive shell.
Everything works like a charm!

Syntax: pry

Example:
    pry
    # [1] pry(#<GDB::EvalContext>)>

Integrate with other gdb extensions

Completely NO effort if you want to use gdb-ruby with other gdb extensions.

For example, I usually use the plugin gef with gdb. Everything works as usual when integrated with gdb-ruby:

Launching with $ gdb-ruby -q bash

ruby-in-gef

Use gdb in Ruby

Communicate with gdb in your Ruby script.

Useful methods

Basic usage is use execute to do anything you want to execute inside gdb, while gdb-ruby provides some useful methods listed as following:

  • break: Set break points. Alias: b
  • run: Run. Alias: r
  • register: Get value by register's name. Alias: reg
  • text_base: Get current running program's text base, useful for a PIE binary.
  • pid: Get the process id of running process.
  • read_memory: Read process's memory, with friendly type casting. Alias: readm
  • write_memory: Write process's memory, useful for dynamic analysis. Alias: writem
  • interact: Back to normal gdb interactive mode.

All of these methods are fully documented at online doc, go for it!

Examples

Play with argv using gdb-ruby.

This script does:

  1. Set a break point at main.
  2. Get argv using register and read_memory.
  3. Change argv using write_memory.
require 'gdb'

# launch a gdb instance
gdb = GDB::GDB.new('bash')

# 1. set breakpoint
gdb.break('main')
#=> "Breakpoint 1 at 0x41eed0"
gdb.run('-c "echo cat"')

# 2. get argv pointers
rdi = gdb.reg(:rdi)
#=> 3
rsi = gdb.reg(:rsi)
argv = gdb.readm(rsi, rdi, as: :u64)
argv.map { |c| '0x%x' % c }
#=> ['0x7fffffffe61b', '0x7fffffffe625', '0x7fffffffe628']

# 3. overwrite argv[2]'s 'cat' to 'FAT'
gdb.writem(argv[2] + 5, 'FAT') # echo FAT

puts gdb.execute('continue')
# Continuing.
# FAT
# [Inferior 1 (process 32217) exited normally]

Set a break point, run it, and back to gdb interactive mode.

require 'gdb'

# launch a gdb instance
gdb = GDB::GDB.new('bash')
# set breakpoints
gdb.break('main')
gdb.run
# to show the process do stop at the breakpoint
gdb.execute('info reg rip')
#=> "rip            0x41eed0\t0x41eed0 <main>"

# interaction like normal gdb!
gdb.interact

Installation

Available on RubyGems.org!

$ gem install gdb

Development

git clone https://github.com/david942j/gdb-ruby
cd gdb-ruby
bundle
bundle exec rake

Bugs & Feedback

Feel free to file an issue if you find any bugs. Any feature requests and suggestions are welcome! 😬

Growing up

gdb-ruby is under developing, give it a star and watch for latest updates!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].