diff --git a/lib/wpscan/modules/web_site.rb b/lib/wpscan/modules/web_site.rb index f906f216..ad266525 100644 --- a/lib/wpscan/modules/web_site.rb +++ b/lib/wpscan/modules/web_site.rb @@ -18,6 +18,8 @@ module WebSite + #@error_404_hash = nil + # Checks if the remote website is up. def online? Browser.instance.get(@uri.to_s).code != 0 @@ -83,4 +85,17 @@ module WebSite redirection end + + # Return the MD5 hash of a 404 page + def error_404_hash + unless @error_404_hash + non_existant_page = Digest::MD5.hexdigest(rand(9999999999).to_s) + ".html" + + response = Browser.instance.get(@uri.merge(non_existant_page).to_s) + + @error_404_hash = Digest::MD5.hexdigest(response.body) + end + + @error_404_hash + end end diff --git a/lib/wpscan/wp_target.rb b/lib/wpscan/wp_target.rb index 214e6c74..082a25d6 100644 --- a/lib/wpscan/wp_target.rb +++ b/lib/wpscan/wp_target.rb @@ -29,8 +29,6 @@ class WpTarget include WpThemes include BruteForce - @error_404_hash = nil - attr_reader :uri, :verbose def initialize(target_url, options = {}) @@ -60,19 +58,6 @@ class WpTarget url end - # Return the MD5 hash of a 404 page - def error_404_hash - unless @error_404_hash - non_existant_page = Digest::MD5.hexdigest(rand(9999999999).to_s) + ".html" - - response = Browser.instance.get(@uri.merge(non_existant_page).to_s) - - @error_404_hash = Digest::MD5.hexdigest(response.body) - end - - @error_404_hash - end - # Valid HTTP return codes def self.valid_response_codes [200, 301, 302, 401, 403, 500] diff --git a/spec/lib/wpscan/modules/web_site_spec.rb b/spec/lib/wpscan/modules/web_site_spec.rb index 5aac90a2..067cfbc0 100644 --- a/spec/lib/wpscan/modules/web_site_spec.rb +++ b/spec/lib/wpscan/modules/web_site_spec.rb @@ -120,4 +120,12 @@ shared_examples_for "WebSite" do end end + describe "#error_404_hash" do + it "should return the md5sum of the 404 page" do + stub_request(:any, /.*/). + to_return(:status => 404, :body => "404 page !") + + web_site.error_404_hash.should === Digest::MD5.hexdigest("404 page !") + end + end end diff --git a/spec/lib/wpscan/wp_target_spec.rb b/spec/lib/wpscan/wp_target_spec.rb index 0792e92a..cf1bc743 100644 --- a/spec/lib/wpscan/wp_target_spec.rb +++ b/spec/lib/wpscan/wp_target_spec.rb @@ -83,15 +83,6 @@ describe WpTarget do end end - describe "#error_404_hash" do - it "should return the md5sum of the 404 page" do - stub_request(:any, /.*/). - to_return(:status => 404, :body => "404 page !") - - @wp_target.error_404_hash.should === Digest::MD5.hexdigest("404 page !") - end - end - describe "#wp_content_dir" do let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + "/wp_content_dir" }