forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexe2vba.rb
executable file
·49 lines (38 loc) · 874 Bytes
/
exe2vba.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby
#
# $Id$
#
# This script converts an EXE to a VBA script for Word/Excel
# Credit to PriestMaster for the original C code
#
# $Revision$
#
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'
require 'msfenv'
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
require 'rex'
require 'msf/base'
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
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"