Skip to content
Snippets Groups Projects
README.md 5.23 KiB
Newer Older
  • Learn to ignore specific revisions
  • Dennis Suermann's avatar
    Dennis Suermann committed
    # DNSCensorBreaker
    
    DNSCensorBreaker is a python tool that acts as a proxy and implements DNS censorship evasion techniques.
    The tool is implemented to bypass DNS censorship of the Great Fire Wall in China.
    Currently, GFWatch Comparison, Encrypted DNS, and TCP Fragmentation are implemented.
    The techniques can be activated separately.
    
    This tool should be run locally to circumvent the DNS censorship successfully.
    It can be set up as the standard DNS resolver so that every DNS message is sent to this tool.
    
    # Requirements
    - python3
      - `sudo apt install python3`
    
    All requirements below can be installed with `pip3 install -r requirements.txt`
    - dnspython
    - requests
    - pyyaml
    - httpx
    - httpcore
    - h2
    - aioquic
      
    
    # Usage
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    ```
    
    python3 main.py -h
          
    usage: main.py [-h] [--debug | --no-debug] [--timeout TIMEOUT] [--host HOST] [--port PORT] [--dns_server DNS_SERVER]
                   [--server_port SERVER_PORT] [--strategy {GFWatch,Encrypted,PreferEncrypted,TCPFragmentation}]
                   [--encryption_protocol {DoT,DoH,DoQ,FindUsable}]
    
    Optional app description
    
    options:
      -h, --help            show this help message and exit
      --debug, --no-debug   Turns on debugging
      --timeout TIMEOUT     Connection timeout in seconds
      --host HOST           Address the proxy server runs on
      --port PORT           Port the proxy server runs on (default 5533)
      --dns_server DNS_SERVER
                            Defines the dns server that should be used. If the encryption protocol is set to FindUsable,
                            this field will be ignored when the server is blocked and a working server will be determined.
      --server_port SERVER_PORT
                            The port of the dns server. For normal UDP queries this is port 53.
      --strategy {GFWatch,Encrypted,PreferEncrypted,TCPFragmentation}
                            Which type of evasion strategy should be used. GFWatch comparison, Encrypted DNS, TCP
                            fragmentation, or prefer encrypted DNS with fallback to GFWatch comparison.
      --encryption_protocol {DoT,DoH,DoQ,FindUsable}
                            Which encryption protocol should be used for encrypted DNS. Only usable when the
                            evasion_strategy uses encrypted DNS. FindUsable searches for a usable protocol.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    ```
    
    
    ## Settings
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### -- debug
    Turns on debugging statements.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --timeout
    The timeout of the underlying sockets, which defines how long a connection is hold or waited for.
    This timeout also specifies the exit time of the tool, because it waits for all sockets to be closed. 
    
    ### --host
    The host on which DNSCensorBreaker listens for incoming connections.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --port
    The port on which DNSCensorBreaker listens for incoming connections. By default, this is set to 5533.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --dns_server
    Defines the DNS server that should be used. If the encryption protocol is set to FindUsable, this field will be ignored
    when the server is blocked and a working server will be determined.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --server_port
    Defines the port of the DNS server that is used for DNS resolving. For normal DNS queries over UDP this is set to port 53.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --strategy
    Defines the evasion strategy that is used to bypass DNS censorship. Available options: GFWatch comparison, Encrypted DNS
    , TCPFragmentation, or prefer encrypted DNS with fallback to GFWatch comparison.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ### --encryption_protocol 
    Which encryption protocol should be used for encrypted DNS. Only usable when the evasion_strategy is set to encrypted 
    DNS. FindUsable searches for a usable protocol.
    
    ## Default Configuration
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    To automatically set default configuration, we added the default_config.yml file. In this file the default connection 
    and strategy is defined that is used when no other parameter is provided. 
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ## Examples
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py` Launches DNSCensorBreaker with the default configuration specified in the default_config.yml. 
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --host 127.0.0.1 --port 4444` Launches DNSCensorBreaker locally on port 4444 and uses the strategy 
    defined in the default configuration.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --dns_server 1.1.1.1 --server_port 53 --strategy GFWatch` Starts the tool and uses the Cloudflare DNS 
    resolver with the GFWatch comparison strategy.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --dns_server 8.8.8.8 --server_port 853 --strategy Encrypted --encryption_protocol DoT` Launches the 
    tool and uses a DoT connection to the Google DNS resolver. 
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --dns_server 8.8.8.8 --server_port 853 --strategy PreferEncrypted --encryption_protocol DoT` Launches 
    tool and tries to establish a connection to the DoT endpoint of the Google resolver. If it is not reachable it falls 
    back to the GFWatch comparison strategy.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --strategy PreferEncrypted --encryption_protocol FindUsable` Launches the tool in the availability 
    check mode. It tries to search for an encrypted connection. If it found one this will be used. If no encrypted 
    connection could be established, the tool falls back to the GFWatch comparison.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    `python3 main.py --debug` Launches the tool in the debug mode.
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    ## Testing
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    Setup DNSCensorBreaker with 
    ```sh
    python3 main.py --port 4444 --strategy GFWatch 
    ```
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    test it by sending a DNS query via dig or another dns query tool
    ```sh
    dig @127.0.0.1 google.com -p 5533
    ```
    
    Dennis Suermann's avatar
    Dennis Suermann committed
    
    
    When using Wireshark, you can see the injected DNS response from the GFW and the real response that is returned by the 
    tool.