Add emergency.php detection #1108
This commit is contained in:
@@ -155,6 +155,21 @@ class WpTarget < WebSite
|
||||
resp.code == 200 && resp.body[%r{by interconnect}i]
|
||||
end
|
||||
|
||||
# Script used to recover locked out admin users
|
||||
# http://yoast.com/emergency-wordpress-access/
|
||||
# https://codex.wordpress.org/User:MichaelH/Orphaned_Plugins_needing_Adoption/Emergency
|
||||
#
|
||||
# @return [ String ]
|
||||
def emergency_url
|
||||
@uri.merge('emergency.php').to_s
|
||||
end
|
||||
|
||||
# @return [ Boolean ]
|
||||
def emergency_exists?
|
||||
resp = Browser.get(emergency_url)
|
||||
resp.code == 200 && resp.body[%r{password}i]
|
||||
end
|
||||
|
||||
def upload_directory_listing_enabled?
|
||||
directory_listing_enabled?(upload_dir_url)
|
||||
end
|
||||
|
||||
@@ -192,4 +192,27 @@ describe WpTarget do
|
||||
end
|
||||
end
|
||||
|
||||
describe '#emergency_url' do
|
||||
it 'returns the correct url' do
|
||||
expect(wp_target.emergency_url).to eq 'http://example.localhost/emergency.php'
|
||||
end
|
||||
end
|
||||
|
||||
describe '#emergency_exists?' do
|
||||
it 'returns true' do
|
||||
stub_request(:any, wp_target.emergency_url).to_return(status: 200, body: 'enter your password here')
|
||||
expect(wp_target.emergency_exists?).to be_truthy
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
stub_request(:any, wp_target.emergency_url).to_return(status: 500)
|
||||
expect(wp_target.emergency_exists?).to be_falsey
|
||||
end
|
||||
|
||||
it 'returns false' do
|
||||
stub_request(:any, wp_target.emergency_url).to_return(status: 500, body: 'enter your password here')
|
||||
expect(wp_target.emergency_exists?).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -226,6 +226,10 @@ def main
|
||||
puts critical("searchreplacedb2.php has been found in: '#{wp_target.search_replace_db_2_url}'")
|
||||
end
|
||||
|
||||
if wp_target.emergency_exists?
|
||||
puts critical("emergency.php has been found in: '#{wp_target.emergency_url}'")
|
||||
end
|
||||
|
||||
wp_target.interesting_headers.each do |header|
|
||||
output = info('Interesting header: ')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user