Files
metasploit-gs/lib/metasm/samples/dasm_pe.rb
T
HD Moore 4a204efaa1 Import the new METASM code
git-svn-id: file:///home/svn/framework3/trunk@5008 4d416f70-5f16-0410-b530-b9f4589650da
2007-06-30 21:53:26 +00:00

25 lines
630 B
Ruby

#!/usr/bin/env ruby
# This file is part of Metasm, the Ruby assembly manipulation suite
# Copyright (C) 2007 Yoann GUILLOT
#
# Licence is LGPL, see LICENCE in the top-level directory
#
# in this exemple we decode a PE file, and disassemble its instructions from
# its entrypoint. We then dump the whole thing to standard out.
#
require 'metasm'
raise 'usage: script <pe filename>' if not filename = ARGV.shift
# load and decode the file
pe = Metasm::PE.decode_file filename, Metasm::Ia32.new
# disassemble instructions
pe.disassemble pe.optheader.entrypoint + pe.optheader.image_base
# dump
puts pe.blocks_to_src