Module: PWN::Reports::XML

Defined in:
lib/pwn/reports/xml.rb

Overview

Generic XML report writer for pentest / findings payloads.

Class Method Summary collapse

Class Method Details

.authorsObject



35
36
37
# File 'lib/pwn/reports/xml.rb', line 35

public_class_method def self.authors
  "AUTHOR(S):\n  0day Inc. <[email protected]>\n"
end

.generate(opts = {}) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/pwn/reports/xml.rb', line 9

public_class_method def self.generate(opts = {})
  out = PWN::Reports.resolve_path(opts.merge(ext: 'xml'))
  payload = PWN::Reports.report_payload(opts)
  doc = REXML::Document.new
  doc << REXML::XMLDecl.new('1.0', 'UTF-8')
  root = doc.add_element('report')
  root.add_element('title').text = payload[:title]
  root.add_element('executive_summary').text = payload[:executive_summary]
  findings = root.add_element('findings')
  payload[:findings].each do |row|
    node = findings.add_element('finding')
    row.each do |key, val|
      node.add_element(safe_tag(name: key)).text = val.to_s
    end
  end
  File.open(out, 'w') { |io| doc.write(io, 2) }
  out
end

.helpObject



39
40
41
42
43
44
45
46
47
48
# File 'lib/pwn/reports/xml.rb', line 39

public_class_method def self.help
  puts "USAGE:
    # Run generate and return its result
    #{self}.generate

    # Print the AUTHOR(S) string for this module.
    #{self}.authors
  "
  constants.sort
end