Ref #177 wp-super-cache detected from header

This commit is contained in:
erwanlr
2013-05-06 15:35:15 +02:00
parent 7a963e346a
commit b06dcf555e
2 changed files with 19 additions and 14 deletions

View File

@@ -102,6 +102,7 @@ class WpItems < Array
vulns_file: self.vulns_file vulns_file: self.vulns_file
} }
end end
# The default request parameters # The default request parameters
# #
# @return [ Hash ] # @return [ Hash ]

View File

@@ -23,50 +23,54 @@ class WpPlugins < WpItems
detected += from_header(wp_target) detected += from_header(wp_target)
detected += from_content(wp_target) detected += from_content(wp_target)
detected.sort.uniq! detected.uniq! { |i| i.name }
detected detected
end end
protected protected
# X-Powered-By: W3 Total Cache/0.9.2.5 # X-Powered-By: W3 Total Cache/0.9.2.5
# @param [ Typhoeus::Response ] response # WP-Super-Cache: Served supercache file from PHP
# @param [ WpTarget ] wp_target
# #
# @return [ WpPlugins ] # @return [ WpPlugins ]
def from_header(wp_target) def from_header(wp_target)
headers = Browser.get(wp_target.url).headers
wp_plugins = WpPlugins.new wp_plugins = WpPlugins.new
response = Browser.get(wp_target.url)
if response.headers && powered_by = response.headers[:x_powered_by] if headers
if powered_by =~ /W3 Total Cache\/([^0-9.]+)/i powered_by = headers[:x_powered_by]
wp_plugins << WpPlugin.new( wp_super_cache = headers['wp-super-cache']
wp_target.uri,
self.item_options(wp_target).merge(name: 'w3-total-cache', version: $1) if powered_by =~ /W3 Total Cache/i
) wp_plugins << create_item(WpPlugin, 'w3-total-cache', wp_target)
end
if wp_super_cache =~ /supercache/i
wp_plugins << create_item(WpPlugin, 'wp-super-cache', wp_target)
end end
end end
wp_plugins wp_plugins
end end
# <!-- Cached page generated by WP-Super-Cache on 2013-05-03 14:46:37 --> # <!-- Cached page generated by WP-Super-Cache on 2013-05-03 14:46:37 -->
# <!-- Performance optimized by W3 Total Cache. # <!-- Performance optimized by W3 Total Cache.
# @param [ Typhoeus::Response ] response # @param [ WpTarget ] wp_target
# #
# @return [ WpPlugins ] # @return [ WpPlugins ]
def from_content(wp_target) def from_content(wp_target)
body = Browser.get(wp_target.url).body body = Browser.get(wp_target.url).body
wp_plugins = WpPlugins.new wp_plugins = WpPlugins.new
options = self.item_options(wp_target)
if body =~ /wp-super-cache/i if body =~ /wp-super-cache/i
wp_plugins << WpPlugin.new(wp_target.uri, options.merge(name: 'wp-super-cache')) wp_plugins << create_item(WpPlugin, 'wp-super-cache', wp_target)
end end
if body =~ /w3 total cache/i if body =~ /w3 total cache/i
wp_plugins << WpPlugin.new(wp_target.uri, options.merge(name: 'w3-total-cache')) wp_plugins << create_item(WpPlugin, 'w3-total-cache', wp_target)
end end
wp_plugins.uniq!
wp_plugins wp_plugins
end end