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/exe2vbs.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 vbs script
10
#
11
begin
12
msfbase = __FILE__
13
while File.symlink?(msfbase)
14
msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
15
end
16
17
$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
18
require 'msfenv'
19
20
$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
21
22
require 'rex'
23
24
def usage
25
$stderr.puts(" Usage: #{$0} [exe] [vbs]\n")
26
exit
27
end
28
29
exe = ARGV.shift
30
vbs = ARGV.shift
31
32
if (not (exe and vbs))
33
usage
34
end
35
36
out = File.new(vbs, "w")
37
inp = File.open(exe, "rb")
38
39
dat = ""
40
while(buf = inp.read(8192))
41
dat << buf
42
end
43
44
out.write(Msf::Util::EXE.to_exe_vbs(dat))
45
out.close
46
inp.close
47
48
$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a vbs script"
49
rescue SignalException => e
50
puts("Aborted! #{e}")
51
end
52
53