Path: blob/master/tools/exploit/exe2vba.rb
21517 views
#!/usr/bin/env ruby12##3# This module requires Metasploit: https://metasploit.com/download4# Current source: https://github.com/rapid7/metasploit-framework5##67#8# This script converts an EXE to a VBA script for Word/Excel9# Credit to PriestMaster for the original C code10#11begin12msfbase = __FILE__13while File.symlink?(msfbase)14msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))15end1617$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))18require 'msfenv'1920$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']2122require 'rex'2324def usage25$stderr.puts(" Usage: #{$0} [exe] [vba]\n")26exit27end2829exe = ARGV.shift30vba = ARGV.shift3132if (not (exe and vba))33usage34end3536out = File.new(vba, "w")37inp = File.open(exe, "rb")3839dat = ""40while(buf = inp.read(8192))41dat << buf42end4344out.write(Msf::Util::EXE.to_exe_vba(dat))45out.close46inp.close4748$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a VBA script"49rescue SignalException => e50puts("Aborted! #{e}")51end525354