Class: Dradis::Plugins::Metasploit::Importer
- Inherits:
-
Upload::Importer
- Object
- Upload::Importer
- Dradis::Plugins::Metasploit::Importer
- Defined in:
- lib/dradis/plugins/metasploit/importer.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#import(params = {}) ⇒ Object
The framework will call this function if the user selects this plugin from the dropdown list and uploads a file.
Class Method Details
.templates ⇒ Object
3 4 5 |
# File 'lib/dradis/plugins/metasploit/importer.rb', line 3 def self.templates {} end |
Instance Method Details
#import(params = {}) ⇒ Object
The framework will call this function if the user selects this plugin from the dropdown list and uploads a file.
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/dradis/plugins/metasploit/importer.rb', line 10 def import(params={}) file_content = File.read( params[:file] ) # Parse the uploaded file into a Ruby Hash logger.info { "Parsing Metasploit output from #{ params[:file] }..." } @doc = Nokogiri::XML(file_content) logger.info { 'Done.' } case @doc.root.name when 'MetasploitV5' # version_importer = Dradis::Plugins::Metasploit::Importers::Version5.new(@doc) when /MetasploitV/ error = "Invalid Metasploit version. Sorry, the XML file corresponds to a version of Metasploit we don't have a parser for. Please let us know: http://discuss.dradisframework.org" logger.fatal { error } content_service.create_note text: error return false else error = "Invalid XML file. The XML document didn't contain a Metasploit root tag. Did you upload a Metasploit XML file?" logger.fatal { error } content_service.create_note text: error return false end parse_file end |