Module: Rex::Post::Meterpreter::ObjectAliasesContainer

Included in:
Extensions::Stdapi::Sys::Process, Extensions::Stdapi::Sys::Thread, Extensions::Stdapi::UI, ObjectAliases
Defined in:
lib/rex/post/meterpreter/object_aliases.rb

Overview

Mixin for classes that wish to have object aliases but do not really need to inherit from the ObjectAliases class.

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(symbol, *args) ⇒ Object

Pass-thru aliases.



25
26
27
# File 'lib/rex/post/meterpreter/object_aliases.rb', line 25

def method_missing(symbol, *args)
  self.aliases[symbol.to_s]
end

Instance Attribute Details

#aliasesObject

The hash of aliases.



58
59
60
# File 'lib/rex/post/meterpreter/object_aliases.rb', line 58

def aliases
  @aliases
end

Instance Method Details

#dump_alias_tree(parent_path, current = nil) ⇒ Object

Recursively dumps all of the aliases registered with a class that is kind_of? ObjectAliases.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rex/post/meterpreter/object_aliases.rb', line 33

def dump_alias_tree(parent_path, current = nil)
  items = []

  if (current == nil)
    current = self
  end

  # If the current object may have object aliases...
  if (current.kind_of?(Rex::Post::Meterpreter::ObjectAliases))
    current.aliases.each_key { |x|
      current_path = parent_path + '.' + x

      items << current_path

      items.concat(dump_alias_tree(current_path,
        current.aliases[x]))
    }
  end

  return items
end

#initialize_aliases(aliases = {}) ⇒ Object

Initialize the instance’s aliases.



18
19
20
# File 'lib/rex/post/meterpreter/object_aliases.rb', line 18

def initialize_aliases(aliases = {})
  self.aliases = aliases
end