Skip to content

Commit

Permalink
--fake-resend option: repeat sending each fake packet number of times
Browse files Browse the repository at this point in the history
  • Loading branch information
ValdikSS committed Sep 14, 2024
1 parent 985a09c commit bc95b6f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ Usage: goodbyedpi.exe [OPTION...]
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).
--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.
Use this option to reduce CPU usage by skipping huge amount of data
(like file transfers) in already established sessions.
Expand Down
7 changes: 5 additions & 2 deletions src/fakepackets.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct fake_t {

static struct fake_t *fakes[30] = {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"
"User-Agent: curl/7.65.3\r\nAccept: */*\r\n"
Expand Down Expand Up @@ -198,7 +199,8 @@ int send_fake_http_request(const HANDLE w_filter,
) {
int ret = 0;
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,
set_ttl, set_checksum, set_seq,
fakes[i]))
Expand All @@ -220,7 +222,8 @@ int send_fake_https_request(const HANDLE w_filter,
) {
int ret = 0;
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,
set_ttl, set_checksum, set_seq,
fakes[i]))
Expand Down
1 change: 1 addition & 0 deletions src/fakepackets.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
extern int fakes_count;
extern int fakes_resend;
int send_fake_http_request(const HANDLE w_filter,
const PWINDIVERT_ADDRESS addr,
const char *pkt,
Expand Down
20 changes: 17 additions & 3 deletions src/goodbyedpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ static struct option long_options[] = {
{"max-payload", optional_argument, 0, '|' },
{"fake-from-hex", required_argument, 0, 'u' },
{"fake-gen", required_argument, 0, 'j' },
{"fake-resend", required_argument, 0, 't' },
{"debug-exit", optional_argument, 0, 'x' },
{0, 0, 0, 0 }
};
Expand Down Expand Up @@ -952,6 +953,15 @@ int main(int argc, char *argv[]) {
puts("WARNING: fake generator has failed!");
}
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
debug_exit = true;
break;
Expand Down Expand Up @@ -1005,6 +1015,8 @@ int main(int argc, char *argv[]) {
" 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"
" --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"
" Use this option to reduce CPU usage by skipping huge amount of data\n"
" (like file transfers) in already established sessions.\n"
Expand Down Expand Up @@ -1065,7 +1077,8 @@ int main(int argc, char *argv[]) {
"Fake requests, wrong checksum: %d\n" /* 18 */
"Fake requests, wrong SEQ/ACK: %d\n" /* 19 */
"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_fragment_http ? http_fragment_size : 0), /* 2 */
(do_fragment_http_persistent ? http_fragment_size : 0),/* 3 */
Expand All @@ -1087,8 +1100,9 @@ int main(int argc, char *argv[]) {
do_auto_ttl ? auto_ttl_max : 0, ttl_min_nhops,
do_wrong_chksum, /* 18 */
do_wrong_seq, /* 19 */
fakes_count, /* 20 */
max_payload_size /* 21 */
fakes_count, /* 20 */
fakes_resend, /* 21 */
max_payload_size /* 22 */
);

if (do_fragment_http && http_fragment_size > 2 && !do_native_frag) {
Expand Down

0 comments on commit bc95b6f

Please sign in to comment.