Skip to content

Commit 15eb10a

Browse files
committed
Fragment packet by the beginning of SNI value. #357
It has been reported that the DPI systems in Saudi Arabia and United Arab Emirates are started to search for the beginning of SNI extension header and its value, without parsing the TLS ClientHello packet, in any part of TCP session. Workaround the issue by splitting the packet right after the end of extension headers and before its value. https://ntc.party/t/goodbyedpi-in-saudi-arabia/7884 https://ntc.party/t/goodbyedpi-in-uae/7914
1 parent 4c846c7 commit 15eb10a

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Usage: goodbyedpi.exe [OPTION...]
4343
supplied text file (HTTP Host/TLS SNI).
4444
This option can be supplied multiple times.
4545
--allow-no-sni perform circumvention if TLS SNI can't be detected with --blacklist enabled.
46+
--frag-by-sni if SNI is detected in TLS packet, fragment the packet right before SNI value.
4647
--set-ttl <value> activate Fake Request Mode and send it with supplied TTL value.
4748
DANGEROUS! May break websites in unexpected ways. Use with care (or --blacklist).
4849
--auto-ttl [a1-a2-m] activate Fake Request Mode, automatically detect TTL and decrease

src/goodbyedpi.c

+30-17
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ static struct option long_options[] = {
162162
{"dns-verb", no_argument, 0, 'v' },
163163
{"blacklist", required_argument, 0, 'b' },
164164
{"allow-no-sni",no_argument, 0, ']' },
165+
{"frag-by-sni", no_argument, 0, '>' },
165166
{"ip-id", required_argument, 0, 'i' },
166167
{"set-ttl", required_argument, 0, '$' },
167168
{"min-ttl", required_argument, 0, '[' },
@@ -568,6 +569,7 @@ int main(int argc, char *argv[]) {
568569
do_dnsv4_redirect = 0, do_dnsv6_redirect = 0,
569570
do_dns_verb = 0, do_tcp_verb = 0, do_blacklist = 0,
570571
do_allow_no_sni = 0,
572+
do_fragment_by_sni = 0,
571573
do_fake_packet = 0,
572574
do_auto_ttl = 0,
573575
do_wrong_chksum = 0,
@@ -806,6 +808,9 @@ int main(int argc, char *argv[]) {
806808
case ']': // --allow-no-sni
807809
do_allow_no_sni = 1;
808810
break;
811+
case '>': // --frag-by-sni
812+
do_fragment_by_sni = 1;
813+
break;
809814
case '$': // --set-ttl
810815
do_auto_ttl = auto_ttl_1 = auto_ttl_2 = auto_ttl_max = 0;
811816
do_fake_packet = 1;
@@ -899,6 +904,7 @@ int main(int argc, char *argv[]) {
899904
" supplied text file (HTTP Host/TLS SNI).\n"
900905
" This option can be supplied multiple times.\n"
901906
" --allow-no-sni perform circumvention if TLS SNI can't be detected with --blacklist enabled.\n"
907+
" --frag-by-sni if SNI is detected in TLS packet, fragment the packet right before SNI value.\n"
902908
" --set-ttl <value> activate Fake Request Mode and send it with supplied TTL value.\n"
903909
" DANGEROUS! May break websites in unexpected ways. Use with care (or --blacklist).\n"
904910
" --auto-ttl [a1-a2-m] activate Fake Request Mode, automatically detect TTL and decrease\n"
@@ -957,6 +963,7 @@ int main(int argc, char *argv[]) {
957963
"Fragment HTTP: %u\n" /* 2 */
958964
"Fragment persistent HTTP: %u\n" /* 3 */
959965
"Fragment HTTPS: %u\n" /* 4 */
966+
"Fragment by SNI: %u\n" /* 5 */
960967
"Native fragmentation (splitting): %d\n" /* 5 */
961968
"Fragments sending in reverse: %d\n" /* 6 */
962969
"hoSt: %d\n" /* 7 */
@@ -976,23 +983,24 @@ int main(int argc, char *argv[]) {
976983
(do_fragment_http ? http_fragment_size : 0), /* 2 */
977984
(do_fragment_http_persistent ? http_fragment_size : 0),/* 3 */
978985
(do_fragment_https ? https_fragment_size : 0), /* 4 */
979-
do_native_frag, /* 5 */
980-
do_reverse_frag, /* 6 */
981-
do_host, /* 7 */
982-
do_host_removespace, /* 8 */
983-
do_additional_space, /* 9 */
984-
do_host_mixedcase, /* 10 */
985-
do_http_allports, /* 11 */
986-
do_fragment_http_persistent_nowait, /* 12 */
987-
do_dnsv4_redirect, /* 13 */
988-
do_dnsv6_redirect, /* 14 */
989-
do_allow_no_sni, /* 15 */
990-
do_auto_ttl ? "auto" : (do_fake_packet ? "fixed" : "disabled"), /* 16 */
986+
do_fragment_by_sni, /* 5 */
987+
do_native_frag, /* 6 */
988+
do_reverse_frag, /* 7 */
989+
do_host, /* 8 */
990+
do_host_removespace, /* 9 */
991+
do_additional_space, /* 10 */
992+
do_host_mixedcase, /* 11 */
993+
do_http_allports, /* 12 */
994+
do_fragment_http_persistent_nowait, /* 13 */
995+
do_dnsv4_redirect, /* 14 */
996+
do_dnsv6_redirect, /* 15 */
997+
do_allow_no_sni, /* 16 */
998+
do_auto_ttl ? "auto" : (do_fake_packet ? "fixed" : "disabled"), /* 17 */
991999
ttl_of_fake_packet, do_auto_ttl ? auto_ttl_1 : 0, do_auto_ttl ? auto_ttl_2 : 0,
9921000
do_auto_ttl ? auto_ttl_max : 0, ttl_min_nhops,
993-
do_wrong_chksum, /* 17 */
994-
do_wrong_seq, /* 18 */
995-
max_payload_size /* 19 */
1001+
do_wrong_chksum, /* 18 */
1002+
do_wrong_seq, /* 19 */
1003+
max_payload_size /* 20 */
9961004
);
9971005

9981006
if (do_fragment_http && http_fragment_size > 2 && !do_native_frag) {
@@ -1046,6 +1054,7 @@ int main(int argc, char *argv[]) {
10461054
packetLen);
10471055
should_reinject = 1;
10481056
should_recalc_checksum = 0;
1057+
sni_ok = 0;
10491058

10501059
ppIpHdr = (PWINDIVERT_IPHDR)NULL;
10511060
ppIpV6Hdr = (PWINDIVERT_IPV6HDR)NULL;
@@ -1131,7 +1140,7 @@ int main(int argc, char *argv[]) {
11311140
if ((packet_dataLen == 2 && memcmp(packet_data, "\x16\x03", 2) == 0) ||
11321141
(packet_dataLen >= 3 && ( memcmp(packet_data, "\x16\x03\x01", 3) == 0 || memcmp(packet_data, "\x16\x03\x03", 3) == 0 )))
11331142
{
1134-
if (do_blacklist) {
1143+
if (do_blacklist || do_fragment_by_sni) {
11351144
sni_ok = extract_sni(packet_data, packet_dataLen,
11361145
&host_addr, &host_len);
11371146
}
@@ -1284,7 +1293,11 @@ int main(int argc, char *argv[]) {
12841293
current_fragment_size = http_fragment_size;
12851294
}
12861295
else if (do_fragment_https && ppTcpHdr->DstPort != htons(80)) {
1287-
current_fragment_size = https_fragment_size;
1296+
if (do_fragment_by_sni && sni_ok) {
1297+
current_fragment_size = (void*)host_addr - packet_data;
1298+
} else {
1299+
current_fragment_size = https_fragment_size;
1300+
}
12881301
}
12891302

12901303
if (current_fragment_size) {

0 commit comments

Comments
 (0)