2008-11-12 19:15:24 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Id$
|
|
|
|
#
|
2008-11-12 19:15:24 +00:00
|
|
|
# This script converts an EXE to a VBA script for Word/Excel
|
|
|
|
# Credit to PriestMaster for the original C code
|
|
|
|
#
|
2010-05-03 17:13:09 +00:00
|
|
|
# $Revision$
|
|
|
|
#
|
2008-11-12 19:15:24 +00:00
|
|
|
|
2012-02-04 06:38:21 +00:00
|
|
|
msfbase = __FILE__
|
|
|
|
while File.symlink?(msfbase)
|
|
|
|
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
|
|
|
|
end
|
|
|
|
|
|
|
|
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', 'lib')))
|
|
|
|
require 'fastlib'
|
|
|
|
|
|
|
|
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
|
2008-11-12 19:15:24 +00:00
|
|
|
|
|
|
|
require 'rex'
|
2009-06-24 20:02:29 +00:00
|
|
|
require 'msf/base'
|
2008-11-12 19:15:24 +00:00
|
|
|
|
|
|
|
def usage
|
|
|
|
$stderr.puts(" Usage: #{$0} [exe] [vba]\n")
|
|
|
|
exit
|
|
|
|
end
|
|
|
|
|
|
|
|
exe = ARGV.shift
|
|
|
|
vba = ARGV.shift
|
|
|
|
|
|
|
|
if (not (exe and vba))
|
|
|
|
usage
|
|
|
|
end
|
|
|
|
|
|
|
|
out = File.new(vba, "w")
|
|
|
|
inp = File.open(exe, "rb")
|
|
|
|
|
|
|
|
dat = ""
|
|
|
|
while(buf = inp.read(8192))
|
|
|
|
dat << buf
|
|
|
|
end
|
|
|
|
|
2009-06-24 03:59:54 +00:00
|
|
|
out.write(Msf::Util::EXE.to_exe_vba(dat))
|
2008-11-12 19:15:24 +00:00
|
|
|
out.close
|
|
|
|
inp.close
|
|
|
|
|
|
|
|
$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a VBA script"
|