Class: Msf::Ui::Web::WebConsole
- Inherits:
-
Object
- Object
- Msf::Ui::Web::WebConsole
show all
- Defined in:
- lib/msf/ui/web/web_console.rb
Overview
This class implements a console instance for use by the web interface
Defined Under Namespace
Modules: WebConsoleShell
Classes: WebConsolePipe
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(framework, console_id, opts = {}) ⇒ WebConsole
Returns a new instance of WebConsole.
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'lib/msf/ui/web/web_console.rb', line 46
def initialize(framework, console_id, opts={})
self.framework = framework
self.console_id = console_id
self.pipe = WebConsolePipe.new
self.pipe.create_subscriber('msfweb')
if framework.db && framework.db.active
opts['SkipDatabaseInit'] = true
if opts['workspace']
wspace = framework.db.find_workspace(opts['workspace'])
framework.db.workspace = wspace
end
end
self.console = Msf::Ui::Console::Driver.new(
'msf',
'>',
opts.merge({
'Framework' => self.framework,
'LocalInput' => self.pipe,
'LocalOutput' => self.pipe,
'AllowCommandPassthru' => true,
'Resource' => [],
})
)
self.console.extend(WebConsoleShell)
self.console.block_command('irb')
self.thread = framework.threads.spawn("WebConsoleShell", false) { self.console.run }
update_access()
end
|
Instance Attribute Details
#console ⇒ Object
Returns the value of attribute console.
14
15
16
|
# File 'lib/msf/ui/web/web_console.rb', line 14
def console
@console
end
|
#console_id ⇒ Object
Returns the value of attribute console_id.
15
16
17
|
# File 'lib/msf/ui/web/web_console.rb', line 15
def console_id
@console_id
end
|
#framework ⇒ Object
Returns the value of attribute framework.
17
18
19
|
# File 'lib/msf/ui/web/web_console.rb', line 17
def framework
@framework
end
|
#last_access ⇒ Object
Returns the value of attribute last_access.
16
17
18
|
# File 'lib/msf/ui/web/web_console.rb', line 16
def last_access
@last_access
end
|
#pipe ⇒ Object
Returns the value of attribute pipe.
13
14
15
|
# File 'lib/msf/ui/web/web_console.rb', line 13
def pipe
@pipe
end
|
#thread ⇒ Object
Returns the value of attribute thread.
18
19
20
|
# File 'lib/msf/ui/web/web_console.rb', line 18
def thread
@thread
end
|
Instance Method Details
#active_module ⇒ Object
148
149
150
|
# File 'lib/msf/ui/web/web_console.rb', line 148
def active_module
self.console.active_module
end
|
#active_module=(val) ⇒ Object
152
153
154
|
# File 'lib/msf/ui/web/web_console.rb', line 152
def active_module=(val)
self.console.active_module = val
end
|
#busy ⇒ Object
123
124
125
|
# File 'lib/msf/ui/web/web_console.rb', line 123
def busy
self.console.busy
end
|
#execute(cmd) ⇒ Object
103
104
105
|
# File 'lib/msf/ui/web/web_console.rb', line 103
def execute(cmd)
self.console.run_single(cmd)
end
|
#prompt ⇒ Object
107
108
109
|
# File 'lib/msf/ui/web/web_console.rb', line 107
def prompt
self.pipe.prompt
end
|
#read ⇒ Object
93
94
95
96
|
# File 'lib/msf/ui/web/web_console.rb', line 93
def read
update_access
self.pipe.read_subscriber('msfweb')
end
|
#session_detach ⇒ Object
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
# File 'lib/msf/ui/web/web_console.rb', line 127
def session_detach
if(self.console.active_session)
if(self.console.active_session.respond_to?('channels'))
self.console.active_session.channels.each_value do |ch|
if(ch.respond_to?('interacting') && ch.interacting)
ch.detach()
return
end
end
end
self.console.active_session.completed = true
self.console.active_session.detach()
end
end
|
#session_kill ⇒ Object
144
145
146
|
# File 'lib/msf/ui/web/web_console.rb', line 144
def session_kill
self.thread.raise(Interrupt)
end
|
#shutdown ⇒ Object
118
119
120
121
|
# File 'lib/msf/ui/web/web_console.rb', line 118
def shutdown
self.pipe.close
self.thread.kill
end
|
#tab_complete(cmd) ⇒ Object
111
112
113
114
115
116
|
# File 'lib/msf/ui/web/web_console.rb', line 111
def tab_complete(cmd)
if(self.console.active_session)
return self.console.active_session.console.tab_complete(cmd)
end
self.console.tab_complete(cmd)
end
|
#update_access ⇒ Object
89
90
91
|
# File 'lib/msf/ui/web/web_console.rb', line 89
def update_access
self.last_access = Time.now
end
|
#write(buf) ⇒ Object
98
99
100
101
|
# File 'lib/msf/ui/web/web_console.rb', line 98
def write(buf)
update_access
self.pipe.write_input(buf)
end
|