From 6c0f549abbc72c54f46a8c0ffbe785f98e557327 Mon Sep 17 00:00:00 2001 From: Luke Imhoff Date: Tue, 14 Oct 2014 15:40:29 -0500 Subject: [PATCH] Extract Msf::DBManager::Import::Acunetix MSP-11124 --- lib/msf/core/db_manager/import.rb | 33 ++------------------- lib/msf/core/db_manager/import/acunetix.rb | 34 ++++++++++++++++++++++ 2 files changed, 36 insertions(+), 31 deletions(-) create mode 100644 lib/msf/core/db_manager/import/acunetix.rb diff --git a/lib/msf/core/db_manager/import.rb b/lib/msf/core/db_manager/import.rb index 25352725c5..06b361c38c 100644 --- a/lib/msf/core/db_manager/import.rb +++ b/lib/msf/core/db_manager/import.rb @@ -12,7 +12,6 @@ require 'uri' # require 'packetfu' -require 'rex/parser/acunetix_nokogiri' require 'rex/parser/appscan_nokogiri' require 'rex/parser/burp_session_nokogiri' require 'rex/parser/ci_nokogiri' @@ -34,9 +33,11 @@ require 'rex/parser/retina_xml' require 'rex/parser/wapiti_nokogiri' module Msf::DBManager::Import + autoload :Acunetix, 'msf/core/db_manager/import/acunetix' autoload :MsfXml, 'msf/core/db_manager/import/msf_xml' autoload :Qualys, 'msf/core/db_manager/import/qualys' + include Msf::DBManager::Import::Acunetix include Msf::DBManager::Import::MsfXml include Msf::DBManager::Import::Qualys @@ -66,36 +67,6 @@ module Msf::DBManager::Import self.send "import_#{ftype}".to_sym, args, &block end - def import_acunetix_noko_stream(args={},&block) - if block - doc = Rex::Parser::AcunetixDocument.new(args,framework.db) {|type, data| yield type,data } - else - doc = Rex::Parser::AcunetixFoundstoneDocument.new(args,self) - end - parser = ::Nokogiri::XML::SAX::Parser.new(doc) - parser.parse(args[:data]) - end - - def import_acunetix_xml(args={}, &block) - bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : [] - wspace = args[:wspace] || workspace - if Rex::Parser.nokogiri_loaded - parser = "Nokogiri v#{::Nokogiri::VERSION}" - noko_args = args.dup - noko_args[:blacklist] = bl - noko_args[:wspace] = wspace - if block - yield(:parser, parser) - import_acunetix_noko_stream(noko_args) {|type, data| yield type,data} - else - import_acunetix_noko_stream(noko_args) - end - return true - else # Sorry - raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.") - end - end - def import_amap_log(args={}, &block) data = args[:data] wspace = args[:wspace] || workspace diff --git a/lib/msf/core/db_manager/import/acunetix.rb b/lib/msf/core/db_manager/import/acunetix.rb new file mode 100644 index 0000000000..afe7c9f2fa --- /dev/null +++ b/lib/msf/core/db_manager/import/acunetix.rb @@ -0,0 +1,34 @@ +require 'rex/parser/acunetix_nokogiri' + +module Msf::DBManager::Import::Acunetix + def import_acunetix_noko_stream(args={},&block) + if block + doc = Rex::Parser::AcunetixDocument.new(args,framework.db) {|type, data| yield type,data } + else + doc = Rex::Parser::AcunetixFoundstoneDocument.new(args,self) + end + parser = ::Nokogiri::XML::SAX::Parser.new(doc) + parser.parse(args[:data]) + end + + def import_acunetix_xml(args={}, &block) + bl = validate_ips(args[:blacklist]) ? args[:blacklist].split : [] + wspace = args[:wspace] || workspace + if Rex::Parser.nokogiri_loaded + parser = "Nokogiri v#{::Nokogiri::VERSION}" + noko_args = args.dup + noko_args[:blacklist] = bl + noko_args[:wspace] = wspace + if block + yield(:parser, parser) + import_acunetix_noko_stream(noko_args) {|type, data| yield type,data} + else + import_acunetix_noko_stream(noko_args) + end + return true + else # Sorry + raise DBImportError.new("Could not import due to missing Nokogiri parser. Try 'gem install nokogiri'.") + end + end + +end \ No newline at end of file