Module: Msf::WebServices::VulnAttemptServlet

Defined in:
lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb

Class Method Summary collapse

Class Method Details

.api_path ⇒ Object



3
4
5
# File 'lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb', line 3

def self.api_path
  '/api/v1/vuln-attempts'
end

.api_path_with_id ⇒ Object



7
8
9
# File 'lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb', line 7

def self.api_path_with_id
  "#{self.api_path}/?:id?"
end

.get_vuln_attempt ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb', line 21

def self.get_vuln_attempt
  lambda {
    warden.authenticate!
    begin
      sanitized_params = sanitize_params(params, env['rack.request.query_hash'])
      data = get_db.vuln_attempts(sanitized_params)
      data = data.first if is_single_object?(data, sanitized_params)
      set_json_data_response(response: data)
    rescue => e
      print_error_and_create_response(error: e, message: 'There was an error retrieving vuln attempts:', code: 500)
    end
  }
end

.registered(app) ⇒ Object



11
12
13
14
15
# File 'lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb', line 11

def self.registered(app)
  app.get self.api_path, &get_vuln_attempt
  app.get self.api_path_with_id, &get_vuln_attempt
  app.post self.api_path, &report_vuln_attempt
end

.report_vuln_attempt ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/msf/core/web_services/servlet/vuln_attempt_servlet.rb', line 35

def self.report_vuln_attempt
  lambda {
    warden.authenticate!
    job = lambda { |opts|
      vuln_id = opts.delete(:vuln_id)
      wspace = opts.delete(:workspace)
      vuln = get_db.vulns(id: vuln_id).first
      get_db.report_vuln_attempt(vuln, opts)
    }
    exec_report_job(request, &job)
  }
end