2008-02-06 17:31:57 +00:00
|
|
|
#!/usr/bin/env ruby
|
2012-06-29 05:18:28 +00:00
|
|
|
# -*- coding: binary -*-
|
2008-02-06 17:31:57 +00:00
|
|
|
|
|
|
|
# $Id$
|
|
|
|
|
|
|
|
module Rex
|
|
|
|
module ElfScan
|
|
|
|
module Search
|
|
|
|
|
|
|
|
class DumpRVA
|
|
|
|
attr_accessor :elf
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
def initialize(elf)
|
|
|
|
self.elf = elf
|
|
|
|
end
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
def config(param)
|
|
|
|
@address = param['args']
|
|
|
|
end
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
def scan(param)
|
|
|
|
config(param)
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
$stdout.puts "[#{param['file']}]"
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
# Adjust based on -A and -B flags
|
|
|
|
pre = param['before'] || 0
|
|
|
|
suf = param['after'] || 16
|
2010-08-27 21:26:59 +00:00
|
|
|
|
2008-02-06 17:31:57 +00:00
|
|
|
@address -= pre
|
|
|
|
@address = 0 if (@address < 0 || ! @address)
|
|
|
|
buf = elf.read_rva(@address, suf)
|
|
|
|
$stdout.puts elf.ptr_s(@address) + " " + buf.unpack("H*")[0]
|
2010-08-27 21:26:59 +00:00
|
|
|
end
|
2008-02-06 17:31:57 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
class DumpOffset < DumpRVA
|
|
|
|
def config(param)
|
|
|
|
begin
|
|
|
|
@address = elf.offset_to_rva(param['args'])
|
|
|
|
rescue Rex::ElfParsey::BoundsError
|
|
|
|
end
|
|
|
|
end
|
2010-08-27 21:26:59 +00:00
|
|
|
end
|
|
|
|
end
|
2008-02-06 17:31:57 +00:00
|
|
|
end
|
|
|
|
end
|