Module: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher

Overview

Base class for all command dispatchers within the meterpreter console user interface.

Defined Under Namespace

Classes: Android, Core, Espia, Extapi, Incognito, Kiwi, Lanattacks, Mimikatz, NetworkPug, Priv, Sniffer, Stdapi

Constant Summary collapse

@@file_hash =

The hash of file names to class names after a module has already been loaded once on the client side.

{}

Instance Attribute Summary

Attributes included from Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #commands, #deprecated_cmd, #deprecated_commands, #deprecated_help, #help_to_s, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_filenames, #update_prompt

Class Method Details

.check_hash(name) ⇒ Object

Checks the file name to hash association to see if the module being requested has already been loaded once.



29
30
31
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 29

def self.check_hash(name)
  @@file_hash[name]
end

.set_hash(name, klass) ⇒ Object

Sets the file path to class name association for future reference.



36
37
38
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 36

def self.set_hash(name, klass)
  @@file_hash[name] = klass
end

Instance Method Details

#clientObject

Returns the meterpreter client context.



48
49
50
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 48

def client
  shell.client
end

#initialize(shell) ⇒ Object



40
41
42
43
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 40

def initialize(shell)
  @msf_loaded = nil
  super
end

#log_error(msg) ⇒ Object

Log that an error occurred.



73
74
75
76
77
78
79
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 73

def log_error(msg)
  print_error(msg)

  elog(msg, 'meterpreter')

  dlog("Call stack:\n#{$@.join("\n")}", 'meterpreter')
end

#msf_loaded?Boolean

Returns true if the client has a framework object.

Used for firing framework session events

Returns:

  • (Boolean)


57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher.rb', line 57

def msf_loaded?
  return @msf_loaded unless @msf_loaded.nil?
  # if we get here we must not have initialized yet

  if client.framework
    # We have a framework instance so the msf libraries should be
    # available.  Load up the ones we're going to use
    require 'msf/base/serializer/readable_text'
  end
  @msf_loaded = !!(client.framework)
  @msf_loaded
end