Module: ServiceDataProxy

Included in:
DataProxyAutoLoader
Defined in:
lib/metasploit/framework/data_service/proxy/service_data_proxy.rb

Instance Method Summary collapse

Instance Method Details

#delete_service(opts) ⇒ Object



55
56
57
58
59
60
61
62
63
# File 'lib/metasploit/framework/data_service/proxy/service_data_proxy.rb', line 55

def delete_service(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.delete_service(opts)
    end
  rescue => e
    self.log_error(e, 'Problem deleting service')
  end
end

#find_or_create_service(opts) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/metasploit/framework/data_service/proxy/service_data_proxy.rb', line 14

def find_or_create_service(opts)
  begin
    # create separate opts for find operation since the report operation uses slightly different keys
    # TODO: standardize option keys used for the find and report operations
    find_opts = opts.clone
    # convert host to nested hosts address
    find_opts[:hosts] = {address: find_opts.delete(:host)} if find_opts.key?(:host)

    service = services(find_opts)
    if service.nil? || service.first.nil?
      service = report_service(opts.clone)
    else
      service = service.first
    end
    service
  rescue => e
    self.log_error(e, "Problem finding or creating service")
  end
end

#report_service(opts) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'lib/metasploit/framework/data_service/proxy/service_data_proxy.rb', line 34

def report_service(opts)
  begin
    self.data_service_operation do |data_service|
      add_opts_workspace(opts)
      data_service.report_service(opts)
    end
  rescue => e
    self.log_error(e, 'Problem reporting service')
  end
end

#services(opts = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'lib/metasploit/framework/data_service/proxy/service_data_proxy.rb', line 3

def services(opts = {})
  begin
    self.data_service_operation do |data_service|
      add_opts_workspace(opts)
      data_service.services(opts)
    end
  rescue => e
    self.log_error(e, 'Problem retrieving services')
  end
end

#update_service(opts) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/metasploit/framework/data_service/proxy/service_data_proxy.rb', line 45

def update_service(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.update_service(opts)
    end
  rescue => e
    self.log_error(e, 'Problem updating service')
  end
end