WpTarget.error_404_hash moved to WebSite module
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
module WebSite
|
module WebSite
|
||||||
|
|
||||||
|
#@error_404_hash = nil
|
||||||
|
|
||||||
# Checks if the remote website is up.
|
# Checks if the remote website is up.
|
||||||
def online?
|
def online?
|
||||||
Browser.instance.get(@uri.to_s).code != 0
|
Browser.instance.get(@uri.to_s).code != 0
|
||||||
@@ -83,4 +85,17 @@ module WebSite
|
|||||||
|
|
||||||
redirection
|
redirection
|
||||||
end
|
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
|
end
|
||||||
|
|||||||
@@ -29,8 +29,6 @@ class WpTarget
|
|||||||
include WpThemes
|
include WpThemes
|
||||||
include BruteForce
|
include BruteForce
|
||||||
|
|
||||||
@error_404_hash = nil
|
|
||||||
|
|
||||||
attr_reader :uri, :verbose
|
attr_reader :uri, :verbose
|
||||||
|
|
||||||
def initialize(target_url, options = {})
|
def initialize(target_url, options = {})
|
||||||
@@ -60,19 +58,6 @@ class WpTarget
|
|||||||
url
|
url
|
||||||
end
|
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
|
# Valid HTTP return codes
|
||||||
def self.valid_response_codes
|
def self.valid_response_codes
|
||||||
[200, 301, 302, 401, 403, 500]
|
[200, 301, 302, 401, 403, 500]
|
||||||
|
|||||||
@@ -120,4 +120,12 @@ shared_examples_for "WebSite" do
|
|||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|||||||
@@ -83,15 +83,6 @@ describe WpTarget do
|
|||||||
end
|
end
|
||||||
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
|
describe "#wp_content_dir" do
|
||||||
let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + "/wp_content_dir" }
|
let(:fixtures_dir) { SPEC_FIXTURES_WPSCAN_WP_TARGET_DIR + "/wp_content_dir" }
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user