CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/lib/rex/post/mysql/ui/console.rb
Views: 1904
1
# -*- coding: binary -*-
2
3
require 'rex/post/sql/ui/console'
4
5
module Rex
6
module Post
7
module MySQL
8
module Ui
9
10
# This class provides a shell driven interface to the MySQL client API.
11
class Console
12
include Rex::Post::Sql::Ui::Console
13
include Rex::Ui::Text::DispatcherShell
14
15
# Dispatchers
16
require 'rex/post/mysql/ui/console/command_dispatcher'
17
require 'rex/post/mysql/ui/console/command_dispatcher/core'
18
require 'rex/post/mysql/ui/console/command_dispatcher/client'
19
20
# Initialize the MySQL console.
21
#
22
# @param [Msf::Sessions::MySQL] session
23
def initialize(session)
24
# The mysql client context
25
self.session = session
26
self.client = session.client
27
prompt = "%undMySQL @ #{client.peerinfo} (#{current_database})%clr"
28
history_file = Msf::Config.history_file_for_session_type(session_type: session.type, interactive: false)
29
super(prompt, '>', history_file, nil, :mysql)
30
31
# Queued commands array
32
self.commands = []
33
34
# Point the input/output handles elsewhere
35
reset_ui
36
37
enstack_dispatcher(::Rex::Post::MySQL::Ui::Console::CommandDispatcher::Core)
38
enstack_dispatcher(::Rex::Post::MySQL::Ui::Console::CommandDispatcher::Client)
39
enstack_dispatcher(Msf::Ui::Console::CommandDispatcher::LocalFileSystem)
40
41
# Set up logging to whatever logsink 'core' is using
42
if ! $dispatcher['mysql']
43
$dispatcher['mysql'] = $dispatcher['core']
44
end
45
end
46
47
# @return [Msf::Sessions::MySQL]
48
attr_reader :session
49
50
# @return [MySQL::Client]
51
attr_reader :client
52
53
protected
54
55
attr_writer :session, :client # :nodoc:
56
attr_accessor :commands # :nodoc:
57
end
58
end
59
end
60
end
61
end
62
63