Module: PWN::Reports::Markdown

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

Overview

Generic Markdown report writer for pentest / findings payloads.

Class Method Summary collapse

Class Method Details

.authorsObject



37
38
39
# File 'lib/pwn/reports/markdown.rb', line 37

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

.generate(opts = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/pwn/reports/markdown.rb', line 7

public_class_method def self.generate(opts = {})
  out = PWN::Reports.resolve_path(opts.merge(ext: 'md'))
  payload = PWN::Reports.report_payload(opts)
  lines = ["# #{payload[:title]}", '']
  lines += ['## Executive summary', '', payload[:executive_summary].to_s, ''] unless payload[:executive_summary].to_s.empty?
  lines += ['## Findings', '']
  if payload[:findings].empty?
    lines << '_No findings._'
  else
    payload[:findings].each do |row|
      lines << "### #{row['id'].to_s.empty? ? row['title'] : "#{row['id']}: #{row['title']}"}"
      lines << ''
      row.each do |key, val|
        next if %w[id title].include?(key.to_s)

        lines << "- **#{key}**: #{val}"
      end
      lines << ''
    end
  end
  unless payload[:attack_chains].empty?
    lines += ['## Attack chains', '']
    payload[:attack_chains].each do |chain|
      lines << "- #{chain[:finding_ids].join(' -> ')}: **#{chain[:combined_severity]}**. #{chain[:rationale]}"
    end
  end
  File.write(out, "#{lines.join("\n").rstrip}\n")
  out
end

.helpObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/pwn/reports/markdown.rb', line 41

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