/* A connecting netbus client "hangs" while being flooded with data. When the (Windows) netbus client tries to connect to you on TCP port 12345 it obviously waits for some string from you to confirm the connection. However, until that string is recieved the netbus client reads/scans all the data that is sent to it, and during that time it "hangs", so if we flood it with data it will hang and the client-user will be forced to kill the client. NoNetBusd simply loops /dev/urandom on port 12345 when a connection is established. This ought to teach those annoying netbus-scanning punks to stop filling my logfiles. c.o.d (c.o.d@mindless.com) Word to: Carlman and cannon for letting me test this using their Win* machines. Nevyn and Creed for finding the time to recode it. #wlug and #linux.se people -- snip -- */ /* nonetbusd.c, originally coded by c.o.d recoded by Nevyn, Creed (and me) at DreamHack 98 */ #include #include #include #include #include #include #include #include #include #include #include #include #define PORT 12345 const char *file = "/dev/urandom"; void print_file(); int sock, fd, client_len; main(int argc, char **argv) { int i,n; struct sockaddr_in server, client; struct hostent *clienthost; signal(SIGCHLD, SIG_IGN); /* reap the zombies, jao */ signal(SIGINT, SIG_IGN); if(fork()) exit(0); sock=socket(AF_INET, SOCK_STREAM, 0); server.sin_family=AF_INET; server.sin_addr.s_addr=INADDR_ANY; server.sin_port=htons(PORT); bind(sock,(struct sockaddr *)&server, sizeof server); listen(sock,10); client_len = sizeof client; while(1) { while((fd = accept(sock,(struct sockaddr *)&client,&client_len))<0) { if(errno!=EINTR) { exit(3); } } clienthost=gethostbyaddr((char *)&client.sin_addr.s_addr, 4, AF_INET); openlog(argv[0], LOG_NDELAY, LOG_AUTH); syslog(LOG_NOTICE, "asshole @ %s (%s)", clienthost->h_name, inet_ntoa(*(struct in_addr *)&client.sin_addr)); if (!fork()) { for (i = 0 ; i < 10 ; i++) { print_file(); usleep(5000); } close(fd); } else close(fd); } } void print_file() { FILE *infile; char sbuf[1024]; infile = fopen(file,"r"); fgets(sbuf,120,infile); while(!feof(infile)) { write(fd, sbuf, strlen(sbuf)); fgets(sbuf,120,infile); usleep(300000); /* so we won't completely lag ourselves */ } fclose(infile); }