Module: Rex::Post::LDAP::Ui::Console::CommandDispatcher
- Defined in:
- lib/rex/post/ldap/ui/console/command_dispatcher.rb
Overview
Base class for all command dispatchers within the LDAP console user interface.
Defined Under Namespace
Instance Attribute Summary
Attributes included from Ui::Text::DispatcherShell::CommandDispatcher
Instance Method Summary collapse
-
#client ⇒ Rex::Proto::LDAP::Client
Returns the LDAP client context.
-
#docs_dir ⇒ Object
Return the subdir of the ‘documentation/` directory that should be used to find usage documentation.
-
#filter_commands(all, reqs) ⇒ Object
Returns the commands that meet the requirements.
-
#initialize(console) ⇒ Object
Initializes an instance of the core command set using the supplied session and client for interactivity.
-
#log_error(msg) ⇒ Object
Log that an error occurred.
-
#msf_loaded? ⇒ Boolean
Returns true if the client has a framework object.
-
#session ⇒ Msf::Sessions::LDAP
Returns the LDAP session context.
- #unknown_command(cmd, line) ⇒ Object
Methods included from Msf::Ui::Console::CommandDispatcher::Session
#cmd_background, #cmd_background_help, #cmd_exit, #cmd_irb, #cmd_irb_help, #cmd_irb_tabs, #cmd_pry, #cmd_pry_help, #cmd_resource, #cmd_resource_help, #cmd_resource_tabs, #cmd_sessions, #cmd_sessions_help, #commands
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, included, #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 Method Details
#client ⇒ Rex::Proto::LDAP::Client
Returns the LDAP client context.
34 35 36 37 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 34 def client console = shell console.client end |
#docs_dir ⇒ Object
Return the subdir of the ‘documentation/` directory that should be used to find usage documentation
73 74 75 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 73 def docs_dir File.join(super, 'ldap_session') end |
#filter_commands(all, reqs) ⇒ Object
Returns the commands that meet the requirements
51 52 53 54 55 56 57 58 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 51 def filter_commands(all, reqs) all.delete_if do |cmd, _desc| if reqs[cmd]&.any? { |req| !client.commands.include?(req) } @filtered_commands << cmd true end end end |
#initialize(console) ⇒ Object
Initializes an instance of the core command set using the supplied session and client for interactivity.
24 25 26 27 28 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 24 def initialize(console) super @msf_loaded = nil @filtered_commands = [] end |
#log_error(msg) ⇒ Object
Log that an error occurred.
94 95 96 97 98 99 100 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 94 def log_error(msg) print_error(msg) elog(msg, 'ldap') dlog("Call stack:\n#{$ERROR_POSITION.join("\n")}", 'ldap') end |
#msf_loaded? ⇒ Boolean
Returns true if the client has a framework object.
Used for firing framework session events
82 83 84 85 86 87 88 89 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 82 def msf_loaded? return @msf_loaded unless @msf_loaded.nil? # if we get here we must not have initialized yet @msf_loaded = !session.framework.nil? @msf_loaded end |
#session ⇒ Msf::Sessions::LDAP
Returns the LDAP session context.
43 44 45 46 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 43 def session console = shell console.session end |
#unknown_command(cmd, line) ⇒ Object
60 61 62 63 64 65 66 67 |
# File 'lib/rex/post/ldap/ui/console/command_dispatcher.rb', line 60 def unknown_command(cmd, line) if @filtered_commands.include?(cmd) print_error("The \"#{cmd}\" command is not supported by this session type (#{session.session_type})") return :handled end super end |