Module: Msf::Ui::Console::CommandDispatcher
- Included in:
- Plugin::Aggregator::AggregatorCommandDispatcher, Plugin::Alias::AliasCommandDispatcher, Plugin::Beholder::BeholderCommandDispatcher, Plugin::CredCollect::CredCollectCommandDispatcher, Plugin::FFAutoRegen::FFAutoRegenCommandDispatcher, Plugin::Lab::LabCommandDispatcher, Plugin::Nessus::ConsoleCommandDispatcher, Plugin::Nexpose::NexposeCommandDispatcher, Plugin::OpenVAS::OpenVASCommandDispatcher, Plugin::PcapLog::PcapLogDispatcher, Plugin::Requests::ConsoleCommandDispatcher, Plugin::Sample::ConsoleCommandDispatcher, Plugin::SessionNotifier::SessionNotifierCommandDispatcher, Plugin::Sqlmap::SqlmapCommandDispatcher, Plugin::ThreadTest::ConsoleCommandDispatcher, Plugin::TokenAdduser::TokenCommandDispatcher, Plugin::TokenHunter::TokenCommandDispatcher, Plugin::Wiki::WikiCommandDispatcher, Plugin::Wmap::WmapCommandDispatcher, Core, Creds, Db, Developer, Jobs, Modules, Resource, ModuleCommandDispatcher
- Defined in:
- lib/msf/ui/console/command_dispatcher.rb,
lib/msf/ui/console/command_dispatcher/db.rb,
lib/msf/ui/console/command_dispatcher/nop.rb,
lib/msf/ui/console/command_dispatcher/core.rb,
lib/msf/ui/console/command_dispatcher/jobs.rb,
lib/msf/ui/console/command_dispatcher/post.rb,
lib/msf/ui/console/command_dispatcher/creds.rb,
lib/msf/ui/console/command_dispatcher/common.rb,
lib/msf/ui/console/command_dispatcher/encoder.rb,
lib/msf/ui/console/command_dispatcher/evasion.rb,
lib/msf/ui/console/command_dispatcher/exploit.rb,
lib/msf/ui/console/command_dispatcher/modules.rb,
lib/msf/ui/console/command_dispatcher/payload.rb,
lib/msf/ui/console/command_dispatcher/resource.rb,
lib/msf/ui/console/command_dispatcher/auxiliary.rb
Overview
The common command dispatcher base class that is shared for component-specific command dispatching.
Defined Under Namespace
Modules: Analyze, Common Classes: Auxiliary, Core, Creds, Db, Developer, Encoder, Evasion, Exploit, Jobs, Modules, Nop, Payload, Post, Resource
Instance Attribute Summary collapse
-
#driver ⇒ Object
The driver that this command dispatcher is associated with.
Attributes included from Rex::Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#active_module ⇒ Object
Returns the active module if one has been selected, otherwise nil is returned.
-
#active_module=(mod) ⇒ Object
Sets the active module for this driver instance.
-
#active_session ⇒ Object
Returns the active session if one has been selected, otherwise nil is returned.
-
#active_session=(mod) ⇒ Object
Sets the active session for this driver instance.
-
#build_range_array(id_list) ⇒ Array<String>
Generate an array of job or session IDs from a given range String.
-
#docs_dir ⇒ Object
Return the subdir of the `documentation/` directory that should be used to find usage documentation.
-
#framework ⇒ Object
Returns the framework instance associated with this command dispatcher.
-
#initialize(driver) ⇒ Object
Initializes a command dispatcher instance.
-
#log_error(err) ⇒ Object
Logs an error message to the screen and the log file.
-
#remove_lines(text, to_match) ⇒ String
Remove lines with specific substring.
Methods included from Rex::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_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #update_prompt
Instance Attribute Details
#driver ⇒ Object
The driver that this command dispatcher is associated with.
132 133 134 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 132 def driver @driver end |
Instance Method Details
#active_module ⇒ Object
Returns the active module if one has been selected, otherwise nil is returned.
38 39 40 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 38 def active_module driver.active_module end |
#active_module=(mod) ⇒ Object
Sets the active module for this driver instance.
45 46 47 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 45 def active_module=(mod) driver.active_module = mod end |
#active_session ⇒ Object
Returns the active session if one has been selected, otherwise nil is returned.
53 54 55 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 53 def active_session driver.active_session end |
#active_session=(mod) ⇒ Object
Sets the active session for this driver instance.
60 61 62 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 60 def active_session=(mod) driver.active_session = mod end |
#build_range_array(id_list) ⇒ Array<String>
Generate an array of job or session IDs from a given range String. Always returns an Array.
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 91 def build_range_array(id_list) item_list = [] unless id_list.blank? temp_list = id_list.split(',') temp_list.each do |ele| return if ele.count('-') > 1 return if ele.first == '-' || ele[-1] == '-' return if ele.first == '.' || ele[-1] == '.' return unless ele =~ (/^\d+((\.\.|-)\d+)?$/) # Not a number or range if ele.include? '-' temp_array = (ele.split("-").inject { |s, e| s.to_i..e.to_i }).to_a item_list.concat(temp_array) elsif ele.include? '..' temp_array = (ele.split("..").inject { |s, e| s.to_i..e.to_i }).to_a item_list.concat(temp_array) else item_list.push(ele.to_i) end end end item_list.uniq.sort end |
#docs_dir ⇒ Object
Return the subdir of the `documentation/` directory that should be used to find usage documentation
81 82 83 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 81 def docs_dir File.join(super, 'msfconsole') end |
#framework ⇒ Object
Returns the framework instance associated with this command dispatcher.
30 31 32 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 30 def framework return driver.framework end |
#initialize(driver) ⇒ Object
Initializes a command dispatcher instance.
20 21 22 23 24 25 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 20 def initialize(driver) super self.driver = driver self.driver.on_command_proc = Proc.new { |command| framework.events.on_ui_command(command) } end |
#log_error(err) ⇒ Object
Logs an error message to the screen and the log file. The callstack is also printed.
68 69 70 71 72 73 74 75 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 68 def log_error(err) print_error(err) wlog(err) # If it's a syntax error, log the call stack that it originated from. dlog("Call stack:\n#{[email protected].join("\n")}", 'core', LEV_1) end |
#remove_lines(text, to_match) ⇒ String
Remove lines with specific substring
124 125 126 127 |
# File 'lib/msf/ui/console/command_dispatcher.rb', line 124 def remove_lines(text, to_match) to_match = Regexp.escape(to_match) text.gsub(/^.*(#{to_match}).*(#{Regexp.escape $/})?/, '') end |