Class: Rex::Post::MySQL::Ui::Console

Inherits:
Object
  • Object
show all
Includes:
Sql::Ui::Console, Ui::Text::DispatcherShell
Defined in:
lib/rex/post/mysql/ui/console.rb

Overview

This class provides a shell driven interface to the MySQL client API.

Defined Under Namespace

Modules: CommandDispatcher

Instance Attribute Summary collapse

Attributes included from Ui::Text::DispatcherShell

#blocked, #busy, #dispatcher_stack

Attributes included from Ui::Text::Shell

#cont_flag, #cont_prompt, #disable_output, #framework, #hist_last_saved, #histfile, #history_manager, #input, #local_hostname, #local_username, #log_source, #name, #on_command_proc, #on_print_proc, #output, #prompt, #prompt_char, #stop_count, #stop_flag, #tab_complete_proc

Instance Method Summary collapse

Methods included from Ui::Text::DispatcherShell

#append_dispatcher, #block_command, #blocked_command?, #current_dispatcher, #destack_dispatcher, #enstack_dispatcher, #help_to_s, #remove_dispatcher, #run_command, #run_single, #shellsplitex, #tab_complete, #tab_complete_helper, #tab_complete_stub, #unblock_command, #unknown_command

Methods included from Ui::Text::Shell

#_print_prompt, #format_prompt, #get_input_line, #init_tab_complete, #init_ui, #log_input, #log_output, #parse_line, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #prompt_yesno, #reset_ui, #run, #set_log_source, #stop, #stopped?, #supports_color?, #tab_complete, #unset_log_source, #update_prompt, #with_history_manager_context

Methods included from Ui::Text::Resource

#load_resource

Methods included from Sql::Ui::Console

#current_database, #format_prompt, #help_to_s, #interact, #interact_with_client, #interact_with_client_notification, #log_error, #queue_cmd, #run_command, #sql_prompt

Methods included from SessionCompatibleModules

#format_session_compatible_modules, #session_compatible_modules

Constructor Details

#initialize(session) ⇒ Console

Initialize the MySQL console.

Parameters:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rex/post/mysql/ui/console.rb', line 23

def initialize(session)
  # The mysql client context
  self.session = session
  self.client = session.client
  prompt = "%undMySQL @ #{client.peerinfo} (#{current_database})%clr"
  history_file = Msf::Config.history_file_for_session_type(session_type: session.type, interactive: false)
  super(prompt, '>', history_file, nil, :mysql)

  # Queued commands array
  self.commands = []

  # Point the input/output handles elsewhere
  reset_ui

  enstack_dispatcher(::Rex::Post::MySQL::Ui::Console::CommandDispatcher::Core)
  enstack_dispatcher(::Rex::Post::MySQL::Ui::Console::CommandDispatcher::Client)
  enstack_dispatcher(Msf::Ui::Console::CommandDispatcher::LocalFileSystem)

  # Set up logging to whatever logsink 'core' is using
  if ! $dispatcher['mysql']
    $dispatcher['mysql'] = $dispatcher['core']
  end
end

Instance Attribute Details

#clientMySQL::Client

Returns:

  • (MySQL::Client)


51
52
53
# File 'lib/rex/post/mysql/ui/console.rb', line 51

def client
  @client
end

#commandsObject (protected)

:nodoc:



56
57
58
# File 'lib/rex/post/mysql/ui/console.rb', line 56

def commands
  @commands
end

#sessionMsf::Sessions::MySQL



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

def session
  @session
end