From 7d2b8a2a8bdcce79aec40939552e45943d88db55 Mon Sep 17 00:00:00 2001 From: erwanlr Date: Wed, 12 Feb 2020 19:50:00 +0000 Subject: [PATCH] Reduces time to detect non WP sites when there are a lof of links in pages --- app/controllers/custom_directories.rb | 4 +--- lib/wpscan/target/platform/wordpress.rb | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/controllers/custom_directories.rb b/app/controllers/custom_directories.rb index ffffbb7c..a8634dc6 100644 --- a/app/controllers/custom_directories.rb +++ b/app/controllers/custom_directories.rb @@ -18,9 +18,7 @@ module WPScan target.content_dir = ParsedCli.wp_content_dir if ParsedCli.wp_content_dir target.plugins_dir = ParsedCli.wp_plugins_dir if ParsedCli.wp_plugins_dir - return if target.content_dir - - raise Error::WpContentDirNotDetected + raise Error::WpContentDirNotDetected unless target.content_dir end end end diff --git a/lib/wpscan/target/platform/wordpress.rb b/lib/wpscan/target/platform/wordpress.rb index dbb41bc9..df7d621f 100644 --- a/lib/wpscan/target/platform/wordpress.rb +++ b/lib/wpscan/target/platform/wordpress.rb @@ -44,7 +44,7 @@ module WPScan # @param [ Typhoeus::Response ] response # @return [ Boolean ] def wordpress_from_meta_comments_or_scripts?(response) - in_scope_uris(response) do |uri| + in_scope_uris(response, '//link/@href|//script/@src|//img/@src') do |uri| return true if WORDPRESS_PATTERN.match?(uri.path) || WP_JSON_OEMBED_PATTERN.match?(uri.path) end @@ -100,8 +100,9 @@ module WPScan unless content_dir pattern = %r{https?://s\d\.wp\.com#{WORDPRESS_PATTERN}}i.freeze + xpath = '//@href[contains(., "wp.com")]|//@src[contains(., "wp.com")]' - uris_from_page(homepage_res) do |uri| + uris_from_page(homepage_res, xpath) do |uri| return true if uri.to_s.match?(pattern) end end