exe2vbs.rb 961 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #!/usr/bin/env ruby
  2. ##
  3. # This module requires Metasploit: https://metasploit.com/download
  4. # Current source: https://github.com/rapid7/metasploit-framework
  5. ##
  6. #
  7. # This script converts an EXE to a vbs script
  8. #
  9. begin
  10. msfbase = __FILE__
  11. while File.symlink?(msfbase)
  12. msfbase = File.expand_path(File.readlink(msfbase), File.dirname(msfbase))
  13. end
  14. $:.unshift(File.expand_path(File.join(File.dirname(msfbase), '..', '..', 'lib')))
  15. require 'msfenv'
  16. $:.unshift(ENV['MSF_LOCAL_LIB']) if ENV['MSF_LOCAL_LIB']
  17. require 'rex'
  18. def usage
  19. $stderr.puts(" Usage: #{$0} [exe] [vbs]\n")
  20. exit
  21. end
  22. exe = ARGV.shift
  23. vbs = ARGV.shift
  24. if (not (exe and vbs))
  25. usage
  26. end
  27. out = File.new(vbs, "w")
  28. inp = File.open(exe, "rb")
  29. dat = ""
  30. while(buf = inp.read(8192))
  31. dat << buf
  32. end
  33. out.write(Msf::Util::EXE.to_exe_vbs(dat))
  34. out.close
  35. inp.close
  36. $stderr.puts "[*] Converted #{dat.length} bytes of EXE into a vbs script"
  37. rescue SignalException => e
  38. puts("Aborted! #{e}")
  39. end