From 7831cb53c5808448684d454870772fc19fbcfecb Mon Sep 17 00:00:00 2001 From: h00die Date: Sat, 11 Jun 2016 21:13:31 -0400 Subject: [PATCH 1/2] print status of opening browser at file --- lib/msf/util/document_generator.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/msf/util/document_generator.rb b/lib/msf/util/document_generator.rb index a34a60ad93..b81990491d 100644 --- a/lib/msf/util/document_generator.rb +++ b/lib/msf/util/document_generator.rb @@ -22,7 +22,7 @@ module Msf f.write(md) f.close kb_path = f.path - + print_status("Opening web browser for file://#{kb_path}") Rex::Compat.open_webrtc_browser("file://#{kb_path}") end From 78775f7833e9c721312428ed680190337ca3834f Mon Sep 17 00:00:00 2001 From: h00die Date: Wed, 15 Jun 2016 07:44:32 -0400 Subject: [PATCH 2/2] first attempt at 6964 --- lib/msf/ui/console/command_dispatcher/core.rb | 18 ++++++++++++++---- lib/msf/util/document_generator.rb | 11 ++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/msf/ui/console/command_dispatcher/core.rb b/lib/msf/ui/console/command_dispatcher/core.rb index aeef56c6a6..1311828705 100644 --- a/lib/msf/ui/console/command_dispatcher/core.rb +++ b/lib/msf/ui/console/command_dispatcher/core.rb @@ -778,8 +778,13 @@ class Core if dump_json print(Serializer::Json.dump_module(active_module) + "\n") elsif show_doc - print_status("Please wait, generating documentation for #{active_module.shortname}") - Msf::Util::DocumentGenerator.spawn_module_document(active_module) + f = Rex::Quickfile.new(["#{active_module.shortname}_doc", '.html']) + begin + print_status("Generating documentation for #{active_module.shortname}, then opening #{f.path} in a browser...") + Msf::Util::DocumentGenerator.spawn_module_document(active_module, f) + ensure + f.close if f + end else print(Serializer::ReadableText.dump_module(active_module)) end @@ -801,8 +806,13 @@ class Core elsif dump_json print(Serializer::Json.dump_module(mod) + "\n") elsif show_doc - print_status("Please wait, generating documentation for #{mod.shortname}") - Msf::Util::DocumentGenerator.spawn_module_document(mod) + f = Rex::Quickfile.new(["#{active_module.shortname}_doc", '.html']) + begin + print_status("Generating documentation for #{active_module.shortname}, then opening #{f.path} in a browser...") + Msf::Util::DocumentGenerator.spawn_module_document(active_module, f) + ensure + f.close if f + end else print(Serializer::ReadableText.dump_module(mod)) end diff --git a/lib/msf/util/document_generator.rb b/lib/msf/util/document_generator.rb index b81990491d..de92ed7602 100644 --- a/lib/msf/util/document_generator.rb +++ b/lib/msf/util/document_generator.rb @@ -15,15 +15,12 @@ module Msf # Spawns a module document with a browser locally. # # @param mod [Msf::Module] Module to create document for. + # @param out_file [Rex::Quickfile] File handle to write the document to. # @return [void] - def self.spawn_module_document(mod) + def self.spawn_module_document(mod, out_file) md = get_module_document(mod) - f = Rex::Quickfile.new(["#{mod.shortname}_doc", '.html']) - f.write(md) - f.close - kb_path = f.path - print_status("Opening web browser for file://#{kb_path}") - Rex::Compat.open_webrtc_browser("file://#{kb_path}") + out_file.write(md) + Rex::Compat.open_webrtc_browser("file://#{out_file.path}") end