2013-08-21 10:45:15 +00:00
|
|
|
# -*- coding: binary -*-
|
|
|
|
|
2013-08-22 15:33:35 +00:00
|
|
|
module Msf::HTTP::Wordpress::Base
|
2013-09-05 19:11:03 +00:00
|
|
|
# Checks if the site is online and running wordpress
|
|
|
|
#
|
|
|
|
# @return [Rex::Proto::Http::Response,nil] Returns the HTTP response if the site is online and running wordpress, nil otherwise
|
|
|
|
def wordpress_and_online?
|
2015-01-30 16:26:23 +00:00
|
|
|
wordpress_detect_regexes = [
|
|
|
|
/["'][^"']*\/#{Regexp.escape(wp_content_dir)}\/[^"']*["']/i,
|
|
|
|
/<link rel=["']wlwmanifest["'].*href=["'].*\/wp-includes\/wlwmanifest\.xml["'] \/>/i,
|
|
|
|
/<link rel=["']pingback["'].*href=["'].*\/xmlrpc\.php["'](?: \/)*>/i
|
|
|
|
]
|
|
|
|
|
2014-07-22 15:02:35 +00:00
|
|
|
res = send_request_cgi(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => normalize_uri(target_uri.path)
|
|
|
|
)
|
2015-01-30 16:26:23 +00:00
|
|
|
|
|
|
|
# handle one redirect
|
|
|
|
if res && res.redirect? && res.redirection
|
|
|
|
res = send_request_cgi(
|
|
|
|
'method' => 'GET',
|
|
|
|
'uri' => path_from_uri(res.redirection)
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2014-07-22 17:49:58 +00:00
|
|
|
return res if res && res.code == 200 && res.body && wordpress_detect_regexes.any? { |r| res.body =~ r }
|
2014-07-22 15:02:35 +00:00
|
|
|
return nil
|
2014-07-22 17:49:58 +00:00
|
|
|
rescue ::Rex::ConnectionRefused, ::Rex::HostUnreachable, ::Rex::ConnectionTimeout => e
|
|
|
|
print_error("#{peer} - Error connecting to #{target_uri}: #{e}")
|
2014-07-22 15:02:35 +00:00
|
|
|
return nil
|
2013-09-05 19:11:03 +00:00
|
|
|
end
|
2013-08-21 10:45:15 +00:00
|
|
|
end
|