-) Check if userregistration is enabled

-) Check if blog is a multisite
This commit is contained in:
Christian Mehlmauer
2012-09-24 20:46:26 +02:00
parent fe1191a51e
commit 2e4a622cec
3 changed files with 73 additions and 4 deletions

View File

@@ -137,11 +137,33 @@ class WpTarget
# Should check wp-login.php if registration is enabled or not # Should check wp-login.php if registration is enabled or not
def registration_enabled? def registration_enabled?
# TODO resp = Browser.instance.get(registration_url)
if resp.code == 302 and resp.headers_hash["location"] =~ /wp-login\.php\?registration=disabled/
enabled = false
else
enabled = true
end
enabled
end end
def registration_url def registration_url
# TODO @uri.merge("wp-login.php?action=register")
end end
def is_multisite?
# when multisite, there is no redirection or a redirect to the site itself
# otherwise redirect to wp-login.php
url = @uri.merge("wp-signup.php")
resp = Browser.instance.get(url)
if resp.code == 302 and resp.headers_hash["location"] =~ /wp-login\.php\?action=register/
multisite = false
elsif resp.code == 302 and resp.headers_hash["location"] =~ /wp-signup\.php/
multisite = true
elsif resp.code == 200
multisite = true
else
multisite = false
end
multisite
end
end end

View File

@@ -244,4 +244,43 @@ describe WpTarget do
@wp_target.search_replace_db_2_exists?.should be_false @wp_target.search_replace_db_2_exists?.should be_false
end end
end end
describe "#registration_url" do
it "should return the correct url" do
@wp_target.registration_url.to_s.should == "http://example.localhost/wp-login.php?action=register"
end
end
describe "#registration_enabled?" do
it "should return false" do
stub_request(:any, @wp_target.registration_url.to_s).to_return(:status => 302, :headers => { "Location" => "wp-login.php?registration=disabled" })
@wp_target.registration_enabled?.should be_false
end
it "should return true" do
stub_request(:any, @wp_target.registration_url.to_s).to_return(:status => 200)
@wp_target.registration_enabled?.should be_true
end
end
describe "#is_multisite?" do
before :each do
@url = @wp_target.uri.merge("wp-signup.php").to_s
end
it "should return false" do
stub_request(:any, @url).to_return(:status => 302, :headers => { "Location" => "wp-login.php?action=register" })
@wp_target.is_multisite?.should be_false
end
it "should return true" do
stub_request(:any, @url).to_return(:status => 302, :headers => { "Location" => "http://example.localhost/wp-signup.php" })
@wp_target.is_multisite?.should be_true
end
it "should return true" do
stub_request(:any, @url).to_return(:status => 200)
@wp_target.is_multisite?.should be_true
end
end
end end

View File

@@ -101,11 +101,11 @@ begin
wp_theme = wp_target.theme wp_theme = wp_target.theme
if wp_theme if wp_theme
# Theme version is handled in wp_item.to_s # Theme version is handled in wp_item.to_s
puts green("[!]") + " The WordPress theme in use is #{wp_theme}" puts green("[+]") + " The WordPress theme in use is #{wp_theme}"
theme_vulnerabilities = wp_theme.vulnerabilities theme_vulnerabilities = wp_theme.vulnerabilities
unless theme_vulnerabilities.empty? unless theme_vulnerabilities.empty?
puts red("[+]") + " We have identified #{theme_vulnerabilities.size} vulnerabilities for this theme :" puts red("[!]") + " We have identified #{theme_vulnerabilities.size} vulnerabilities for this theme :"
theme_vulnerabilities.each do |vulnerability| theme_vulnerabilities.each do |vulnerability|
puts puts
puts " | " + red("* Title: #{vulnerability.title}") puts " | " + red("* Title: #{vulnerability.title}")
@@ -135,6 +135,14 @@ begin
puts red("[!] searchreplacedb2.php has been found '#{wp_target.search_replace_db_2_url}'") puts red("[!] searchreplacedb2.php has been found '#{wp_target.search_replace_db_2_url}'")
end end
if wp_target.is_multisite?
puts green("[+]") + " This site seems to be a multisite (http://codex.wordpress.org/Glossary#Multisite)"
end
if wp_target.registration_enabled?
puts green("[+]") + " Userregistration is enabled"
end
if wp_target.has_malwares? if wp_target.has_malwares?
malwares = wp_target.malwares malwares = wp_target.malwares
puts red("[!]") + " #{malwares.size} malware(s) found :" puts red("[!]") + " #{malwares.size} malware(s) found :"