--fake-resend option: repeat sending each fake packet number of times

This commit is contained in:
ValdikSS 2024-09-14 23:00:38 +03:00
parent 985a09c73d
commit bc95b6f598
4 changed files with 25 additions and 5 deletions

View File

@ -69,6 +69,8 @@ Usage: goodbyedpi.exe [OPTION...]
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 --fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them
(up to 30). (up to 30).
--fake-resend <value> Send each fake packet value number of times.
Default: 1 (send each packet once).
--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.

View File

@ -16,6 +16,7 @@ struct fake_t {
static struct fake_t *fakes[30] = {0}; static struct fake_t *fakes[30] = {0};
int fakes_count = 0; int fakes_count = 0;
int fakes_resend = 1;
static const unsigned char fake_http_request[] = "GET / HTTP/1.1\r\nHost: www.w3.org\r\n" static const unsigned char fake_http_request[] = "GET / HTTP/1.1\r\nHost: www.w3.org\r\n"
"User-Agent: curl/7.65.3\r\nAccept: */*\r\n" "User-Agent: curl/7.65.3\r\nAccept: */*\r\n"
@ -198,7 +199,8 @@ int send_fake_http_request(const HANDLE w_filter,
) { ) {
int ret = 0; int ret = 0;
for (int i=0; i<fakes_count || i == 0; i++) { for (int i=0; i<fakes_count || i == 0; i++) {
if (send_fake_request(w_filter, addr, pkt, packetLen, for (int j=0; j<fakes_resend; j++)
if (send_fake_request(w_filter, addr, pkt, packetLen,
is_ipv6, FALSE, is_ipv6, FALSE,
set_ttl, set_checksum, set_seq, set_ttl, set_checksum, set_seq,
fakes[i])) fakes[i]))
@ -220,7 +222,8 @@ int send_fake_https_request(const HANDLE w_filter,
) { ) {
int ret = 0; int ret = 0;
for (int i=0; i<fakes_count || i == 0; i++) { for (int i=0; i<fakes_count || i == 0; i++) {
if (send_fake_request(w_filter, addr, pkt, packetLen, for (int j=0; j<fakes_resend; j++)
if (send_fake_request(w_filter, addr, pkt, packetLen,
is_ipv6, TRUE, is_ipv6, TRUE,
set_ttl, set_checksum, set_seq, set_ttl, set_checksum, set_seq,
fakes[i])) fakes[i]))

View File

@ -1,4 +1,5 @@
extern int fakes_count; extern int fakes_count;
extern int fakes_resend;
int send_fake_http_request(const HANDLE w_filter, int send_fake_http_request(const HANDLE w_filter,
const PWINDIVERT_ADDRESS addr, const PWINDIVERT_ADDRESS addr,
const char *pkt, const char *pkt,

View File

@ -190,6 +190,7 @@ static struct option long_options[] = {
{"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' }, {"fake-gen", required_argument, 0, 'j' },
{"fake-resend", required_argument, 0, 't' },
{"debug-exit", optional_argument, 0, 'x' }, {"debug-exit", optional_argument, 0, 'x' },
{0, 0, 0, 0 } {0, 0, 0, 0 }
}; };
@ -952,6 +953,15 @@ int main(int argc, char *argv[]) {
puts("WARNING: fake generator has failed!"); puts("WARNING: fake generator has failed!");
} }
break; break;
case 't': // --fake-resend
fakes_resend = atoub(optarg, "Fake resend parameter error!");
if (fakes_resend == 1)
puts("WARNING: fake-resend is 1, no resending is in place!");
else if (!fakes_resend)
puts("WARNING: fake-resend is 0, fake packet mode is disabled!");
else if (fakes_resend > 100)
puts("WARNING: fake-resend value is a little too high, don't you think?");
break;
case 'x': // --debug-exit case 'x': // --debug-exit
debug_exit = true; debug_exit = true;
break; break;
@ -1005,6 +1015,8 @@ int main(int argc, char *argv[]) {
" 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" " --fake-gen <value> Generate random-filled fake packets for Fake Request Mode, value of them\n"
" (up to 30).\n" " (up to 30).\n"
" --fake-resend <value> Send each fake packet value number of times.\n"
" Default: 1 (send each packet once).\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"
@ -1065,7 +1077,8 @@ int main(int argc, char *argv[]) {
"Fake requests, wrong checksum: %d\n" /* 18 */ "Fake requests, wrong checksum: %d\n" /* 18 */
"Fake requests, wrong SEQ/ACK: %d\n" /* 19 */ "Fake requests, wrong SEQ/ACK: %d\n" /* 19 */
"Fake requests, custom payloads: %d\n" /* 20 */ "Fake requests, custom payloads: %d\n" /* 20 */
"Max payload size: %hu\n", /* 21 */ "Fake requests, resend: %d\n" /* 21 */
"Max payload size: %hu\n", /* 22 */
do_passivedpi, do_block_quic, /* 1 */ do_passivedpi, do_block_quic, /* 1 */
(do_fragment_http ? http_fragment_size : 0), /* 2 */ (do_fragment_http ? http_fragment_size : 0), /* 2 */
(do_fragment_http_persistent ? http_fragment_size : 0),/* 3 */ (do_fragment_http_persistent ? http_fragment_size : 0),/* 3 */
@ -1087,8 +1100,9 @@ int main(int argc, char *argv[]) {
do_auto_ttl ? auto_ttl_max : 0, ttl_min_nhops, do_auto_ttl ? auto_ttl_max : 0, ttl_min_nhops,
do_wrong_chksum, /* 18 */ do_wrong_chksum, /* 18 */
do_wrong_seq, /* 19 */ do_wrong_seq, /* 19 */
fakes_count, /* 20 */ fakes_count, /* 20 */
max_payload_size /* 21 */ fakes_resend, /* 21 */
max_payload_size /* 22 */
); );
if (do_fragment_http && http_fragment_size > 2 && !do_native_frag) { if (do_fragment_http && http_fragment_size > 2 && !do_native_frag) {