|
| 1 | +## |
| 2 | +# This module requires Metasploit: https://metasploit.com/download |
| 3 | +# Current source: https://github.com/rapid7/metasploit-framework |
| 4 | +## |
| 5 | + |
| 6 | +require 'metasploit/framework/login_scanner/base' |
| 7 | +require 'metasploit/framework/credential_collection' |
| 8 | + |
| 9 | +class MetasploitModule < Msf::Auxiliary |
| 10 | + include Msf::Auxiliary::Scanner |
| 11 | + include Msf::Auxiliary::Report |
| 12 | + include Msf::Auxiliary::AuthBrute |
| 13 | + |
| 14 | + def initialize |
| 15 | + super( |
| 16 | + 'Name' => 'Test Login Scanner', |
| 17 | + 'Description' => %q{ |
| 18 | + Use this module to test how credentials are generated for login scanners. |
| 19 | + }, |
| 20 | + 'Author' => [ |
| 21 | + 'Spencer McIntyre' |
| 22 | + ], |
| 23 | + 'References' => [ |
| 24 | + [ 'CVE', '1999-0506'], # Weak password |
| 25 | + ], |
| 26 | + 'DefaultOptions' => { 'RHOSTS' => '192.0.2.1' }, |
| 27 | + 'License' => MSF_LICENSE |
| 28 | + ) |
| 29 | + end |
| 30 | + |
| 31 | + def run_host(ip) |
| 32 | + print_brute(level: :vstatus, ip: ip, msg: 'Starting login bruteforce') |
| 33 | + |
| 34 | + @scanner = TestLoginScanner.new( |
| 35 | + host: ip, |
| 36 | + port: 80, |
| 37 | + stop_on_success: datastore['STOP_ON_SUCCESS'], |
| 38 | + proxies: datastore['Proxies'], |
| 39 | + bruteforce_speed: datastore['BRUTEFORCE_SPEED'], |
| 40 | + framework: framework, |
| 41 | + framework_module: self |
| 42 | + ) |
| 43 | + |
| 44 | + cred_collection = build_credential_collection( |
| 45 | + username: datastore['USERNAME'], |
| 46 | + password: datastore['PASSWORD'] |
| 47 | + ) |
| 48 | + cred_collection = prepend_db_hashes(cred_collection) |
| 49 | + |
| 50 | + @scanner.cred_details = cred_collection |
| 51 | + |
| 52 | + @scanner.each_credential do |credential| |
| 53 | + print_status("username: #{credential.public.inspect}, password: #{credential.private.inspect}") |
| 54 | + end |
| 55 | + end |
| 56 | + |
| 57 | + class TestLoginScanner |
| 58 | + include Metasploit::Framework::LoginScanner::Base |
| 59 | + |
| 60 | + REALM_KEY = nil |
| 61 | + |
| 62 | + def attempt_login(credential) |
| 63 | + ::Metasploit::Framework::LoginScanner::Result.new( |
| 64 | + host: host, |
| 65 | + port: port, |
| 66 | + protocol: 'tcp', |
| 67 | + credential: credential, |
| 68 | + status: Metasploit::Model::Login::Status::SUCCESSFUL |
| 69 | + ) |
| 70 | + end |
| 71 | + end |
| 72 | +end |
0 commit comments