Class: Rex::Post::MySQL::Ui::Console::CommandDispatcher::Client

Inherits:
Object
  • Object
show all
Includes:
Rex::Post::MySQL::Ui::Console::CommandDispatcher, Sql::Ui::Console::CommandDispatcher::Client
Defined in:
lib/rex/post/mysql/ui/console/command_dispatcher/client.rb

Overview

Core MySQL client commands

Instance Attribute Summary

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

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from Rex::Post::MySQL::Ui::Console::CommandDispatcher

#docs_dir

Methods included from Sql::Ui::Console::CommandDispatcher

#client, #filter_commands, #initialize, #msf_loaded?, #session, #unknown_command

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, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt

Methods included from Sql::Ui::Console::CommandDispatcher::Client

#cmd_query, #cmd_query_interactive, #cmd_query_interactive_help, #commands, #format_result, #help_args?, #initialize, #process_query, #query_interactive_help, #run_query

Instance Method Details

#cmd_query_helpObject

Returns:

  • (Object)


21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/rex/post/mysql/ui/console/command_dispatcher/client.rb', line 21

def cmd_query_help
  print_line 'Usage: query'
  print_line
  print_line 'Run a single SQL query on the target.'
  print_line @@query_opts.usage
  print_line 'Examples:'
  print_line
  print_line '    query SHOW DATABASES;'
  print_line '    query USE information_schema;'
  print_line '    query SELECT * FROM SQL_FUNCTIONS;'
  print_line '    query SELECT version();'
  print_line
end

#handle_error(e) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/rex/post/mysql/ui/console/command_dispatcher/client.rb', line 43

def handle_error(e)
  case e
  when Mysql::ClientError::ServerLost
    _close_session
  end
  super
end

#nameString

Returns:

  • (String)


16
17
18
# File 'lib/rex/post/mysql/ui/console/command_dispatcher/client.rb', line 16

def name
  'MySQL Client'
end

#normalise_sql_result(result) ⇒ Hash

Returns Hash containing rows, columns and errors.

Parameters:

  • result (Mysql::Result)

    The MySQL query result

Returns:

  • (Hash)

    Hash containing rows, columns and errors.



37
38
39
40
41
# File 'lib/rex/post/mysql/ui/console/command_dispatcher/client.rb', line 37

def normalise_sql_result(result)
  # MySQL errors are handled by raising an exception when querying,
  # meaning we don't have that in the Result object.
  { rows: result.entries, columns: result.fields.each.map(&:name), errors: [] }
end