Module: Msf::Util::DocumentGenerator

Defined in:
lib/msf/util/document_generator.rb,
lib/msf/util/document_generator/document_normalizer.rb,
lib/msf/util/document_generator/pull_request_finder.rb

Defined Under Namespace

Classes: DocumentNormalizer, PullRequestFinder

Class Method Summary collapse

Class Method Details

.get_module_document(mod) ⇒ void

This method returns an undefined value.

Returns a module document in HTML.

Parameters:



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/msf/util/document_generator.rb', line 29

def self.get_module_document(mod)
  kb_path = nil
  kb = ''

  user_path = File.join(PullRequestFinder::USER_MANUAL_BASE_PATH, "#{mod.fullname}.md")
  global_path = File.join(PullRequestFinder::MANUAL_BASE_PATH, "#{mod.fullname}.md")

  if File.exist?(user_path)
    kb_path = user_path
  elsif File.exist?(global_path)
    kb_path = global_path
  end

  unless kb_path.nil?
    File.open(kb_path, 'rb') { |f| kb = f.read }
  end

  begin
    pr_finder = PullRequestFinder.new
    pr = pr_finder.search(mod)
  rescue PullRequestFinder::Exception => e
    pr = e
  end

  n = DocumentNormalizer.new
    items = {
      mod_description:   mod.description,
      mod_authors:       mod.send(:module_info)['Author'],
      mod_fullname:      mod.fullname,
      mod_name:          mod.name,
      mod_pull_requests: pr,
      mod_refs:          mod.references,
      mod_rank:          mod.rank,
      mod_rank_name:     Msf::RankingName[mod.rank].capitalize,
      mod_platforms:     mod.send(:module_info)['Platform'],
      mod_options:       mod.options,
      mod_side_effects:  mod.side_effects,
      mod_reliability:   mod.reliability,
      mod_stability:     mod.stability,
      mod_demo:          mod
  }

  if mod.respond_to?(:targets) && mod.targets
    items[:mod_targets] = mod.targets
  end

  n.get_md_content(items, kb).force_encoding('UTF-8')
end

.spawn_module_document(mod, out_file) ⇒ void

This method returns an undefined value.

Spawns a module document with a browser locally.

Parameters:

  • mod (Msf::Module)

    Module to create document for.

  • out_file (Rex::Quickfile)

    File handle to write the document to.



18
19
20
21
22
# File 'lib/msf/util/document_generator.rb', line 18

def self.spawn_module_document(mod, out_file)
  md = get_module_document(mod)
  out_file.write(md)
  Rex::Compat.open_webrtc_browser("file://#{out_file.path}")
end