Add stubs for remote data payload

master
Erin Bleiweiss 2018-09-14 10:21:24 -05:00
parent 7994564f25
commit c8f48d4272
No known key found for this signature in database
GPG Key ID: F69B2138BD594660
3 changed files with 86 additions and 0 deletions

View File

@ -0,0 +1,39 @@
module PayloadDataProxy
def create_payload(opts)
begin
data_service = self.get_data_service
data_service.create_payload(opts)
rescue => e
self.log_error(e, "Problem creating payload")
end
end
def get_payload(opts)
begin
data_service = self.get_data_service
data_service.get_payload(opts)
rescue => e
self.log_error(e, "Problem retrieving payload")
end
end
def update_payload(opts)
begin
data_service = self.get_data_service
data_service.update_payload(opts)
rescue => e
self.log_error(e, "Problem updating payload")
end
end
def delete_payload(opts)
begin
data_service = self.get_data_service
data_service.delete_payload(opts)
rescue => e
self.log_error(e, "Problem deleting payload")
end
end
end

View File

@ -0,0 +1,29 @@
require 'metasploit/framework/data_service/remote/http/response_data_helper'
module RemotePayloadDataService
include ResponseDataHelper
PAYLOAD_API_PATH = '/api/v1/payloads'
PAYLOAD_MDM_CLASS = 'Mdm::Payload'
def create_payload(opts)
json_to_mdm_object(self.post_data(PAYLOAD_API_PATH, opts), PAYLOAD_MDM_CLASS, []).first
end
def get_payload(opts)
json_to_mdm_object(self.get_data(PAYLOAD_API_PATH, nil, opts), PAYLOAD_MDM_CLASS, [])
end
def update_payload(opts)
path = PAYLOAD_API_PATH
if opts && opts[:id]
id = opts.delete(:id)
path = "#{PAYLOAD_API_PATH}/#{id}"
end
json_to_mdm_object(self.put_data(path, opts), PAYLOAD_MDM_CLASS, [])
end
def delete_payload(opts)
json_to_mdm_object(self.delete_data(PAYLOAD_API_PATH, opts), PAYLOAD_MDM_CLASS, [])
end
end

View File

@ -0,0 +1,18 @@
module PayloadDataService
def get_payload(opts)
raise 'PayloadDataService#get_payload is not implemented'
end
def create_payload(opts)
raise 'PayloadDataService#create_payload is not implemented'
end
def update_payload(opts)
raise 'PayloadDataService#update_payload is not implemented'
end
def delete_payload(opts)
raise 'PayloadDataService#delete_payload is not implemented'
end
end