Skip to content

Commit 403696d

Browse files
Lands rapid7#6730 Modify the open_vas importer and the nessus importer
2 parents d3eaae3 + 5e8ed09 commit 403696d

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

lib/msf/core/db_manager/import.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,9 @@ def import_filetype_detect(data)
254254
elsif (firstline.index("<scanJob>"))
255255
@import_filedata[:type] = "Retina XML"
256256
return :retina_xml
257+
elsif (firstline.index(/<get_results_response status=['"]200['"] status_text=['"]OK['"]>/))
258+
@import_filedata[:type] = "OpenVAS XML"
259+
return :openvas_new_xml
257260
elsif (firstline.index(/<get_reports_response status=['"]200['"] status_text=['"]OK['"]>/))
258261
@import_filedata[:type] = "OpenVAS XML"
259262
return :openvas_new_xml
@@ -286,7 +289,7 @@ def import_filetype_detect(data)
286289
@import_filedata[:type] = "Nmap XML"
287290
return :nmap_xml
288291
when "openvas-report"
289-
@import_filedata[:type] = "OpenVAS Report"
292+
@import_filedata[:type] = "OpenVAS"
290293
return :openvas_xml
291294
when "NessusClientData"
292295
@import_filedata[:type] = "Nessus XML (v1)"

lib/msf/core/db_manager/import/nessus.rb

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,22 @@ module Msf::DBManager::Import::Nessus
1212
# Nessus NBE and NESSUS v1 methods
1313
#
1414
def handle_nessus(wspace, hobj, port, nasl, plugin_name, severity, data,task=nil)
15+
1516
addr = hobj.address
1617
# The port section looks like:
1718
# http (80/tcp)
1819
p = port.match(/^([^\(]+)\((\d+)\/([^\)]+)\)/)
19-
return if not p
2020

21-
# Unnecessary as the caller should already have reported this host
22-
#report_host(:workspace => wspace, :host => addr, :state => Msf::HostState::Alive)
23-
name = p[1].strip
24-
port = p[2].to_i
25-
proto = p[3].downcase
21+
if p
22+
name = p[1].strip
23+
port = p[2].to_i
24+
proto = p[3].downcase
25+
else
26+
port = nil
27+
end
2628

2729
info = { :workspace => wspace, :host => hobj, :port => port, :proto => proto, :task => task }
28-
if name != "unknown" and name[-1,1] != "?"
30+
if name and name != "unknown" and name[-1,1] != "?"
2931
info[:name] = name
3032
end
3133
report_service(info)

lib/msf/core/db_manager/import/open_vas.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ def import_openvas_xml(args={}, &block)
2929
filename = args[:filename]
3030
wspace = args[:wspace] || workspace
3131

32-
raise Msf::DBImportError.new("No OpenVAS XML support. Please submit a patch to msfdev[at]metasploit.com")
32+
raise Msf::DBImportError.new("No OpenVas XML support. Please submit a patch to msfdev[at]metasploit.com")
3333
end
3434
end

lib/rex/parser/openvas_nokogiri.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
module Rex
55
module Parser
66

7-
# If Nokogiri is available, define OpenVAS document class.
7+
# If Nokogiri is available, define OpenVas document class.
88
load_nokogiri && class OpenVASDocument < Nokogiri::XML::SAX::Document
99

1010
include NokogiriDocMixin
@@ -37,8 +37,10 @@ def end_element(name=nil)
3737
@state[:vuln_name] = @text.strip if @text
3838
end
3939
when 'description'
40-
@state[:has_text] = true
41-
@state[:vuln_desc] = @text.strip if @text
40+
if in_tag('result')
41+
@state[:has_text] = true
42+
@state[:vuln_desc] = @text.strip if @text
43+
end
4244
when 'bid'
4345
if in_tag('result') && in_tag('nvt')
4446
@state[:has_text] = true
@@ -62,7 +64,7 @@ def end_element(name=nil)
6264
when 'subnet'
6365
@state[:has_text] = true
6466
when 'result'
65-
record_vuln if in_tag('results')
67+
record_vuln
6668
when 'threat'
6769
@state[:has_text] = true if in_tag('ports') && in_tag('port')
6870
when 'host'

0 commit comments

Comments
 (0)