Skip to content

Commit cc1676a

Browse files
committed
--allow-no-sni option. Useful with --blacklist and undetectable SNI.
This option is added specially for protonmail.com, as it sends low Window Size in SYN-ACK for requests from Russia, to force the client to fragment the packet. GoodbyeDPI doesn't do reassembling and can't extract SNI in this case, thus won't circumvent the censorship if --blacklist option is used.
1 parent 7f59593 commit cc1676a

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ Usage: goodbyedpi.exe [OPTION...]
3434
--blacklist <txtfile> perform circumvention tricks only to host names and subdomains from
3535
supplied text file (HTTP Host/TLS SNI).
3636
This option can be supplied multiple times.
37+
--allow-no-sni perform circumvention if TLS SNI can't be detected with --blacklist enabled.
3738
--set-ttl <value> activate Fake Request Mode and send it with supplied TTL value.
3839
DANGEROUS! May break websites in unexpected ways. Use with care.
3940
--auto-ttl [a1-a2-m] activate Fake Request Mode, automatically detect TTL and decrease

src/goodbyedpi.c

+26-11
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static struct option long_options[] = {
160160
{"dnsv6-port", required_argument, 0, '@' },
161161
{"dns-verb", no_argument, 0, 'v' },
162162
{"blacklist", required_argument, 0, 'b' },
163+
{"allow-no-sni",no_argument, 0, ']' },
163164
{"ip-id", required_argument, 0, 'i' },
164165
{"set-ttl", required_argument, 0, '$' },
165166
{"min-ttl", required_argument, 0, '[' },
@@ -523,6 +524,7 @@ int main(int argc, char *argv[]) {
523524
ipv6_tcp, ipv6_tcp_data, ipv6_udp_data
524525
} packet_type;
525526
int i, should_reinject, should_recalc_checksum = 0;
527+
int sni_ok = 0;
526528
int opt;
527529
int packet_v4, packet_v6;
528530
HANDLE w_filter = NULL;
@@ -547,6 +549,7 @@ int main(int argc, char *argv[]) {
547549
do_host_mixedcase = 0,
548550
do_dnsv4_redirect = 0, do_dnsv6_redirect = 0,
549551
do_dns_verb = 0, do_tcp_verb = 0, do_blacklist = 0,
552+
do_allow_no_sni = 0,
550553
do_fake_packet = 0,
551554
do_auto_ttl = 0,
552555
do_wrong_chksum = 0,
@@ -778,6 +781,9 @@ int main(int argc, char *argv[]) {
778781
exit(EXIT_FAILURE);
779782
}
780783
break;
784+
case ']': // --allow-no-sni
785+
do_allow_no_sni = 1;
786+
break;
781787
case '$': // --set-ttl
782788
do_fake_packet = 1;
783789
ttl_of_fake_packet = atoub(optarg, "Set TTL parameter error!");
@@ -861,6 +867,7 @@ int main(int argc, char *argv[]) {
861867
" --blacklist <txtfile> perform circumvention tricks only to host names and subdomains from\n"
862868
" supplied text file (HTTP Host/TLS SNI).\n"
863869
" This option can be supplied multiple times.\n"
870+
" --allow-no-sni perform circumvention if TLS SNI can't be detected with --blacklist enabled.\n"
864871
" --set-ttl <value> activate Fake Request Mode and send it with supplied TTL value.\n"
865872
" DANGEROUS! May break websites in unexpected ways. Use with care (or --blacklist).\n"
866873
" --auto-ttl [a1-a2-m] activate Fake Request Mode, automatically detect TTL and decrease\n"
@@ -925,9 +932,10 @@ int main(int argc, char *argv[]) {
925932
"HTTP Persistent Nowait: %d\n" /* 12 */
926933
"DNS redirect: %d\n" /* 13 */
927934
"DNSv6 redirect: %d\n" /* 14 */
928-
"Fake requests, TTL: %s (fixed: %hu, auto: %hu-%hu-%hu, min distance: %hu)\n" /* 15 */
929-
"Fake requests, wrong checksum: %d\n" /* 16 */
930-
"Fake requests, wrong SEQ/ACK: %d\n", /* 17 */
935+
"Allow missing SNI: %d\n" /* 15 */
936+
"Fake requests, TTL: %s (fixed: %hu, auto: %hu-%hu-%hu, min distance: %hu)\n" /* 16 */
937+
"Fake requests, wrong checksum: %d\n" /* 17 */
938+
"Fake requests, wrong SEQ/ACK: %d\n", /* 18 */
931939
do_passivedpi, /* 1 */
932940
(do_fragment_http ? http_fragment_size : 0), /* 2 */
933941
(do_fragment_http_persistent ? http_fragment_size : 0),/* 3 */
@@ -942,11 +950,12 @@ int main(int argc, char *argv[]) {
942950
do_fragment_http_persistent_nowait, /* 12 */
943951
do_dnsv4_redirect, /* 13 */
944952
do_dnsv6_redirect, /* 14 */
945-
ttl_of_fake_packet ? "fixed" : (do_auto_ttl ? "auto" : "disabled"), /* 15 */
953+
do_allow_no_sni, /* 15 */
954+
ttl_of_fake_packet ? "fixed" : (do_auto_ttl ? "auto" : "disabled"), /* 16 */
946955
ttl_of_fake_packet, do_auto_ttl ? auto_ttl_1 : 0, do_auto_ttl ? auto_ttl_2 : 0,
947956
do_auto_ttl ? auto_ttl_max : 0, ttl_min_nhops,
948-
do_wrong_chksum, /* 16 */
949-
do_wrong_seq /* 17 */
957+
do_wrong_chksum, /* 17 */
958+
do_wrong_seq /* 18 */
950959
);
951960

952961
if (do_fragment_http && http_fragment_size > 2 && !do_native_frag) {
@@ -1083,11 +1092,17 @@ int main(int argc, char *argv[]) {
10831092
if ((packet_dataLen == 2 && memcmp(packet_data, "\x16\x03", 2) == 0) ||
10841093
(packet_dataLen >= 3 && memcmp(packet_data, "\x16\x03\x01", 3) == 0))
10851094
{
1086-
if (do_blacklist
1087-
? (extract_sni(packet_data, packet_dataLen,
1088-
&host_addr, &host_len) &&
1089-
blackwhitelist_check_hostname(host_addr, host_len))
1090-
: 1)
1095+
if (do_blacklist) {
1096+
sni_ok = extract_sni(packet_data, packet_dataLen,
1097+
&host_addr, &host_len);
1098+
}
1099+
if (
1100+
(do_blacklist && sni_ok &&
1101+
blackwhitelist_check_hostname(host_addr, host_len)
1102+
) ||
1103+
(do_blacklist && !sni_ok && do_allow_no_sni) ||
1104+
(!do_blacklist)
1105+
)
10911106
{
10921107
#ifdef DEBUG
10931108
char lsni[HOST_MAXLEN + 1] = {0};

0 commit comments

Comments
 (0)