Module: HostDataProxy

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

Instance Method Summary collapse

Instance Method Details

#add_host_tag(opts) ⇒ Object



84
85
86
87
88
89
90
91
92
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 84

def add_host_tag(opts)
  if add_host_id_to_opts(opts)
    self.data_service_operation do |data_service|
      return data_service.add_host_tag(opts)
    end
  else
    nil
  end
end

#delete_host(opts) ⇒ Object



64
65
66
67
68
69
70
71
72
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 64

def delete_host(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.delete_host(opts)
    end
  rescue => e
    self.log_error(e, "Problem deleting host")
  end
end

#delete_host_tag(opts) ⇒ Object



94
95
96
97
98
99
100
101
102
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 94

def delete_host_tag(opts)
  if add_host_id_to_opts(opts)
    self.data_service_operation do |data_service|
      return data_service.delete_host_tag(opts)
    end
  else
    nil
  end
end

#find_or_create_host(opts) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 17

def find_or_create_host(opts)
  begin
    host = hosts(opts.clone)
    if host.nil? || host.first.nil?
      host = report_host(opts.clone)
    else
      host = host.first
    end
    host
  rescue => e
    self.log_error(e, "Problem finding or creating host")
  end
end

#get_host(opts) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 31

def get_host(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.get_host(opts)
    end
  rescue => e
    self.log_error(e, "Problem retrieving host")
  end
end

#get_host_tags(opts) ⇒ Object



74
75
76
77
78
79
80
81
82
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 74

def get_host_tags(opts)
  if add_host_id_to_opts(opts)
    self.data_service_operation do |data_service|
      return data_service.get_host_tags(opts)
    end
  else
    nil
  end
end

#hosts(opts = {}) ⇒ Object



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

def hosts(opts = {})
  begin
    self.data_service_operation do |data_service|
      opts[:non_dead] = false unless opts.has_key?(:non_dead)
      opts[:address] = opts.delete(:address) || opts.delete(:host)
      opts[:search_term] = nil unless opts.has_key?(:search_term)
      add_opts_workspace(opts)
      data_service.hosts(opts)
    end
  rescue => e
    self.log_error(e, "Problem retrieving hosts")
  end
end

#report_host(opts) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/metasploit/framework/data_service/proxy/host_data_proxy.rb', line 41

def report_host(opts)
  return unless valid(opts)

  begin
    self.data_service_operation do |data_service|
      add_opts_workspace(opts)
      data_service.report_host(opts)
    end
  rescue => e
    self.log_error(e, "Problem reporting host")
  end
end

#update_host(opts) ⇒ Object



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

def update_host(opts)
  begin
    self.data_service_operation do |data_service|
      data_service.update_host(opts)
    end
  rescue => e
    self.log_error(e, "Problem updating host")
  end
end