Method: Rex::Exploitation::Powershell::Script#initialize

Defined in:
lib/rex/exploitation/powershell/script.rb

#initialize(code) ⇒ Script

Returns a new instance of Script.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rex/exploitation/powershell/script.rb', line 35

def initialize(code)
  @code = ''
  @rig = Rex::RandomIdentifierGenerator.new

  begin
    # Open code file for reading
    fd = ::File.new(code, 'rb')
    while (line = fd.gets)
      @code << line
    end

    # Close open file
    fd.close
  rescue Errno::ENAMETOOLONG, Errno::ENOENT
    # Treat code as a... code
    @code = code.to_s.dup # in case we're eating another script
  end
  @functions = get_func_names.map { |f| get_func(f) }
end