Class: Rex::Poly::MachineX86
- Defined in:
- lib/rex/poly/machine/x86.rb
Overview
A subclass to represent a Rex poly machine on the x86 architecture.
Constant Summary
Constants inherited from Machine
Rex::Poly::Machine::BYTE, Rex::Poly::Machine::DWORD, Rex::Poly::Machine::QWORD, Rex::Poly::Machine::WORD
Instance Method Summary collapse
-
#create_block_primitive(block_name, primitive_name, *args) ⇒ Object
Overload this method to intercept the ‘set’ primitive with the ‘location’ keyword and create the block with the ‘_set_variable_location’.
-
#initialize(badchars = '', consume_base_pointer = nil, consume_stack_pointer = true) ⇒ MachineX86
constructor
A new instance of MachineX86.
-
#native_size ⇒ Object
The general purpose registers are 32bit.
Methods inherited from Machine
#assemble, #block_exist?, #block_next, #block_offset, #block_previous, #create_block, #create_variable, #generate, #is_valid?, #make_safe_byte, #make_safe_dword, #make_safe_qword, #make_safe_word, #release_temp_variable, #resolve_value, #solution_is_valid?, #solution_pop, #solution_push, #variable_exist?, #variable_value
Constructor Details
#initialize(badchars = '', consume_base_pointer = nil, consume_stack_pointer = true) ⇒ MachineX86
Returns a new instance of MachineX86.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rex/poly/machine/x86.rb', line 12 def initialize( badchars='', consume_base_pointer=nil, consume_stack_pointer=true ) super( badchars, Metasm::Ia32.new ) @reg_available << Rex::Arch::X86::EAX @reg_available << Rex::Arch::X86::EBX @reg_available << Rex::Arch::X86::ECX @reg_available << Rex::Arch::X86::EDX @reg_available << Rex::Arch::X86::ESI @reg_available << Rex::Arch::X86::EDI @reg_available << Rex::Arch::X86::EBP @reg_available << Rex::Arch::X86::ESP # By default we consume the EBP register if badchars contains \x00. This helps speed # things up greatly as many instructions opperating on EBP introduce a NULL byte. For # example, a MOV instruction with EAX as the source operand is as follows: # 8B08 mov ecx, [eax] # but the same instruction with EBP as the source operand is as follows: # 8B4D00 mov ecx, [ebp] ; This is assembled as 'mov ecx, [ebp+0]' # we can see that EBP is encoded differently with an offset included. We can still # try to generate a solution with EBP included and \x00 in the badchars list but # it can take considerably longer. if( ( consume_base_pointer.nil? and not Rex::Text.badchar_index( "\x00", @badchars ).nil? ) or consume_base_pointer == true ) create_variable( 'base_pointer', 'ebp' ) end # By default we consume the ESP register to avoid munging the stack. if( consume_stack_pointer ) create_variable( 'stack_pointer', 'esp' ) end # discover all the safe FPU instruction we can use. @safe_fpu_instructions = ::Array.new Rex::Arch::X86.fpu_instructions.each do | fpu | if( is_valid?( fpu ) ) @safe_fpu_instructions << fpu end end end |
Instance Method Details
#create_block_primitive(block_name, primitive_name, *args) ⇒ Object
Overload this method to intercept the ‘set’ primitive with the ‘location’ keyword and create the block with the ‘_set_variable_location’. We do this to keep a consistent style.
63 64 65 66 67 68 69 |
# File 'lib/rex/poly/machine/x86.rb', line 63 def create_block_primitive( block_name, primitive_name, *args ) if( primitive_name == 'set' and args.length == 2 and args[1] == 'location' ) _create_block_primitive( block_name, '_set_variable_location', args[0] ) else super end end |