Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/util/document_generator.rb
Views: 11780
###1#2# This provides methods to generate documentation for a module.3#4###567module Msf8module Util9module DocumentGenerator101112# Spawns a module document with a browser locally.13#14# @param mod [Msf::Module] Module to create document for.15# @param out_file [Rex::Quickfile] File handle to write the document to.16# @return [void]17def self.spawn_module_document(mod, out_file)18md = get_module_document(mod)19out_file.write(md)20Rex::Compat.open_webrtc_browser("file://#{out_file.path}")21end222324# Returns a module document in HTML.25#26# @param mod [Msf::Module] Module to create document for.27# @return [void]28def self.get_module_document(mod)29kb_path = nil30kb = ''3132user_path = File.join(PullRequestFinder::USER_MANUAL_BASE_PATH, "#{mod.fullname}.md")33global_path = File.join(PullRequestFinder::MANUAL_BASE_PATH, "#{mod.fullname}.md")3435if File.exist?(user_path)36kb_path = user_path37elsif File.exist?(global_path)38kb_path = global_path39end4041unless kb_path.nil?42File.open(kb_path, 'rb') { |f| kb = f.read }43end4445begin46pr_finder = PullRequestFinder.new47pr = pr_finder.search(mod)48rescue PullRequestFinder::Exception => e49pr = e50end5152n = DocumentNormalizer.new53items = {54mod_description: mod.description,55mod_authors: mod.send(:module_info)['Author'],56mod_fullname: mod.fullname,57mod_name: mod.name,58mod_pull_requests: pr,59mod_refs: mod.references,60mod_rank: mod.rank,61mod_rank_name: Msf::RankingName[mod.rank].capitalize,62mod_platforms: mod.send(:module_info)['Platform'],63mod_options: mod.options,64mod_side_effects: mod.side_effects,65mod_reliability: mod.reliability,66mod_stability: mod.stability,67mod_demo: mod68}6970if mod.respond_to?(:targets) && mod.targets71items[:mod_targets] = mod.targets72end7374n.get_md_content(items, kb).force_encoding('UTF-8')75end7677end78end79end808182