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

Inherits:
Object
  • Object
show all
Defined in:
lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb

Overview

Manages our library of windows constants

Defined Under Namespace

Classes: UnitTest

Instance Method Summary collapse

Constructor Details

#initialize(initial_consts = {}) ⇒ WinConstManager

Returns a new instance of WinConstManager.



37
38
39
40
41
42
43
44
45
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb', line 37

def initialize(initial_consts = {})
	@consts = {}

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

	# Load utility 
end

Instance Method Details

#add_const(name, value) ⇒ Object



47
48
49
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb', line 47

def add_const(name, value)
	@consts[name] = value
end

#is_parseable(s) ⇒ Object



70
71
72
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb', line 70

def is_parseable(s)
	return parse(s) != nil
end

#parse(s) ⇒ Object

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



55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rex/post/meterpreter/extensions/stdapi/railgun/win_const_manager.rb', line 55

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