Class: Msf::RPC::RPC_Console
- Defined in:
- lib/msf/core/rpc/v10/rpc_console.rb
Instance Attribute Summary
Attributes inherited from RPC_Base
#framework, #job_status_tracker, #service, #tokens, #users
Instance Method Summary collapse
-
#initialize(*args) ⇒ Msf::Ui::Web::Driver
constructor
Initializes the RPC console.
-
#rpc_create(opts = {}) ⇒ Hash
Creates a new framework console instance.
-
#rpc_destroy(cid) ⇒ Hash
Deletes a framework console instance.
-
#rpc_list ⇒ Hash
Returns a list of framework consoles.
-
#rpc_read(cid) ⇒ Hash
Returns the framework console output in raw form.
-
#rpc_session_detach(cid) ⇒ Hash
Detaches a framework session.
-
#rpc_session_kill(cid) ⇒ Hash
Kills a framework session.
-
#rpc_tabs(cid, line) ⇒ Hash
Returns the tab-completed version of your input (such as a module path).
-
#rpc_write(cid, data) ⇒ Hash
Sends an input (such as a command) to the framework console.
Methods inherited from RPC_Base
Constructor Details
Instance Method Details
#rpc_create(opts = {}) ⇒ Hash
Creates a new framework console instance.
27 28 29 30 31 32 33 34 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 27 def rpc_create(opts={}) cid = @console_driver.create_console(opts) { 'id' => cid, 'prompt' => @console_driver.consoles[cid].prompt || '', 'busy' => @console_driver.consoles[cid].busy || false } end |
#rpc_destroy(cid) ⇒ Hash
Deletes a framework console instance.
68 69 70 71 72 73 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 68 def rpc_destroy(cid) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] res = @console_driver.destroy_console(cid) { 'result' => res ? 'success' : 'failure' } end |
#rpc_list ⇒ Hash
Returns a list of framework consoles.
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 47 def rpc_list ret = [] @console_driver.consoles.each_key do |cid| ret << { 'id' => cid, 'prompt' => @console_driver.consoles[cid].prompt || '', 'busy' => @console_driver.consoles[cid].busy || false } end {'consoles' => ret} end |
#rpc_read(cid) ⇒ Hash
Returns the framework console output in raw form.
90 91 92 93 94 95 96 97 98 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 90 def rpc_read(cid) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] { "data" => @console_driver.read_console(cid) || '', "prompt" => @console_driver.consoles[cid].prompt || '', "busy" => @console_driver.consoles[cid].busy || false } end |
#rpc_session_detach(cid) ⇒ Hash
Detaches a framework session. This serves the same purpose as [CTRL]+ to background an interactive session.
169 170 171 172 173 174 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 169 def rpc_session_detach(cid) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] @console_driver.consoles[cid].session_detach { 'result' => 'success' } end |
#rpc_session_kill(cid) ⇒ Hash
Kills a framework session. This serves the same purpose as [CTRL]+ to abort an interactive session. You might also want to considering using the session API calls instead of this.
153 154 155 156 157 158 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 153 def rpc_session_kill(cid) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] @console_driver.consoles[cid].session_kill { 'result' => 'success' } end |
#rpc_tabs(cid, line) ⇒ Hash
Returns the tab-completed version of your input (such as a module path).
138 139 140 141 142 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 138 def rpc_tabs(cid, line) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] { "tabs" => @console_driver.consoles[cid].tab_complete(line) } end |
#rpc_write(cid, data) ⇒ Hash
Remember to add a newline (\r\n) at the end of input, otherwise the console will not do anything. And you will need to use the #rpc_read method to retrieve the output again.
Sends an input (such as a command) to the framework console.
117 118 119 120 121 |
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 117 def rpc_write(cid, data) cid = cid.to_s return { 'result' => 'failure' } if not @console_driver.consoles[cid] { "wrote" => @console_driver.write_console(cid, data || '') } end |