Parent

Class/Module Index [+]

Quicksearch

Rex::Post::Meterpreter::Extensions::Stdapi::Railgun::WinConstManager

Manages our library of windows constants

Attributes

consts[R]

Public Class Methods

new(initial_consts = {}) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb, line 38
def initialize(initial_consts = {})
        @consts = {}

        initial_consts.each_pair do |name, value|
                add_const(name, value)
        end
end

Public Instance Methods

add_const(name, value) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb, line 46
def add_const(name, value)
        consts[name] = value
end
is_parseable(s) click to toggle source
# File lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb, line 69
def is_parseable(s)
        return !parse(s).nil?
end
parse(s) click to toggle source

parses a string constaining constants and returns an integer the string can be either "CONST" or "CONST1 | CONST2"

this function will NOT throw an exception but return "nil" if it can't parse a string

# File lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb, line 54
def parse(s)
        if s.class != String
                return nil # it's not even a string'
        end
        return_value = 0
        for one_const in s.split('|')
                one_const = one_const.strip()
                if not consts.has_key? one_const
                        return nil # at least one "Constant" is unknown to us
                end
                return_value |= consts[one_const]
        end
        return return_value
end
select_const_names(winconst, filter_regex=nil) click to toggle source

Returns an array of constant names that have a value matching "winconst" and (optionally) a name that matches "filter_regex"

# File lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb, line 77
def select_const_names(winconst, filter_regex=nil)
        matches = []

        consts.each_pair do |name, value|
                matches << name if value == winconst
        end
        
        # Filter matches by name if a filter has been provided
        unless filter_regex.nil?
                matches.reject! do |name|
                        name !~ filter_regex
                end
        end

        return matches
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.