Module: RemoteLootDataService

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

Constant Summary collapse

LOOT_API_PATH =
'/api/v1/loots'
LOOT_MDM_CLASS =
'Mdm::Loot'

Instance Method Summary collapse

Methods included from ResponseDataHelper

#json_to_hash, #json_to_mdm_object, #process_file, #to_ar

Instance Method Details

#delete_loot(opts) ⇒ Object


42
43
44
# File 'lib/metasploit/framework/data_service/remote/http/remote_loot_data_service.rb', line 42

def delete_loot(opts)
  json_to_mdm_object(self.delete_data(LOOT_API_PATH, opts), LOOT_MDM_CLASS)
end

#loot(opts = {}) ⇒ Object


9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/metasploit/framework/data_service/remote/http/remote_loot_data_service.rb', line 9

def loot(opts = {})
  path = get_path_select(opts, LOOT_API_PATH)
  data = self.get_data(path, nil, opts)
  rv = json_to_mdm_object(data, LOOT_MDM_CLASS)
  parsed_body = JSON.parse(data.response.body, symbolize_names: true)
  data = parsed_body[:data]
  data.each do |loot|
    # TODO: Add an option to toggle whether the file data is returned or not
    if loot[:data] && !loot[:data].empty?
      local_path = File.join(Msf::Config.loot_directory, File.basename(loot[:path]))
      rv[data.index(loot)].path = process_file(loot[:data], local_path)
    end
    if loot[:host]
      host_object = to_ar(RemoteHostDataService::HOST_MDM_CLASS.constantize, loot[:host])
      rv[data.index(loot)].host = host_object
    end
  end
  rv
end

#report_loot(opts) ⇒ Object


29
30
31
# File 'lib/metasploit/framework/data_service/remote/http/remote_loot_data_service.rb', line 29

def report_loot(opts)
  self.post_data_async(LOOT_API_PATH, opts)
end

#update_loot(opts) ⇒ Object


33
34
35
36
37
38
39
40
# File 'lib/metasploit/framework/data_service/remote/http/remote_loot_data_service.rb', line 33

def update_loot(opts)
  path = LOOT_API_PATH
  if opts && opts[:id]
    id = opts.delete(:id)
    path = "#{LOOT_API_PATH}/#{id}"
  end
  json_to_mdm_object(self.put_data(path, opts), LOOT_MDM_CLASS)
end