WIP: getting services add working

GSoC/Meterpreter_Web_Console
James Barnett 2018-02-08 17:20:50 -06:00
parent f12405191e
commit bbd25fc97b
No known key found for this signature in database
GPG Key ID: 647983861A4EC5EA
3 changed files with 32 additions and 6 deletions

View File

@ -9,4 +9,19 @@ module ServiceDataProxy
end
end
def services(wspace = workspace, only_up = false, proto = nil, addresses = nil, ports = nil, names = nil)
begin
data_service = self.get_data_service()
opts = {}
opts[:workspace] = wspace
opts[:only_up] = only_up
opts[:proto] = proto
opts[:address] = addresses
opts[:ports] = ports
opts[:names] = names
data_service.services(opts)
rescue Exception => e
elog "Problem retrieving services: #{e.message}"
end
end
end

View File

@ -1,7 +1,12 @@
module RemoteServiceDataService
SERVICE_API_PATH = '/api/v1/services'
SERVICE_MDM_CLASS = 'Mdm::Service'
def report_service(opts)
self.post_data_async(SERVICE_API_PATH, opts)
end
def services(opts)
json_to_mdm_object(self.get_data(SERVICE_API_PATH, nil, opts), SERVICE_MDM_CLASS, [])
end
end

View File

@ -5,6 +5,7 @@ module ServiceServlet
end
def self.registered(app)
app.get ServiceServlet.api_path, &get_services
app.post ServiceServlet.api_path, &report_service
end
@ -12,11 +13,16 @@ module ServiceServlet
private
#######
def self.get_host
def self.get_services
lambda {
begin
opts = parse_json_request(request, false)
data = get_db().hosts(opts)
data = get_db().services(opts[:workspace],
opts[:only_up],
opts[:proto],
opts[:address],
opts[:ports],
opts[:names])
set_json_response(data)
rescue Exception => e
set_error_on_response(e)