Path: blob/master/tools/exploit/exe2vbs.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 vbs script9#10begin11msfbase = __FILE__12while File.symlink?(msfbase)13msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))14end1516$:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))17require 'msfenv'1819$:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']2021require 'rex'2223def usage24$stderr.puts(" Usage: #{$0} [exe] [vbs]\n")25exit26end2728exe = ARGV.shift29vbs = ARGV.shift3031if (not (exe and vbs))32usage33end3435out = File.new(vbs, "w")36inp = File.open(exe, "rb")3738dat = ""39while(buf = inp.read(8192))40dat << buf41end4243out.write(Msf::Util::EXE.to_exe_vbs(dat))44out.close45inp.close4647$stderr.puts "[*] Converted #{dat.length} bytes of EXE into a vbs script"48rescue SignalException => e49puts("Aborted! #{e}")50end515253