Module: RemoteSessionDataService

Includes:
ResponseDataHelper
Included in:
DataServiceAutoLoader
Defined in:
lib/metasploit/framework/data_service/remote/http/remote_session_data_service.rb

Constant Summary collapse

SESSION_API_PATH =
'/api/v1/sessions'
SESSION_MDM_CLASS =
'Mdm::Session'

Instance Method Summary collapse

Methods included from ResponseDataHelper

#json_to_hash, #json_to_mdm_object, #process_file, #to_ar

Instance Method Details

#report_session(opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/metasploit/framework/data_service/remote/http/remote_session_data_service.rb', line 14

def report_session(opts)
  session = opts[:session]
  session.workspace = session.workspace || opts[:workspace]
  if (session.kind_of? Msf::Session)
    opts = SessionDataProxy.convert_msf_session_to_hash(session)
  elsif (opts[:host])
    opts[:host] = opts[:host].address
  end

  opts[:time_stamp] = Time.now.utc
  sess_db = json_to_mdm_object(self.post_data(SESSION_API_PATH, opts), SESSION_MDM_CLASS).first
  session.db_record = sess_db
end

#sessions(opts) ⇒ Object



9
10
11
12
# File 'lib/metasploit/framework/data_service/remote/http/remote_session_data_service.rb', line 9

def sessions(opts)
  path = get_path_select(opts, SESSION_API_PATH)
  json_to_mdm_object(self.get_data(path, nil, opts), SESSION_MDM_CLASS)
end

#update_session(opts) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/metasploit/framework/data_service/remote/http/remote_session_data_service.rb', line 28

def update_session(opts)
  path = SESSION_API_PATH
  if opts && opts[:id]
    id = opts.delete(:id)
    path = "#{SESSION_API_PATH}/#{id}"
  end

  json_to_mdm_object(self.put_data(path, opts), SESSION_MDM_CLASS).first
end