Class: OneGadget::Emulators::I386

Inherits:
X86 show all
Defined in:
lib/one_gadget/emulators/i386.rb

Overview

Emulator of amd64 instruction set.

Instance Attribute Summary

Attributes inherited from Processor

#pc, #registers, #sp, #stack

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from X86

#instructions, #process!

Methods inherited from Processor

#constraints, #instructions, #parse, #process, #process!

Constructor Details

#initializeI386

Instantiate an OneGadget::Emulators::I386 object.


16
17
18
# File 'lib/one_gadget/emulators/i386.rb', line 16

def initialize
  super(OneGadget::ABI.i386, 'esp', 'eip')
end

Class Method Details

.bitsObject

Yap, bits.


10
11
12
# File 'lib/one_gadget/emulators/i386.rb', line 10

def bits
  32
end

Instance Method Details

#argument(idx) ⇒ Lambda, Integer

Get function call arguments.

For i386 this is a little bit tricky. We need to fetch the stack slots reference to current 'esp' but not original 'esp'. So we need to evaluate the offset of current esp first.

Parameters:

  • idx (Integer)

Returns:


28
29
30
31
# File 'lib/one_gadget/emulators/i386.rb', line 28

def argument(idx)
  cur_top = registers['esp'].evaluate('esp' => 0)
  stack[cur_top + idx * 4]
end