Skip to content

Commit 15793fb

Browse files
committed
--fake-gen option: generate random-filled Fake Packets
This option is similar to fake-from-hex, but generates number of packets with random payload.
1 parent f0d4212 commit 15793fb

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Usage: goodbyedpi.exe [OPTION...]
6767
--fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).
6868
This option can be supplied multiple times, in this case each fake packet
6969
would be sent on every request in the command line argument order.
70+
--fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them
71+
(up to 30).
7072
--max-payload [value] packets with TCP payload data more than [value] won't be processed.
7173
Use this option to reduce CPU usage by skipping huge amount of data
7274
(like file transfers) in already established sessions.

src/fakepackets.c

+24
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <stdio.h>
2+
#define _CRT_RAND_S
23
#include <stdlib.h>
34
#include <stdbool.h>
45
#include <ctype.h>
@@ -284,3 +285,26 @@ int fake_load_from_hex(const char *data) {
284285

285286
return fake_add(finaldata, len / 2);
286287
}
288+
289+
int fake_load_random(unsigned int count, unsigned int maxsize) {
290+
if (count < 1 || count > sizeof(fakes) / sizeof(*fakes))
291+
return 1;
292+
293+
unsigned int random = 0;
294+
295+
for (unsigned int i=0; i<count; i++) {
296+
unsigned int len = 0;
297+
if (rand_s(&len))
298+
return 1;
299+
len = 8 + (len % maxsize);
300+
301+
unsigned char *data = calloc(len, 1);
302+
for (unsigned int j=0; j<len; j++) {
303+
rand_s(&random);
304+
data[j] = random % 0xFF;
305+
}
306+
if (fake_add(data, len))
307+
return 2;
308+
}
309+
return 0;
310+
}

src/goodbyedpi.c

+8
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ static struct option long_options[] = {
189189
{"reverse-frag",no_argument, 0, '(' },
190190
{"max-payload", optional_argument, 0, '|' },
191191
{"fake-from-hex", required_argument, 0, 'u' },
192+
{"fake-gen", required_argument, 0, 'j' },
192193
{"debug-exit", optional_argument, 0, 'x' },
193194
{0, 0, 0, 0 }
194195
};
@@ -946,6 +947,11 @@ int main(int argc, char *argv[]) {
946947
printf("WARNING: bad fake HEX value %s\n", optarg);
947948
}
948949
break;
950+
case 'j': // --fake-gen
951+
if (fake_load_random(atoub(optarg, "Fake generator parameter error!"))) {
952+
puts("WARNING: fake generator has failed!");
953+
}
954+
break;
949955
case 'x': // --debug-exit
950956
debug_exit = true;
951957
break;
@@ -997,6 +1003,8 @@ int main(int argc, char *argv[]) {
9971003
" --fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).\n"
9981004
" This option can be supplied multiple times, in this case each fake packet\n"
9991005
" would be sent on every request in the command line argument order.\n"
1006+
" --fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them\n"
1007+
" (up to 30).\n"
10001008
" --max-payload [value] packets with TCP payload data more than [value] won't be processed.\n"
10011009
" Use this option to reduce CPU usage by skipping huge amount of data\n"
10021010
" (like file transfers) in already established sessions.\n"

0 commit comments

Comments
 (0)