Path: blob/master/modules/auxiliary/scanner/afp/afp_server_info.rb
19500 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45require 'English'6class MetasploitModule < Msf::Auxiliary7include Msf::Auxiliary::Report8include Msf::Auxiliary::Scanner9include Msf::Exploit::Remote::AFP1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Apple Filing Protocol Info Enumerator',16'Description' => %q{17This module fetches AFP server information, including server name,18network address, supported AFP versions, signature, machine type,19and server flags.20},21'References' => [22[ 'URL', 'https://web.archive.org/web/20130309051753/https://developer.apple.com/library/mac/#documentation/Networking/Reference/AFP_Reference/Reference/reference.html' ]23],24'Author' => [ 'Gregory Man <man.gregory[at]gmail.com>' ],25'License' => MSF_LICENSE,26'Notes' => {27'Stability' => [CRASH_SAFE],28'SideEffects' => [],29'Reliability' => []30}31)32)33end3435def run_host(ip)36print_status("AFP #{ip} Scanning...")37connect38response = get_info39report(response)40rescue ::Timeout::Error => e41vprint_error(e.message)42rescue ::Rex::ConnectionError, ::IOError, ::Errno::ECONNRESET, ::Errno::ENOPROTOOPT => e43vprint_error(e.message)44rescue ::Interrupt45raise $ERROR_INFO46rescue StandardError47print_error("AFP #{rhost}:#{rport} #{$ERROR_INFO.class} #{$ERROR_INFO}")48raise $ERROR_INFO49ensure50disconnect51end5253def report(response)54report_info = "AFP #{rhost}:#{rport} Server Name: #{response[:server_name]} \n" \55"AFP #{rhost}:#{rport} Server Flags: \n" +56format_flags_report(response[:server_flags]) +57"AFP #{rhost}:#{rport} Machine Type: #{response[:machine_type]} \n" \58"AFP #{rhost}:#{rport} AFP Versions: #{response[:versions].join(', ')} \n" \59"AFP #{rhost}:#{rport} UAMs: #{response[:uams].join(', ')}\n" \60"AFP #{rhost}:#{rport} Server Signature: #{response[:signature]}\n" \61"AFP #{rhost}:#{rport} Server Network Address: \n" +62format_addresses_report(response[:network_addresses]) +63"AFP #{rhost}:#{rport} UTF8 Server Name: #{response[:utf8_server_name]}"6465lines = "AFP #{rhost}:#{rport}:#{rport} AFP:\n#{report_info}"6667lines.split(/\n/).each do |line|68print_status(line)69end7071report_note(72host: datastore['RHOST'],73proto: 'tcp',74port: datastore['RPORT'],75type: 'afp_server_info',76data: { server_info: response }77)7879report_service(80host: datastore['RHOST'],81port: datastore['RPORT'],82proto: 'tcp',83name: 'afp',84info: "AFP name: #{response[:utf8_server_name]}, Versions: #{response[:versions].join(', ')}"85)86end8788def format_flags_report(parsed_flags)89report = ''90parsed_flags.each do |flag, val|91report << "AFP #{rhost}:#{rport} * #{flag}: #{val} \n"92end93return report94end9596def format_addresses_report(parsed_network_addresses)97report = ''98parsed_network_addresses.each do |val|99report << "AFP #{rhost}:#{rport} * #{val} \n"100end101return report102end103end104105106