/ README.md
README.md
  1  GoodbyeDPI — Deep Packet Inspection circumvention utility
  2  =========================
  3  
  4  This software designed to bypass Deep Packet Inspection systems found in many Internet Service Providers which block access to certain websites.
  5  
  6  It handles DPI connected using optical splitter or port mirroring (**Passive DPI**) which do not block any data but just replying faster than requested destination, and **Active DPI** connected in sequence.
  7  
  8  **Windows 7, 8, 8.1, 10 or 11** with administrator privileges required.
  9  
 10  # Quick start
 11  
 12  * **For Russia**: Download [latest version from Releases page](https://github.com/ValdikSS/GoodbyeDPI/releases), unpack the file and run **1_russia_blacklist_dnsredir.cmd** script.
 13  * For other countries: Download [latest version from Releases page](https://github.com/ValdikSS/GoodbyeDPI/releases), unpack the file and run **2_any_country_dnsredir.cmd**.
 14  
 15  These scripts launch GoodbyeDPI in recommended mode with DNS resolver redirection to Yandex DNS on non-standard port (to prevent DNS poisoning).  
 16  If it works — congratulations! You can use it as-is or configure further.
 17  
 18  # How to use
 19  
 20  Download [latest version from Releases page](https://github.com/ValdikSS/GoodbyeDPI/releases) and run.
 21  
 22  ```
 23  Usage: goodbyedpi.exe [OPTION...]
 24   -p          block passive DPI
 25   -r          replace Host with hoSt
 26   -s          remove space between host header and its value
 27   -m          mix Host header case (test.com -> tEsT.cOm)
 28   -f <value>  set HTTP fragmentation to value
 29   -k <value>  enable HTTP persistent (keep-alive) fragmentation and set it to value
 30   -n          do not wait for first segment ACK when -k is enabled
 31   -e <value>  set HTTPS fragmentation to value
 32   -a          additional space between Method and Request-URI (enables -s, may break sites)
 33   -w          try to find and parse HTTP traffic on all processed ports (not only on port 80)
 34   --port        <value>    additional TCP port to perform fragmentation on (and HTTP tricks with -w)
 35   --ip-id       <value>    handle additional IP ID (decimal, drop redirects and TCP RSTs with this ID).
 36                            This option can be supplied multiple times.
 37   --dns-addr    <value>    redirect UDP DNS requests to the supplied IP address (experimental)
 38   --dns-port    <value>    redirect UDP DNS requests to the supplied port (53 by default)
 39   --dnsv6-addr  <value>    redirect UDPv6 DNS requests to the supplied IPv6 address (experimental)
 40   --dnsv6-port  <value>    redirect UDPv6 DNS requests to the supplied port (53 by default)
 41   --dns-verb               print verbose DNS redirection messages
 42   --blacklist   <txtfile>  perform circumvention tricks only to host names and subdomains from
 43                            supplied text file (HTTP Host/TLS SNI).
 44                            This option can be supplied multiple times.
 45   --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.
 47   --set-ttl     <value>    activate Fake Request Mode and send it with supplied TTL value.
 48                            DANGEROUS! May break websites in unexpected ways. Use with care (or --blacklist).
 49   --auto-ttl    [a1-a2-m]  activate Fake Request Mode, automatically detect TTL and decrease
 50                            it based on a distance. If the distance is shorter than a2, TTL is decreased
 51                            by a2. If it's longer, (a1; a2) scale is used with the distance as a weight.
 52                            If the resulting TTL is more than m(ax), set it to m.
 53                            Default (if set): --auto-ttl 1-4-10. Also sets --min-ttl 3.
 54                            DANGEROUS! May break websites in unexpected ways. Use with care (or --blacklist).
 55   --min-ttl     <value>    minimum TTL distance (128/64 - TTL) for which to send Fake Request
 56                            in --set-ttl and --auto-ttl modes.
 57   --wrong-chksum           activate Fake Request Mode and send it with incorrect TCP checksum.
 58                            May not work in a VM or with some routers, but is safer than set-ttl.
 59   --wrong-seq              activate Fake Request Mode and send it with TCP SEQ/ACK in the past.
 60   --native-frag            fragment (split) the packets by sending them in smaller packets, without
 61                            shrinking the Window Size. Works faster (does not slow down the connection)
 62                            and better.
 63   --reverse-frag           fragment (split) the packets just as --native-frag, but send them in the
 64                            reversed order. Works with the websites which could not handle segmented
 65                            HTTPS TLS ClientHello (because they receive the TCP flow "combined").
 66   --max-payload [value]    packets with TCP payload data more than [value] won't be processed.
 67                            Use this option to reduce CPU usage by skipping huge amount of data
 68                            (like file transfers) in already established sessions.
 69                            May skip some huge HTTP requests from being processed.
 70                            Default (if set): --max-payload 1200.
 71  
 72  
 73  LEGACY modesets:
 74   -1          -p -r -s -f 2 -k 2 -n -e 2 (most compatible mode)
 75   -2          -p -r -s -f 2 -k 2 -n -e 40 (better speed for HTTPS yet still compatible)
 76   -3          -p -r -s -e 40 (better speed for HTTP and HTTPS)
 77   -4          -p -r -s (best speed)
 78  
 79  Modern modesets (more stable, more compatible, faster):
 80   -5          -f 2 -e 2 --auto-ttl --reverse-frag --max-payload (this is the default)
 81   -6          -f 2 -e 2 --wrong-seq --reverse-frag --max-payload
 82  ```
 83  
 84  To check if your ISP's DPI could be circumvented, first make sure that your provider does not poison DNS answers by enabling "Secure DNS (DNS over HTTPS)" option in your browser.
 85  
 86  * **Chrome**: Settings → [Privacy and security](chrome://settings/security) → Use secure DNS → With: NextDNS
 87  * **Firefox**: [Settings](about:preferences) → Network Settings → Enable DNS over HTTPS → Use provider: NextDNS
 88  
 89  Then run the `goodbyedpi.exe` executable without any options. If it works — congratulations! You can use it as-is or configure further, for example by using `--blacklist` option if the list of blocked websites is known and available for your country.
 90  
 91  If your provider intercepts DNS requests, you may want to use `--dns-addr` option to a public DNS resolver running on non-standard port (such as Yandex DNS `77.88.8.8:1253`) or configure DNS over HTTPS/TLS using third-party applications.
 92  
 93  Check the .cmd scripts and modify it according to your preference and network conditions.
 94  
 95  # How does it work
 96  
 97  ### Passive DPI
 98  
 99  Most Passive DPI send HTTP 302 Redirect if you try to access blocked website over HTTP and TCP Reset in case of HTTPS, faster than destination website. Packets sent by DPI usually have IP Identification field equal to `0x0000` or `0x0001`, as seen with Russian providers. These packets, if they redirect you to another website (censorship page), are blocked by GoodbyeDPI.
100  
101  ### Active DPI
102  
103  Active DPI is more tricky to fool. Currently the software uses 7 methods to circumvent Active DPI:
104  
105  * TCP-level fragmentation for first data packet
106  * TCP-level fragmentation for persistent (keep-alive) HTTP sessions
107  * Replacing `Host` header with `hoSt`
108  * Removing space between header name and value in `Host` header
109  * Adding additional space between HTTP Method (GET, POST etc) and URI
110  * Mixing case of Host header value
111  * Sending fake HTTP/HTTPS packets with low Time-To-Live value, incorrect checksum or incorrect TCP Sequence/Acknowledgement numbers to fool DPI and prevent delivering them to the destination
112  
113  These methods should not break any website as they're fully compatible with TCP and HTTP standards, yet it's sufficient to prevent DPI data classification and to circumvent censorship. Additional space may break some websites, although it's acceptable by HTTP/1.1 specification (see 19.3 Tolerant Applications).
114  
115  The program loads WinDivert driver which uses Windows Filtering Platform to set filters and redirect packets to the userspace. It's running as long as console window is visible and terminates when you close the window.
116  
117  # How to build from source
118  
119  This project can be build using **GNU Make** and [**mingw**](https://mingw-w64.org). The only dependency is [WinDivert](https://github.com/basil00/Divert).
120  
121  To build x86 exe run:
122  
123  `make CPREFIX=i686-w64-mingw32- WINDIVERTHEADERS=/path/to/windivert/include WINDIVERTLIBS=/path/to/windivert/x86`
124  
125  And for x86_64:
126  
127  `make CPREFIX=x86_64-w64-mingw32- BIT64=1 WINDIVERTHEADERS=/path/to/windivert/include WINDIVERTLIBS=/path/to/windivert/amd64`
128  
129  # How to install as Windows Service
130  
131  Check examples in `service_install_russia_blacklist.cmd`, `service_install_russia_blacklist_dnsredir.cmd` and `service_remove.cmd` scripts.
132  
133  Modify them according to your own needs.
134  
135  # Known issues
136  
137  * Horribly outdated Windows 7 installations are not able to load WinDivert driver due to missing support for SHA256 digital signatures. Install KB3033929 [x86](https://www.microsoft.com/en-us/download/details.aspx?id=46078)/[x64](https://www.microsoft.com/en-us/download/details.aspx?id=46148), or better, update the whole system using Windows Update.
138  * ~~Some SSL/TLS stacks unable to process fragmented ClientHello packets, and HTTPS websites won't open. Bug: [#4](https://github.com/ValdikSS/GoodbyeDPI/issues/4), [#64](https://github.com/ValdikSS/GoodbyeDPI/issues/64).~~ Fragmentation issues are fixed in v0.1.7.
139  * ~~ESET Antivirus is incompatible with WinDivert driver [#91](https://github.com/ValdikSS/GoodbyeDPI/issues/91). This is most probably antivirus bug, not WinDivert.~~
140  
141  
142  # Similar projects
143  
144  - **[zapret](https://github.com/bol-van/zapret)** by @bol-van (for MacOS, Linux and Windows)
145  - **[Green Tunnel](https://github.com/SadeghHayeri/GreenTunnel)** by @SadeghHayeri (for MacOS, Linux and Windows)
146  - **[DPI Tunnel CLI](https://github.com/zhenyolka/DPITunnel-cli)** by @zhenyolka (for Linux and routers)
147  - **[DPI Tunnel for Android](https://github.com/zhenyolka/DPITunnel-android)** by @zhenyolka (for Android)
148  - **[PowerTunnel](https://github.com/krlvm/PowerTunnel)** by @krlvm (for Windows, MacOS and Linux)
149  - **[PowerTunnel for Android](https://github.com/krlvm/PowerTunnel-Android)** by @krlvm (for Android)
150  - **[SpoofDPI](https://github.com/xvzc/SpoofDPI)** by @xvzc (for macOS and Linux)
151  - **[GhosTCP](https://github.com/macronut/ghostcp)** by @macronut (for Windows)
152  - **[ByeDPI](https://github.com/hufrea/byedpi)** for Linux/Windows + **[ByeDPIAndroid](https://github.com/dovecoteescapee/ByeDPIAndroid/)** for Android (no root)
153  
154  # Kudos
155  
156  Thanks @basil00 for [WinDivert](https://github.com/basil00/Divert). That's the main part of this program.
157  
158  Thanks for every [BlockCheck](https://github.com/ValdikSS/blockcheck) contributor. It would be impossible to understand DPI behaviour without this utility.