2012-03-02 19:58:40 +00:00
|
|
|
##
|
2014-10-17 16:47:33 +00:00
|
|
|
# This module requires Metasploit: http://metasploit.com/download
|
2013-10-15 18:50:46 +00:00
|
|
|
# Current source: https://github.com/rapid7/metasploit-framework
|
2012-03-02 19:58:40 +00:00
|
|
|
##
|
|
|
|
|
|
|
|
require 'msf/core'
|
|
|
|
|
|
|
|
class Metasploit3 < Msf::Auxiliary
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
include Msf::Auxiliary::Report
|
|
|
|
include Msf::Auxiliary::Scanner
|
|
|
|
include Msf::Exploit::Remote::AFP
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def initialize(info={})
|
|
|
|
super(update_info(info,
|
|
|
|
'Name' => 'Apple Filing Protocol Info Enumerator',
|
|
|
|
'Description' => %q{
|
|
|
|
This module fetches AFP server information, including server name,
|
|
|
|
network address, supported AFP versions, signature, machine type,
|
|
|
|
and server flags.
|
|
|
|
},
|
|
|
|
'References' =>
|
|
|
|
[
|
2015-04-03 11:12:23 +00:00
|
|
|
[ 'URL', 'https://developer.apple.com/library/mac/documentation/Networking/Reference/AFP_Reference/Reference/reference.html' ]
|
2013-08-30 21:28:54 +00:00
|
|
|
],
|
|
|
|
'Author' => [ 'Gregory Man <man.gregory[at]gmail.com>' ],
|
|
|
|
'License' => MSF_LICENSE
|
|
|
|
))
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
deregister_options('RHOST')
|
|
|
|
end
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def run_host(ip)
|
|
|
|
print_status("AFP #{ip} Scanning...")
|
|
|
|
begin
|
|
|
|
connect
|
|
|
|
response = get_info
|
|
|
|
report(response)
|
|
|
|
rescue ::Timeout::Error
|
|
|
|
rescue ::Interrupt
|
|
|
|
raise $!
|
|
|
|
rescue ::Rex::ConnectionError, ::IOError, ::Errno::ECONNRESET, ::Errno::ENOPROTOOPT
|
|
|
|
rescue ::Exception
|
|
|
|
raise $!
|
|
|
|
print_error("AFP #{rhost}:#{rport} #{$!.class} #{$!}")
|
|
|
|
ensure
|
|
|
|
disconnect
|
|
|
|
end
|
|
|
|
end
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def report(response)
|
|
|
|
report_info = "AFP #{rhost}:#{rport} Server Name: #{response[:server_name]} \n" +
|
|
|
|
"AFP #{rhost}:#{rport} Server Flags: \n" +
|
|
|
|
format_flags_report(response[:server_flags]) +
|
|
|
|
"AFP #{rhost}:#{rport} Machine Type: #{response[:machine_type]} \n" +
|
|
|
|
"AFP #{rhost}:#{rport} AFP Versions: #{response[:versions].join(', ')} \n" +
|
|
|
|
"AFP #{rhost}:#{rport} UAMs: #{response[:uams].join(', ')}\n" +
|
|
|
|
"AFP #{rhost}:#{rport} Server Signature: #{response[:signature]}\n" +
|
|
|
|
"AFP #{rhost}:#{rport} Server Network Address: \n" +
|
|
|
|
format_addresses_report(response[:network_addresses]) +
|
|
|
|
"AFP #{rhost}:#{rport} UTF8 Server Name: #{response[:utf8_server_name]}"
|
2012-07-17 05:42:49 +00:00
|
|
|
|
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
lines = "AFP #{rhost}:#{rport}:#{rport} AFP:\n#{report_info}"
|
2012-07-17 05:42:49 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
lines.split(/\n/).each do |line|
|
|
|
|
print_status(line)
|
|
|
|
end
|
2012-03-06 16:22:38 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
report_note(:host => datastore['RHOST'],
|
|
|
|
:proto => 'tcp',
|
|
|
|
:port => datastore['RPORT'],
|
|
|
|
:type => 'afp_server_info',
|
|
|
|
:data => response)
|
2012-03-13 07:52:30 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
report_service(
|
|
|
|
:host => datastore['RHOST'],
|
|
|
|
:port => datastore['RPORT'],
|
|
|
|
:proto => 'tcp',
|
|
|
|
:name => "afp",
|
|
|
|
:info => "AFP name: #{response[:utf8_server_name]}, Versions: #{response[:versions].join(', ')}"
|
|
|
|
)
|
2012-03-13 07:52:30 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
end
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def format_flags_report(parsed_flags)
|
|
|
|
report = ''
|
|
|
|
parsed_flags.each do |flag, val|
|
|
|
|
report << "AFP #{rhost}:#{rport} * #{flag}: #{val.to_s} \n"
|
|
|
|
end
|
|
|
|
return report
|
|
|
|
end
|
2012-03-02 19:58:40 +00:00
|
|
|
|
2013-08-30 21:28:54 +00:00
|
|
|
def format_addresses_report(parsed_network_addresses)
|
|
|
|
report = ''
|
|
|
|
parsed_network_addresses.each do |val|
|
|
|
|
report << "AFP #{rhost}:#{rport} * #{val.to_s} \n"
|
|
|
|
end
|
|
|
|
return report
|
|
|
|
end
|
2012-03-02 19:58:40 +00:00
|
|
|
end
|