Method: Rex::Exploitation::CmdStagerVBS#generate_cmds_decoder

Defined in:
lib/rex/exploitation/cmdstager/vbs.rb

#generate_cmds_decoder(opts) ⇒ Object

Generate the commands that will decode the file we just created



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/rex/exploitation/cmdstager/vbs.rb', line 81

def generate_cmds_decoder(opts)

  # Allow decoder stub override (needs to input base64 and output bin)
  @decoder = opts[:decoder] if (opts[:decoder])

  # Read the decoder data file
  f = File.new(@decoder, "rb")
  decoder = f.read(f.stat.size)
  f.close

  # Replace variables
  decoder.gsub!(/decode_stub/, "#{@tempdir}#{@var_decoder}.vbs")
  decoder.gsub!(/ENCODED/, "#{@tempdir}#{@var_encoded}.b64")
  decoder.gsub!(/DECODED/, "#{@tempdir}#{@var_decoded}.exe")

  # Split it apart by the lines
  decoder.split("\n")
end