Class: Rex::Post::MSSQL::Ui::Console

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

Overview

This class provides a shell driven interface to the MSSQL 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, opts = {}) ⇒ Console

Initialize the MSSQL console.

Parameters:



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rex/post/mssql/ui/console.rb', line 27

def initialize(session, opts={})
  # The mssql client context
  self.session = session
  self.client = session.client
  envchange = ::Rex::Proto::MSSQL::ClientMixin::ENVCHANGE
  prompt = "%undMSSQL @ #{client.peerinfo} (#{client.initial_info_for_envchange(envchange: envchange::DATABASE)[:new]})%clr"
  history_file = Msf::Config.history_file_for_session_type(session_type: session.type, interactive: false)
  super(prompt, '>', history_file, nil, :mssql)

  # Queued commands array
  self.commands = []

  # Point the input/output handles elsewhere
  reset_ui

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

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

Instance Attribute Details

#clientMSSQL::Client

Returns:

  • (MSSQL::Client)


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

def client
  @client
end

#commandsObject (protected)

:nodoc:



61
62
63
# File 'lib/rex/post/mssql/ui/console.rb', line 61

def commands
  @commands
end

#sessionMsf::Sessions::MSSQL



53
54
55
# File 'lib/rex/post/mssql/ui/console.rb', line 53

def session
  @session
end