Merge branch 'json_data'

Conflicts:
	data/plugin_vulns.xml
	data/theme_vulns.xml
This commit is contained in:
ethicalhack3r
2014-08-01 13:34:34 +02:00
50 changed files with 560 additions and 23055 deletions

View File

@@ -35,27 +35,23 @@ class Vulnerability
end
# :nocov:
# Create the Vulnerability from the xml_node
# Create the Vulnerability from the json_item
#
# @param [ Nokogiri::XML::Node ] xml_node
# @param [ Hash ] json_item
#
# @return [ Vulnerability ]
def self.load_from_xml_node(xml_node)
def self.load_from_json_item(json_item)
references = {}
refs = xml_node.search('references')
if refs
references[:url] = refs.search('url').map(&:text)
references[:cve] = refs.search('cve').map(&:text)
references[:secunia] = refs.search('secunia').map(&:text)
references[:osvdb] = refs.search('osvdb').map(&:text)
references[:metasploit] = refs.search('metasploit').map(&:text)
references[:exploitdb] = refs.search('exploitdb').map(&:text)
[:url, :cve, :secunia, :osvdb, :metasploit, :exploitdb].each do |key|
references[key] = json_item[key.to_s].split(',') if json_item[key.to_s]
end
new(
xml_node.search('title').text,
xml_node.search('type').text,
json_item['title'],
json_item['type'],
references,
xml_node.search('fixed_in').text,
json_item['fixed_in'],
)
end

View File

@@ -14,7 +14,7 @@ class Vulnerability
puts " Reference: #{url}" if url
end
end
if !fixed_in.empty?
if !fixed_in.nil?
puts "#{blue('[i]')} Fixed in: #{fixed_in}"
end
end

View File

@@ -2,22 +2,27 @@
class WpItem
module Vulnerable
attr_accessor :vulns_file, :vulns_xpath
attr_accessor :vulns_file, :identifier
# Get the vulnerabilities associated to the WpItem
# Filters out already fixed vulnerabilities
#
# @return [ Vulnerabilities ]
def vulnerabilities
xml = xml(vulns_file)
json = json(vulns_file)
vulnerabilities = Vulnerabilities.new
xml.xpath(vulns_xpath).each do |node|
vuln = Vulnerability.load_from_xml_node(node)
if vulnerable_to?(vuln)
vulnerabilities << vuln
json.each do |item|
asset = item[identifier]
if asset
asset['vulnerabilities'].each do |vulnerability|
vulnerability = Vulnerability.load_from_json_item(vulnerability)
vulnerabilities << vulnerability if vulnerable_to?(vulnerability)
end
end
end
vulnerabilities
end
@@ -41,5 +46,4 @@ class WpItem
return false
end
end
end

View File

@@ -12,8 +12,8 @@ class WpPlugin < WpItem
end
# @return [ String ]
def vulns_xpath
"//plugin[@name='#{@name}']/vulnerability"
def identifier
@name
end
end

View File

@@ -12,9 +12,8 @@ class WpTheme < WpItem
end
# @return [ String ]
def vulns_xpath
"//theme[@name='#{@name}']/vulnerability"
def identifier
@name
end
end
end

View File

@@ -12,9 +12,14 @@ class WpVersion < WpItem
end
# @return [ String ]
def vulns_xpath
"//wordpress[@version='#{@number}']/vulnerability"
end
def identifier
@number
end
# @return [ String ]
# def vulns_xpath
# "//wordpress[@version='#{@number}']/vulnerability"
# end
end
end