CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/tools/exploit/exe2vba.rb
Views: 11766
1
#!/usr/bin/env ruby
2
3
##
4
# This module requires Metasploit: https://metasploit.com/download
5
# Current source: https://github.com/rapid7/metasploit-framework
6
##
7
8
#
9
# This script converts an EXE to a VBA script for Word/Excel
10
# Credit to PriestMaster for the original C code
11
#
12
begin
13
msfbase = __FILE__
14
while File.symlink?(msfbase)
15
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
16
end
17
18
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
19
require 'msfenv'
20
21
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
22
23
require 'rex'
24
25
def usage
26
$stderr.puts(" Usage: #{$0} [exe] [vba]\n")
27
exit
28
end
29
30
exe = ARGV.shift
31
vba = ARGV.shift
32
33
if (not (exe and vba))
34
usage
35
end
36
37
out = File.new(vba, "w")
38
inp = File.open(exe, "rb")
39
40
dat = ""
41
while(buf = inp.read(8192))
42
dat << buf
43
end
44
45
out.write(Msf::Util::EXE.to_exe_vba(dat))
46
out.close
47
inp.close
48
49
$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a VBA script"
50
rescue SignalException => e
51
puts("Aborted! #{e}")
52
end
53
54