lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb in librex-0.0.68 vs lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb in librex-0.0.70

- old
+ new

@@ -32,65 +32,65 @@ # # Manages our library of windows constants # class WinConstManager - attr_reader :consts + attr_reader :consts - def initialize(initial_consts = {}) - @consts = {} + def initialize(initial_consts = {}) + @consts = {} - initial_consts.each_pair do |name, value| - add_const(name, value) - end - end + initial_consts.each_pair do |name, value| + add_const(name, value) + end + end - def add_const(name, value) - consts[name] = value - end + def add_const(name, value) + consts[name] = value + end - # 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 - 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 + # 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 + 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 - def is_parseable(s) - return !parse(s).nil? - end + def is_parseable(s) + return !parse(s).nil? + end - # - # Returns an array of constant names that have a value matching "winconst" - # and (optionally) a name that matches "filter_regex" - # - def select_const_names(winconst, filter_regex=nil) - matches = [] + # + # Returns an array of constant names that have a value matching "winconst" + # and (optionally) a name that matches "filter_regex" + # + 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 + consts.each_pair do |name, value| + matches << name if value == winconst + end - return matches - 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 end end; end; end; end; end; end