mirror of
https://github.com/ValdikSS/GoodbyeDPI.git
synced 2025-12-17 04:44:36 +03:00
--fake-gen option: generate random-filled Fake Packets
This option is similar to fake-from-hex, but generates number of packets with random payload.
This commit is contained in:
@@ -67,6 +67,8 @@ Usage: goodbyedpi.exe [OPTION...]
|
|||||||
--fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).
|
--fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).
|
||||||
This option can be supplied multiple times, in this case each fake packet
|
This option can be supplied multiple times, in this case each fake packet
|
||||||
would be sent on every request in the command line argument order.
|
would be sent on every request in the command line argument order.
|
||||||
|
--fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them
|
||||||
|
(up to 30).
|
||||||
--max-payload [value] packets with TCP payload data more than [value] won't be processed.
|
--max-payload [value] packets with TCP payload data more than [value] won't be processed.
|
||||||
Use this option to reduce CPU usage by skipping huge amount of data
|
Use this option to reduce CPU usage by skipping huge amount of data
|
||||||
(like file transfers) in already established sessions.
|
(like file transfers) in already established sessions.
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define _CRT_RAND_S
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
@@ -284,3 +285,26 @@ int fake_load_from_hex(const char *data) {
|
|||||||
|
|
||||||
return fake_add(finaldata, len / 2);
|
return fake_add(finaldata, len / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fake_load_random(unsigned int count, unsigned int maxsize) {
|
||||||
|
if (count < 1 || count > sizeof(fakes) / sizeof(*fakes))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
unsigned int random = 0;
|
||||||
|
|
||||||
|
for (unsigned int i=0; i<count; i++) {
|
||||||
|
unsigned int len = 0;
|
||||||
|
if (rand_s(&len))
|
||||||
|
return 1;
|
||||||
|
len = 8 + (len % maxsize);
|
||||||
|
|
||||||
|
unsigned char *data = calloc(len, 1);
|
||||||
|
for (unsigned int j=0; j<len; j++) {
|
||||||
|
rand_s(&random);
|
||||||
|
data[j] = random % 0xFF;
|
||||||
|
}
|
||||||
|
if (fake_add(data, len))
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ static struct option long_options[] = {
|
|||||||
{"reverse-frag",no_argument, 0, '(' },
|
{"reverse-frag",no_argument, 0, '(' },
|
||||||
{"max-payload", optional_argument, 0, '|' },
|
{"max-payload", optional_argument, 0, '|' },
|
||||||
{"fake-from-hex", required_argument, 0, 'u' },
|
{"fake-from-hex", required_argument, 0, 'u' },
|
||||||
|
{"fake-gen", required_argument, 0, 'j' },
|
||||||
{"debug-exit", optional_argument, 0, 'x' },
|
{"debug-exit", optional_argument, 0, 'x' },
|
||||||
{0, 0, 0, 0 }
|
{0, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
@@ -946,6 +947,11 @@ int main(int argc, char *argv[]) {
|
|||||||
printf("WARNING: bad fake HEX value %s\n", optarg);
|
printf("WARNING: bad fake HEX value %s\n", optarg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'j': // --fake-gen
|
||||||
|
if (fake_load_random(atoub(optarg, "Fake generator parameter error!"))) {
|
||||||
|
puts("WARNING: fake generator has failed!");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'x': // --debug-exit
|
case 'x': // --debug-exit
|
||||||
debug_exit = true;
|
debug_exit = true;
|
||||||
break;
|
break;
|
||||||
@@ -997,6 +1003,8 @@ int main(int argc, char *argv[]) {
|
|||||||
" --fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).\n"
|
" --fake-from-hex <value> Load fake packets for Fake Request Mode from HEX values (like 1234abcDEF).\n"
|
||||||
" This option can be supplied multiple times, in this case each fake packet\n"
|
" This option can be supplied multiple times, in this case each fake packet\n"
|
||||||
" would be sent on every request in the command line argument order.\n"
|
" would be sent on every request in the command line argument order.\n"
|
||||||
|
" --fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them\n"
|
||||||
|
" (up to 30).\n"
|
||||||
" --max-payload [value] packets with TCP payload data more than [value] won't be processed.\n"
|
" --max-payload [value] packets with TCP payload data more than [value] won't be processed.\n"
|
||||||
" Use this option to reduce CPU usage by skipping huge amount of data\n"
|
" Use this option to reduce CPU usage by skipping huge amount of data\n"
|
||||||
" (like file transfers) in already established sessions.\n"
|
" (like file transfers) in already established sessions.\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user