Support RPC API

bug/bundler_fix
wchen-r7 2016-02-18 00:39:12 -06:00
parent 089d6985b6
commit a5f3bddfc8
3 changed files with 34 additions and 7 deletions

View File

@ -1,5 +1,7 @@
# -*- coding: binary -*-
require 'msf/util/document_generator'
module Msf
module RPC
class RPC_Module < RPC_Base
@ -70,6 +72,17 @@ class RPC_Module < RPC_Base
end
# Returns detailed information about a module in HTML.
#
# @return [String] HTML file.
# @example Here's how you would use this from the client:
# rpc.call('module.info_html', 'exploit', 'windows/smb/ms08_067_netapi')
def rpc_info_html(mtype, mname)
m = _find_module(mtype, mname)
Msf::Util::DocumentGenerator.get_module_document(m)
end
# Returns the metadata for a module.
#
# @param [String] mtype Module type. Supported types include (case-sensitive):

View File

@ -774,7 +774,7 @@ class Core
if dump_json
print(Serializer::Json.dump_module(active_module) + "\n")
elsif show_doc
Msf::Util::DocumentGenerator.get_module_document(active_module)
Msf::Util::DocumentGenerator.spawn_module_document(active_module)
else
print(Serializer::ReadableText.dump_module(active_module))
end

View File

@ -50,12 +50,22 @@ module Msf
private
def load_css
@css ||= lambda {
data = ''
File.open(CSS_BASE_PATH, 'rb') { |f| data = f.read }
return data
}.call
end
def md_to_html(md)
r = Redcarpet::Markdown.new(Redcarpet::Render::MsfMdHTML, fenced_code_blocks: true)
%Q|
<html>
<head>
<link rel="stylesheet" href="file://#{CSS_BASE_PATH}">
<style>
#{load_css}
</style>
</head>
<body>
#{r.render(md)}
@ -247,6 +257,14 @@ module Msf
end
def self.spawn_module_document(mod)
md = get_module_document(mod)
f = Rex::Quickfile.new(["#{mod.shortname}_doc", '.html'])
f.write(md)
f.close
Rex::Compat.open_webrtc_browser("file://#{f.path}")
end
def self.get_module_document(mod)
manual_path = File.join(PullRequestFinder::MANUAL_BASE_PATH, "#{mod.fullname}.md")
@ -279,11 +297,7 @@ module Msf
items[:mod_targets] = mod.targets
end
md = n.get_md_content(items)
f = Rex::Quickfile.new(["#{mod.shortname}_doc", '.html'])
f.write(md)
f.close
Rex::Compat.open_webrtc_browser("file://#{f.path}")
n.get_md_content(items)
end
end