Sha256: 66ead5e58a900951ec634c51e2d8afd9d3fe837b3a1af6e804e69acd0e7a07c3

Contents?: true

Size: 1.27 KB

Versions: 21

Compression:

Stored size: 1.27 KB

Contents

module Rex
module PeScan
module Search

	require "rex/assembly/nasm"
	
	class DumpRVA
		attr_accessor :pe
		
		def initialize(pe)
			self.pe = pe
		end
		
		def config(param)
			@address = pe.vma_to_rva(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)
			
			begin
				buf = pe.read_rva(@address, suf)
			rescue ::Rex::PeParsey::WtfError
				return
			end
			
			$stdout.puts pe.ptr_s(pe.rva_to_vma(@address)) + " " + buf.unpack("H*")[0]
			if(param['disasm'])
				insns = []
				buf.gsub!("; ", "\n")
				if buf.include?("retn")
					buf.gsub!("retn", "ret")
				end
				d2 = Metasm::Shellcode.disassemble(Metasm::Ia32.new, buf)
				addr = 0
				while ((di = d2.disassemble_instruction(addr)))
					insns << di.instruction
					disasm = "0x%08x\t" % (pe.rva_to_vma(@address) + addr)
					disasm << di.instruction.to_s
					$stdout.puts disasm
					addr = di.next_addr
				end
			end
			
		end	
	end

	class DumpOffset < DumpRVA
		def config(param)
			begin
				@address = pe.file_offset_to_rva(param['args'])
			rescue Rex::PeParsey::BoundsError
			end
		end
	end	
end
end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
librex-0.0.65 lib/rex/pescan/search.rb
librex-0.0.63 lib/rex/pescan/search.rb
librex-0.0.54 lib/rex/pescan/search.rb
librex-0.0.53 lib/rex/pescan/search.rb
librex-0.0.52 lib/rex/pescan/search.rb
librex-0.0.51 lib/rex/pescan/search.rb
librex-0.0.50 lib/rex/pescan/search.rb
librex-0.0.49 lib/rex/pescan/search.rb
librex-0.0.48 lib/rex/pescan/search.rb
librex-0.0.47 lib/rex/pescan/search.rb
librex-0.0.46 lib/rex/pescan/search.rb
librex-0.0.44 lib/rex/pescan/search.rb
librex-0.0.43 lib/rex/pescan/search.rb
librex-0.0.42 lib/rex/pescan/search.rb
librex-0.0.41 lib/rex/pescan/search.rb
librex-0.0.40 lib/rex/pescan/search.rb
librex-0.0.39 lib/rex/pescan/search.rb
librex-0.0.38 lib/rex/pescan/search.rb
librex-0.0.37 lib/rex/pescan/search.rb
librex-0.0.36 lib/rex/pescan/search.rb