Files
metasploit-gs/tools/exploit/exe2vba.rb
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

53 lines
1.0 KiB
Ruby
Raw Normal View History

#!/usr/bin/env ruby
2018-03-20 11:33:34 +00:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
2010-05-03 17:13:09 +00:00
#
# This script converts an EXE to a VBA script for Word/Excel
# Credit to PriestMaster for the original C code
#
2021-03-22 15:47:41 +05:30
begin
msfbase = __FILE__
while File.symlink?(msfbase)
2013-09-30 13:47:53 -05:00
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
end
2015-10-06 10:30:52 -05:00
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
2012-04-15 23:35:38 -05:00
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'rex'
def usage
2013-09-30 13:47:53 -05:00
$stderr.puts(" Usage: #{$0} [exe] [vba]\n")
exit
end
exe = ARGV.shift
vba = ARGV.shift
if (not (exe and vba))
2013-09-30 13:47:53 -05:00
usage
end
out = File.new(vba, "w")
inp = File.open(exe, "rb")
dat = ""
while(buf = inp.read(8192))
2013-09-30 13:47:53 -05:00
dat << buf
end
2009-06-24 03:59:54 +00:00
out.write(Msf::Util::EXE.to_exe_vba(dat))
out.close
inp.close
$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a VBA script"
2021-03-22 15:47:41 +05:30
rescue SignalException => e
puts("Aborted! #{e}")
end