Extract Msf::DBManager::Import::MBSA

MSP-11124
bug/bundler_fix
Luke Imhoff 2014-10-15 09:54:03 -05:00
parent 1edad5e0b7
commit d870188377
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8
2 changed files with 35 additions and 31 deletions

View File

@ -12,7 +12,6 @@ require 'uri'
#
require 'packetfu'
require 'rex/parser/mbsa_nokogiri'
require 'rex/parser/nessus_xml'
require 'rex/parser/netsparker_xml'
require 'rex/parser/nexpose_raw_nokogiri'
@ -36,6 +35,7 @@ module Msf::DBManager::Import
autoload :IP360, 'msf/core/db_manager/import/ip360'
autoload :IPList, 'msf/core/db_manager/import/ip_list'
autoload :Libpcap, 'msf/core/db_manager/import/libpcap'
autoload :MBSA, 'msf/core/db_manager/import/mbsa'
autoload :MsfXml, 'msf/core/db_manager/import/msf_xml'
autoload :Qualys, 'msf/core/db_manager/import/qualys'
@ -49,6 +49,7 @@ module Msf::DBManager::Import
include Msf::DBManager::Import::IP360
include Msf::DBManager::Import::IPList
include Msf::DBManager::Import::Libpcap
include Msf::DBManager::Import::MBSA
include Msf::DBManager::Import::MsfXml
include Msf::DBManager::Import::Qualys
@ -346,36 +347,6 @@ module Msf::DBManager::Import
raise DBImportError.new("Could not automatically determine file type")
end
def import_mbsa_noko_stream(args={},&block)
if block
doc = Rex::Parser::MbsaDocument.new(args,framework.db) {|type, data| yield type,data }
else
doc = Rex::Parser::MbsaDocument.new(args,self)
end
parser = ::Nokogiri::XML::SAX::Parser.new(doc)
parser.parse(args[:data])
end
def import_mbsa_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_mbsa_noko_stream(noko_args) {|type, data| yield type,data}
else
import_mbsa_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
# Imports loot, tasks, and reports from an MSF ZIP report.
# XXX: This function is stupidly long. It needs to be refactored.
def import_msf_collateral(args={}, &block)

View File

@ -0,0 +1,33 @@
require 'rex/parser/mbsa_nokogiri'
module Msf::DBManager::Import::MBSA
def import_mbsa_noko_stream(args={},&block)
if block
doc = Rex::Parser::MbsaDocument.new(args,framework.db) {|type, data| yield type,data }
else
doc = Rex::Parser::MbsaDocument.new(args,self)
end
parser = ::Nokogiri::XML::SAX::Parser.new(doc)
parser.parse(args[:data])
end
def import_mbsa_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_mbsa_noko_stream(noko_args) {|type, data| yield type,data}
else
import_mbsa_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