Module: Rex::Post::Sql::Ui::Console::CommandDispatcher

Includes:
Msf::Ui::Console::CommandDispatcher::Session
Included in:
MSSQL::Ui::Console::CommandDispatcher, MySQL::Ui::Console::CommandDispatcher, PostgreSQL::Ui::Console::CommandDispatcher, Client, Core
Defined in:
lib/rex/post/sql/ui/console/command_dispatcher.rb,
lib/rex/post/sql/ui/console/command_dispatcher/core.rb,
lib/rex/post/sql/ui/console/command_dispatcher/client.rb

Overview

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

Defined Under Namespace

Modules: Client, Core

Instance Attribute Summary

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

#shell, #tab_complete_items

Instance Method Summary collapse

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, #docs_dir, #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

#clientObject

Returns the SQL client context.

Returns:

  • (Object)


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

def client
  console = shell
  console.client
end

#filter_commands(all, reqs) ⇒ Object

Returns the commands that meet the requirements



52
53
54
55
56
57
58
59
# File 'lib/rex/post/sql/ui/console/command_dispatcher.rb', line 52

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.

Parameters:



26
27
28
29
30
# File 'lib/rex/post/sql/ui/console/command_dispatcher.rb', line 26

def initialize(console)
  super
  @msf_loaded = nil
  @filtered_commands = []
end

#msf_loaded?Boolean

Returns true if the client has a framework object.

Used for firing framework session events

Returns:

  • (Boolean)


75
76
77
78
79
80
81
82
# File 'lib/rex/post/sql/ui/console/command_dispatcher.rb', line 75

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

#sessionMsf::Sessions::PostgreSQL

Returns the PostgreSQL session context.



44
45
46
47
# File 'lib/rex/post/sql/ui/console/command_dispatcher.rb', line 44

def session
  console = shell
  console.session
end

#unknown_command(cmd, line) ⇒ Object



61
62
63
64
65
66
67
68
# File 'lib/rex/post/sql/ui/console/command_dispatcher.rb', line 61

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