Skip to content

Commit

Permalink
Add emergency.php detection #1108
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicalhack3r committed Jul 17, 2017
1 parent ca5f92c commit 79864ca
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/wpscan/wp_target.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@ def search_replace_db_2_exists?
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
Expand Down
23 changes: 23 additions & 0 deletions spec/lib/wpscan/wp_target_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,27 @@
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
4 changes: 4 additions & 0 deletions wpscan.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: ')

Expand Down

0 comments on commit 79864ca

Please sign in to comment.