Tools for working with x86 assembly in Ruby?

Hi all,

I'm starting a project that will involve injecting instructions into
x86 assembly code. I'd like to write this tool in Ruby. In the
interest of not reinventing wheels, I'm appealing to the Ruby
community: does anyone know of some serviceable source code for
parsing x86 assembly, and ideally for editing (e.g., ability to update
offsets when an instruction is moved around)? Or perhaps someone
knows of an assembler written in Ruby that I could pilfer? My Google-
fu hasn't turned up anything.

(I know of Racc - it will be my starting point if I can't find an
existing parser)

Many thanks =)

You may want to take a look at Metasploit, I think it does some of that.

-- Matt
It's not what I know that counts.
It's what I can remember in time to use.

···

On Sat, 16 Feb 2008, ljp wrote:

I'm starting a project that will involve injecting instructions into
x86 assembly code. I'd like to write this tool in Ruby. In the
interest of not reinventing wheels, I'm appealing to the Ruby
community: does anyone know of some serviceable source code for
parsing x86 assembly, and ideally for editing (e.g., ability to update
offsets when an instruction is moved around)? Or perhaps someone
knows of an assembler written in Ruby that I could pilfer? My Google-
fu hasn't turned up anything.

ljp wrote:

Hi all,

I'm starting a project that will involve injecting instructions into
x86 assembly code. I'd like to write this tool in Ruby. In the
interest of not reinventing wheels, I'm appealing to the Ruby
community: does anyone know of some serviceable source code for
parsing x86 assembly, and ideally for editing (e.g., ability to update
offsets when an instruction is moved around)? Or perhaps someone
knows of an assembler written in Ruby that I could pilfer? My Google-
fu hasn't turned up anything.

(I know of Racc - it will be my starting point if I can't find an
existing parser)

Many thanks =)

Have a look at RubyInline. It lets you put C code in line in Ruby code. I would imagine that "C code" on a Gnu/Linux system could include Gnu Assembler code as well. I can't help you on Windows, however. :wink:

···