Skip to content

Commit

Permalink
Update goodbyedpi.c
Browse files Browse the repository at this point in the history
  • Loading branch information
SashaXser committed Apr 15, 2024
1 parent ceb50e5 commit 82ba0b1
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions src/goodbyedpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ static void send_native_fragment(HANDLE w_filter, WINDIVERT_ADDRESS addr,
memcpy(packet, packet_bak, orig_packetLen);
}


int main(int argc, char *argv[]) {
static enum packet_type_e {
unknown,
Expand Down Expand Up @@ -1009,15 +1008,11 @@ int main(int argc, char *argv[]) {
* active DPI circumvention
*/
filters[filter_num] = init(filter_string, 0);

if (filters[filter_num] == NULL)
die();
w_filter = filters[filter_num];
filter_num++;

for (i = 0; i < filter_num; i++) {
if (filters[i] == NULL)
die();
}

printf("Filter activated, GoodbyeDPI is now running!\n");
signal(SIGINT, sigint_handler);

Expand Down Expand Up @@ -1261,21 +1256,22 @@ int main(int argc, char *argv[]) {
if (should_reinject && should_recalc_checksum && do_native_frag)
{
current_fragment_size = 0;
if (do_fragment_http && ppTcpHdr->DstPort == htons(80)) {
uint16_t port_80 = htons(80);
if (do_fragment_http && ppTcpHdr->DstPort == port_80) {
current_fragment_size = http_fragment_size;
}
else if (do_fragment_https && ppTcpHdr->DstPort != htons(80)) {
else if (do_fragment_https && ppTcpHdr->DstPort != port_80) {
current_fragment_size = https_fragment_size;
}

if (current_fragment_size) {
send_native_fragment(w_filter, addr, packet, packetLen, packet_data,
packet_dataLen,packet_v4, packet_v6,
packet_dataLen, packet_v4, packet_v6,
ppIpHdr, ppIpV6Hdr, ppTcpHdr,
current_fragment_size, do_reverse_frag);

send_native_fragment(w_filter, addr, packet, packetLen, packet_data,
packet_dataLen,packet_v4, packet_v6,
packet_dataLen, packet_v4, packet_v6,
ppIpHdr, ppIpV6Hdr, ppTcpHdr,
current_fragment_size, !do_reverse_frag);
continue;
Expand All @@ -1286,13 +1282,13 @@ int main(int argc, char *argv[]) {
/* Else if we got TCP packet without data */
else if (packet_type == ipv4_tcp || packet_type == ipv6_tcp) {
/* If we got INBOUND SYN+ACK packet */
if (!addr.Outbound &&
ppTcpHdr->Syn == 1 && ppTcpHdr->Ack == 1) {
if (!addr.Outbound && ppTcpHdr->Syn == 1 && ppTcpHdr->Ack == 1) {
//printf("Changing Window Size!\n");
/*
* Window Size is changed even if do_fragment_http_persistent
* is enabled as there could be non-HTTP data on port 80
*/
* Window Size is changed even if do_fragment_http_persistent
* is enabled as there could be non-HTTP data on port 80
*/
uint16_t port_80 = htons(80); // Store result of htons(80) for reuse

if (do_fake_packet && (do_auto_ttl || ttl_min_nhops)) {
if (!((packet_v4 && tcp_handle_incoming(&ppIpHdr->SrcAddr, &ppIpHdr->DstAddr,
Expand All @@ -1310,11 +1306,11 @@ int main(int argc, char *argv[]) {
}

if (!do_native_frag) {
if (do_fragment_http && ppTcpHdr->SrcPort == htons(80)) {
if (do_fragment_http && ppTcpHdr->SrcPort == port_80) {
change_window_size(ppTcpHdr, http_fragment_size);
should_recalc_checksum = 1;
}
else if (do_fragment_https && ppTcpHdr->SrcPort != htons(80)) {
else if (do_fragment_https && ppTcpHdr->SrcPort != port_80) {
change_window_size(ppTcpHdr, https_fragment_size);
should_recalc_checksum = 1;
}
Expand Down

0 comments on commit 82ba0b1

Please sign in to comment.