Implement remote service create
parent
96709600e1
commit
c90fabee60
|
@ -1,14 +1,5 @@
|
|||
module ServiceDataProxy
|
||||
|
||||
def report_service(opts)
|
||||
begin
|
||||
data_service = self.get_data_service()
|
||||
data_service.report_service(opts)
|
||||
rescue Exception => e
|
||||
self.log_error(e, "Problem reporting service")
|
||||
end
|
||||
end
|
||||
|
||||
def services(wspace = workspace, only_up = false, proto = nil, addresses = nil, ports = nil, names = nil)
|
||||
begin
|
||||
data_service = self.get_data_service()
|
||||
|
@ -21,7 +12,20 @@ module ServiceDataProxy
|
|||
opts[:names] = names
|
||||
data_service.services(opts)
|
||||
rescue Exception => e
|
||||
elog "Problem retrieving services: #{e.message}"
|
||||
self.log_error(e, "Problem retrieving services")
|
||||
end
|
||||
end
|
||||
|
||||
def find_or_create_service(opts)
|
||||
report_service(opts)
|
||||
end
|
||||
|
||||
def report_service(opts)
|
||||
begin
|
||||
data_service = self.get_data_service()
|
||||
data_service.report_service(opts)
|
||||
rescue Exception => e
|
||||
self.log_error(e, "Problem reporting service")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,11 +2,11 @@ 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
|
||||
|
||||
def report_service(opts)
|
||||
json_to_mdm_object(self.post_data(SERVICE_API_PATH, opts), SERVICE_MDM_CLASS).first
|
||||
end
|
||||
end
|
||||
|
|
|
@ -674,12 +674,14 @@ module Msf
|
|||
print_error("Exactly one port required")
|
||||
return
|
||||
end
|
||||
if host_ranges.empty?
|
||||
print_error("Host address or range required")
|
||||
return
|
||||
end
|
||||
host_ranges.each do |range|
|
||||
range.each do |addr|
|
||||
host = framework.db.find_or_create_host(:host => addr)
|
||||
next if not host
|
||||
info = {
|
||||
:host => host,
|
||||
:host => addr,
|
||||
:port => ports.first.to_i
|
||||
}
|
||||
info[:proto] = proto.downcase if proto
|
||||
|
|
Loading…
Reference in New Issue