Module: Rex::Exploitation::Powershell

Defined in:
lib/rex/exploitation/powershell.rb,
lib/rex/exploitation/powershell/obfu.rb,
lib/rex/exploitation/powershell/param.rb,
lib/rex/exploitation/powershell/output.rb,
lib/rex/exploitation/powershell/parser.rb,
lib/rex/exploitation/powershell/script.rb,
lib/rex/exploitation/powershell/function.rb,
lib/rex/exploitation/powershell/psh_methods.rb

Defined Under Namespace

Modules: Obfu, Output, Parser, PshMethods Classes: Function, Param, Script

Class Method Summary collapse

Class Method Details

.make_subs(script, subs) ⇒ String

Insert substitutions into the powershell script If script is a path to a file then read the file otherwise treat it as the contents of a file

Parameters:

  • script (String)

    Script file or path to script

  • subs (Array)

    Substitutions to insert

Returns:

  • (String)

    Modified script file



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/rex/exploitation/powershell.rb', line 33

def self.make_subs(script, subs)
  if ::File.file?(script)
    script = ::File.read(script)
  end

  subs.each do |set|
    script.gsub!(set[0], set[1])
  end

  script
end

.process_subs(subs) ⇒ Array

Return an array of substitutions for use in make_subs

Parameters:

  • subs (String)

    A ; seperated list of substitutions

Returns:

  • (Array)

    An array of substitutions



51
52
53
54
55
56
57
58
59
# File 'lib/rex/exploitation/powershell.rb', line 51

def self.process_subs(subs)
  return [] if subs.nil? or subs.empty?
  new_subs = []
  subs.split(';').each do |set|
    new_subs << set.split(',', 2)
  end

  new_subs
end

.read_script(script_path) ⇒ Script

Reads script into a PowershellScript

Parameters:

  • script_path (String)

    Path to the Script File

Returns:

  • (Script)

    Powershell Script object



20
21
22
# File 'lib/rex/exploitation/powershell.rb', line 20

def self.read_script(script_path)
  Rex::Exploitation::Powershell::Script.new(script_path)
end