diff --git a/lib/common/collections/wp_items/detectable.rb b/lib/common/collections/wp_items/detectable.rb index cf7fe64e..db76c952 100755 --- a/lib/common/collections/wp_items/detectable.rb +++ b/lib/common/collections/wp_items/detectable.rb @@ -102,6 +102,7 @@ class WpItems < Array vulns_file: self.vulns_file } end + # The default request parameters # # @return [ Hash ] diff --git a/lib/common/collections/wp_plugins/detectable.rb b/lib/common/collections/wp_plugins/detectable.rb index 5ea4aa6c..0f8580ac 100644 --- a/lib/common/collections/wp_plugins/detectable.rb +++ b/lib/common/collections/wp_plugins/detectable.rb @@ -23,50 +23,54 @@ class WpPlugins < WpItems detected += from_header(wp_target) detected += from_content(wp_target) - detected.sort.uniq! + detected.uniq! { |i| i.name } detected end protected # 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 ] def from_header(wp_target) + headers = Browser.get(wp_target.url).headers wp_plugins = WpPlugins.new - response = Browser.get(wp_target.url) - if response.headers && powered_by = response.headers[:x_powered_by] - if powered_by =~ /W3 Total Cache\/([^0-9.]+)/i - wp_plugins << WpPlugin.new( - wp_target.uri, - self.item_options(wp_target).merge(name: 'w3-total-cache', version: $1) - ) + if headers + powered_by = headers[:x_powered_by] + wp_super_cache = headers['wp-super-cache'] + + 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 + wp_plugins end # #