From 12d4e38ab1b5a5d5576c663b303cc6741bc0cadb Mon Sep 17 00:00:00 2001 From: erwanlr Date: Wed, 20 Feb 2013 15:18:37 +0100 Subject: [PATCH] Fix #131 Bug with WpTarget#wordpress? --- lib/wpscan/wp_target.rb | 2 +- spec/lib/wpscan/wp_target_spec.rb | 13 ++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/wpscan/wp_target.rb b/lib/wpscan/wp_target.rb index 59ff6432..c8c48a1e 100644 --- a/lib/wpscan/wp_target.rb +++ b/lib/wpscan/wp_target.rb @@ -59,7 +59,7 @@ class WpTarget < WebSite else response = Browser.instance.get_and_follow_location(login_url) - if response.body =~ %r{WordPress}i + if response.code == 200 && response.body =~ %r{WordPress}i wordpress = true end end diff --git a/spec/lib/wpscan/wp_target_spec.rb b/spec/lib/wpscan/wp_target_spec.rb index 6b8149e1..45ddf4c4 100644 --- a/spec/lib/wpscan/wp_target_spec.rb +++ b/spec/lib/wpscan/wp_target_spec.rb @@ -21,6 +21,7 @@ require File.expand_path(File.dirname(__FILE__) + '/wpscan_helper') describe WpTarget do let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR } + let(:target_url) { 'http://example.localhost/' } before :each do Browser.reset @@ -31,7 +32,7 @@ describe WpTarget do wp_content_dir: 'wp-content', wp_plugins_dir: 'wp-content/plugins' } - @wp_target = WpTarget.new('http://example.localhost/', @options) + @wp_target = WpTarget.new(target_url, @options) end it_should_behave_like 'WpReadme' @@ -108,6 +109,16 @@ describe WpTarget do it 'should return false if both files are not found (404)' do @wp_target.should_not be_wordpress end + + context 'when the url contains "wordpress" and is a 404' do + let(:target_url) { 'http://lamp/wordpress-3.5./' } + + it 'returns false' do + stub_request(:get, @wp_target.login_url).to_return(status: 404, body: 'The requested URL /wordpress-3.5. was not found on this server.') + + @wp_target.should_not be_wordpress + end + end end describe '#redirection' do