Class: Msf::RPC::RPC_Console

Inherits:
RPC_Base show all
Defined in:
lib/msf/core/rpc/v10/rpc_console.rb

Instance Attribute Summary

Attributes inherited from RPC_Base

#framework, #service, #tokens, #users

Instance Method Summary collapse

Methods inherited from RPC_Base

#error

Constructor Details

#initialize(*args) ⇒ RPC_Console

Returns a new instance of RPC_Console


10
11
12
13
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 10

def initialize(*args)
  super
  @console_driver = Msf::Ui::Web::Driver.new(:framework => framework)
end

Instance Method Details

#rpc_create(opts = {}) ⇒ Object


15
16
17
18
19
20
21
22
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 15

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) ⇒ Object


36
37
38
39
40
41
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 36

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_listObject


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 24

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) ⇒ Object


43
44
45
46
47
48
49
50
51
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 43

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) ⇒ Object


72
73
74
75
76
77
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 72

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) ⇒ Object


65
66
67
68
69
70
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 65

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) ⇒ Object


59
60
61
62
63
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 59

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) ⇒ Object


53
54
55
56
57
# File 'lib/msf/core/rpc/v10/rpc_console.rb', line 53

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