From 2c4069921b196b236d167b33c458a7d5073063b7 Mon Sep 17 00:00:00 2001 From: Christian Mehlmauer Date: Thu, 20 Sep 2012 17:26:42 +0200 Subject: [PATCH] wp-content directory detection --- lib/wpscan/wp_target.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/wpscan/wp_target.rb b/lib/wpscan/wp_target.rb index 3cab4102..9059df2c 100644 --- a/lib/wpscan/wp_target.rb +++ b/lib/wpscan/wp_target.rb @@ -90,15 +90,13 @@ class WpTarget def wp_content_dir unless @wp_content_dir index_body = Browser.instance.get(@uri.to_s).body + # Only use the path because domain can be text or an ip + uri_path = @uri.path - if index_body[%r{#@uri/?wp-content/(?:themes|plugins)/}i] + if index_body[/#{uri_path}\/wp-content\/(?:themes|plugins)\//i] @wp_content_dir = "wp-content" else - @wp_content_dir = index_body[%r{(?:href|src)=(?:"|')#@uri/?([^"']+)/(?:themes|plugins)/.*(?:"|')}i, 1] - # Bug: Some themes and plugins render incorrect with custom wp-content dir, so only take the first folder - # Exmaple: - # /wordpress/wp-custom/plugins/usr/share/wordpress/wp-content/plugins/contact-form-7/includes/js/jquery.form.js? - @wp_content_dir = @wp_content_dir[%r{([^/]+).*}i, 1] + @wp_content_dir = index_body[/(?:href|src)\s*=\s*(?:"|').+#{uri_path}([^"']+)\/(?:themes|plugins)\/.*(?:"|')/i, 1] end end @wp_content_dir