Add disasm option to msfelfscan

bug/bundler_fix
Ramon de C Valle 2013-12-26 16:26:45 -02:00
parent c59b8fd7bc
commit c1f377fda6
2 changed files with 25 additions and 1 deletions

View File

@ -1,4 +1,5 @@
# -*- coding: binary -*- # -*- coding: binary -*-
require 'metasm'
module Rex module Rex
module ElfScan module ElfScan
@ -27,6 +28,26 @@ class Generic
rva = hit[0] rva = hit[0]
message = hit[1].is_a?(Array) ? hit[1].join(" ") : hit[1] message = hit[1].is_a?(Array) ? hit[1].join(" ") : hit[1]
$stdout.puts elf.ptr_s(rva) + " " + message $stdout.puts elf.ptr_s(rva) + " " + message
if(param['disasm'])
message.gsub!("; ", "\n")
if message.include?("retn")
message.gsub!("retn", "ret")
end
begin
d2 = Metasm::Shellcode.assemble(Metasm::Ia32.new, message).disassemble
rescue Metasm::ParseError
d2 = Metasm::Shellcode.disassemble(Metasm::Ia32.new, [message].pack('H*'))
end
addr = 0
while ((di = d2.disassemble_instruction(addr)))
disasm = "0x%08x\t" % (rva + addr)
disasm << di.instruction.to_s
$stdout.puts disasm
addr = di.next_addr
end
end
end end
end end
@ -203,4 +224,3 @@ end
end end
end end
end end

View File

@ -82,6 +82,10 @@ opt.on('-B', '--before [bytes]', 'Number of bytes to show before match (-a/-b)')
param['before'] = opt2i(t) param['before'] = opt2i(t)
end end
opt.on('-D', '--disasm', 'Disassemble the bytes at this address') do |t|
param['disasm'] = true
end
opt.on('-I', '--image-base [address]', 'Specify an alternate ImageBase') do |t| opt.on('-I', '--image-base [address]', 'Specify an alternate ImageBase') do |t|
param['imagebase'] = opt2i(t) param['imagebase'] = opt2i(t)
end end