class Rex::Exploitation::Powershell::Function
Constants
- FUNCTION_REGEX
- PARAMETER_REGEX
Attributes
code[RW]
name[RW]
params[RW]
Public Class Methods
new(name, code)
click to toggle source
# File lib/rex/exploitation/powershell/function.rb, line 14 def initialize(name, code) @name = name @code = code populate_params end
Public Instance Methods
populate_params()
click to toggle source
Identify the parameters from the code and store as Param
in @params
# File lib/rex/exploitation/powershell/function.rb, line 32 def populate_params @params = [] start = code.index(PARAMETER_REGEX) return unless start # Get start of our block idx = scan_with_index('(', code[start..-1]).first.last + start pclause = block_extract(idx) matches = pclause.scan(FUNCTION_REGEX) # Ignore assignment, create params with class and variable names matches.each do |param| klass = nil name = nil param.each do |value| if value if klass name = value @params << Param.new(klass, name) break else klass = value end end end end end
to_s()
click to toggle source
To String
@return [String] Powershell
function
# File lib/rex/exploitation/powershell/function.rb, line 24 def to_s "function #{name} #{code}" end