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 X86

#bp, #bp_based_stack

Attributes inherited from Processor

#pc, #registers, #sp, #sp_based_stack

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from X86

#get_corresponding_stack, #instructions, #process!

Methods inherited from Processor

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

Constructor Details

#initializeI386

Instantiate an OneGadget::Emulators::I386 object.



18
19
20
# File 'lib/one_gadget/emulators/i386.rb', line 18

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

Class Method Details

.bitsObject

Yap, bits.



12
13
14
# File 'lib/one_gadget/emulators/i386.rb', line 12

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.



30
31
32
33
# File 'lib/one_gadget/emulators/i386.rb', line 30

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