1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-11-12 11:52:01 +01:00
metasploit-framework/lib/rex/elfscan/search.rb
Joshua Drake 6d333eb185 style compliance fixes
git-svn-id: file:///home/svn/framework3/trunk@10173 4d416f70-5f16-0410-b530-b9f4589650da
2010-08-27 21:26:59 +00:00

47 lines
735 B
Ruby

#!/usr/bin/env ruby
# $Id$
module Rex
module ElfScan
module Search
class DumpRVA
attr_accessor :elf
def initialize(elf)
self.elf = elf
end
def config(param)
@address = param['args']
end
def scan(param)
config(param)
$stdout.puts "[#{param['file']}]"
# Adjust based on -A and -B flags
pre = param['before'] || 0
suf = param['after'] || 16
@address -= pre
@address = 0 if (@address < 0 || ! @address)
buf = elf.read_rva(@address, suf)
$stdout.puts elf.ptr_s(@address) + " " + buf.unpack("H*")[0]
end
end
class DumpOffset < DumpRVA
def config(param)
begin
@address = elf.offset_to_rva(param['args'])
rescue Rex::ElfParsey::BoundsError
end
end
end
end
end
end