7 Commits
0.0.7 ... 0.0.9

Author SHA1 Message Date
ValdikSS
2fe377a23f Do not handle traffic from private IP ranges 2017-08-15 14:09:47 +03:00
ValdikSS
b74c974235 Print error message if filter initialization fails 2017-08-15 14:09:06 +03:00
ValdikSS
96fb5f9516 Block passive DPI packets only with "Connection: close". Fixes #17.
Some servers set "don't fragment" flag and never increase TCP ID
field. If they send HTTP redirection to another website, it would
be blocked by the program.
This is a hack to block redirects only with "Connection: close"
header as presumably legal redirects are most likely would
use keep-alive.
2017-08-15 08:28:25 +03:00
ValdikSS
c1ca4f9804 Merge pull request #10 from beatcracker/patch-1
Fixed typos
2017-07-10 20:01:56 +04:00
beatcracker
13261e1a92 Fixed typos 2017-07-10 18:44:56 +03:00
ValdikSS
4387e7c690 Merge pull request #7 from pash7ka/patch-2
bugfix: wrong config file name
2017-06-14 12:23:33 +04:00
Pavel Rubin
08902b9a57 bugfix: wrong config file name 2017-06-14 02:13:39 +03:00
2 changed files with 47 additions and 15 deletions

View File

@@ -38,7 +38,7 @@ Use `goodbyedpi.exe -4` if it works for your ISP's DPI. This is the fastest mode
### Passive DPI ### Passive DPI
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 have always 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. 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 always 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.
### Active DPI ### Active DPI
@@ -49,7 +49,7 @@ Active DPI is more tricky to fool. Currently the software uses 4 methods to circ
* Removing space between header name and value in `Host` header * Removing space between header name and value in `Host` header
* Adding additional space between HTTP Method (GET, POST etc) and URI * Adding additional space between HTTP Method (GET, POST etc) and URI
These methods should not break any website as are 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). 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).
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. 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.
@@ -68,7 +68,7 @@ And for x86_64:
# How to install as Windows Service # How to install as Windows Service
One way is using an [srvstart](http://www.rozanski.org.uk/software) program. One way is using an [srvstart](http://www.rozanski.org.uk/software) program.
Unpack it to goodbyedpi directory and create 3 files: Unpack it to `goodbyedpi` directory and create 3 files:
*goodbyedpi.ini* *goodbyedpi.ini*
```INI ```INI
@@ -79,7 +79,7 @@ auto_restart=n
``` ```
*srvinstall.bat* *srvinstall.bat*
```Batchfile ```Batchfile
srvstart install GoodByeDPI -c %CD%\goodbyedpi-svc.ini srvstart install GoodByeDPI -c %CD%\goodbyedpi.ini
``` ```
*srvremove.bat* *srvremove.bat*
```Batchfile ```Batchfile

View File

@@ -21,6 +21,21 @@
#define IPV4_TOTALLEN_OFFSET 2 #define IPV4_TOTALLEN_OFFSET 2
#define TCP_WINDOWSIZE_OFFSET 14 #define TCP_WINDOWSIZE_OFFSET 14
#define DIVERT_NO_LOCALNETS_DST "(" \
"(ip.DstAddr < 127.0.0.1 or ip.DstAddr > 127.255.255.255) and " \
"(ip.DstAddr < 10.0.0.0 or ip.DstAddr > 10.255.255.255) and " \
"(ip.DstAddr < 192.168.0.0 or ip.DstAddr > 192.168.255.255) and " \
"(ip.DstAddr < 172.16.0.0 or ip.DstAddr > 172.31.255.255) and " \
"(ip.DstAddr < 169.254.0.0 or ip.DstAddr > 169.254.255.255)" \
")"
#define DIVERT_NO_LOCALNETS_SRC "(" \
"(ip.SrcAddr < 127.0.0.1 or ip.SrcAddr > 127.255.255.255) and " \
"(ip.SrcAddr < 10.0.0.0 or ip.SrcAddr > 10.255.255.255) and " \
"(ip.SrcAddr < 192.168.0.0 or ip.SrcAddr > 192.168.255.255) and " \
"(ip.SrcAddr < 172.16.0.0 or ip.SrcAddr > 172.31.255.255) and " \
"(ip.SrcAddr < 169.254.0.0 or ip.SrcAddr > 169.254.255.255)" \
")"
static HANDLE filters[MAX_FILTERS]; static HANDLE filters[MAX_FILTERS];
static int filter_num = 0; static int filter_num = 0;
static const char *http10_redirect_302 = "HTTP/1.0 302 "; static const char *http10_redirect_302 = "HTTP/1.0 302 ";
@@ -29,6 +44,7 @@ static const char *http_host_find = "\r\nHost: ";
static const char *http_host_replace = "\r\nhoSt: "; static const char *http_host_replace = "\r\nhoSt: ";
static const char *http_useragent_find = "\r\nUser-Agent: "; static const char *http_useragent_find = "\r\nUser-Agent: ";
static const char *location_http = "\r\nLocation: http://"; static const char *location_http = "\r\nLocation: http://";
static const char *connection_close = "\r\nConnection: close";
static const char *http_methods[] = { static const char *http_methods[] = {
"GET ", "GET ",
"HEAD ", "HEAD ",
@@ -61,9 +77,15 @@ static char* dumb_memmem(const char* haystack, int hlen, const char* needle, int
} }
static HANDLE init(char *filter, UINT64 flags) { static HANDLE init(char *filter, UINT64 flags) {
LPTSTR errormessage = NULL;
filter = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags); filter = WinDivertOpen(filter, WINDIVERT_LAYER_NETWORK, 0, flags);
if (filter != INVALID_HANDLE_VALUE) if (filter != INVALID_HANDLE_VALUE)
return filter; return filter;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT),
(LPTSTR)&errormessage, 0, NULL);
printf("%s", errormessage);
return NULL; return NULL;
} }
@@ -91,8 +113,9 @@ static int is_passivedpi_redirect(const char *pktdata, int pktlen) {
if (memcmp(pktdata, http11_redirect_302, strlen(http11_redirect_302)) == 0 || if (memcmp(pktdata, http11_redirect_302, strlen(http11_redirect_302)) == 0 ||
memcmp(pktdata, http10_redirect_302, strlen(http10_redirect_302)) == 0) memcmp(pktdata, http10_redirect_302, strlen(http10_redirect_302)) == 0)
{ {
/* Then check if this is a redirect to new http site */ /* Then check if this is a redirect to new http site with Connection: close */
if (dumb_memmem(pktdata, pktlen, location_http, strlen(location_http))) { if (dumb_memmem(pktdata, pktlen, location_http, strlen(location_http)) &&
dumb_memmem(pktdata, pktlen, connection_close, strlen(connection_close))) {
return 1; return 1;
} }
} }
@@ -230,21 +253,30 @@ int main(int argc, char *argv[]) {
filter_num = 0; filter_num = 0;
if (do_passivedpi) { if (do_passivedpi) {
/* Filter for inbound RST packets with ID = 0 or 1 */ /* IPv4 filter for inbound RST packets with ID = 0 or 1 */
filters[filter_num] = init("inbound and (ip.Id == 0x0001 or ip.Id == 0x0000) and " filters[filter_num] = init(
"(tcp.SrcPort == 443 or tcp.SrcPort == 80) and tcp.Rst", "inbound and ip and tcp and "
WINDIVERT_FLAG_DROP); "(ip.Id == 0x0001 or ip.Id == 0x0000) and "
"(tcp.SrcPort == 443 or tcp.SrcPort == 80) and tcp.Rst and "
DIVERT_NO_LOCALNETS_SRC,
WINDIVERT_FLAG_DROP);
filter_num++; filter_num++;
} }
/* /*
* Filter for inbound HTTP redirection packets and * IPv4 filter for inbound HTTP redirection packets and
* active DPI circumvention * active DPI circumvention
*/ */
filters[filter_num] = init("(inbound and (ip.Id == 0x0001 or ip.Id == 0x0000) and tcp.SrcPort == 80 and tcp.Ack) " filters[filter_num] = init("ip and tcp and "
"or (inbound and (tcp.SrcPort == 80 or tcp.SrcPort == 443) and tcp.Ack and tcp.Syn) " "(inbound and (("
"or (outbound and (tcp.DstPort == 80 or tcp.DstPort == 443) and tcp.Ack)", "((ip.Id == 0x0001 or ip.Id == 0x0000) and tcp.SrcPort == 80 and tcp.Ack) or "
0); "((tcp.SrcPort == 80 or tcp.SrcPort == 443) and tcp.Ack and tcp.Syn)"
") and " DIVERT_NO_LOCALNETS_SRC ") or "
"(outbound and "
"(tcp.DstPort == 80 or tcp.DstPort == 443) and tcp.Ack and "
DIVERT_NO_LOCALNETS_DST ")"
")",
0);
w_filter = filters[filter_num]; w_filter = filters[filter_num];
filter_num++; filter_num++;