Skip to content

Commit

Permalink
Upgrade to WinDivert 2.0
Browse files Browse the repository at this point in the history
- Tallow now uses the WinDivert SOCKET layer to
  detect and whitelist Tor traffic.
- Tor is now configured to listen on the loopback
  address (127.0.0.1) only.  This required some
  design changes, but should hopefully be address
  the windows firewall (false positive) warnings.
  • Loading branch information
basil00 committed Mar 16, 2019
1 parent 63c8f2d commit b8c2dc1
Show file tree
Hide file tree
Showing 12 changed files with 701 additions and 568 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CFLAGS = --std=c99 -O2 -I contrib/$(WINDIVERT)/include/ -mwindows -mthreads \
-mno-ms-bitfields -m32 -Wall -DVERSION=$(VERSION)
CLIBS = -lws2_32 -lkernel32 -L contrib/$(WINDIVERT)/x86/ -lWinDivert \
-lcomctl32 -liphlpapi -mwindows
OBJS = main.o redirect.o domain.o allow.o
OBJS = main.o redirect.o domain.o
PROG = tallow.exe

$(PROG): $(OBJS)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2
2.0
230 changes: 0 additions & 230 deletions allow.c

This file was deleted.

26 changes: 0 additions & 26 deletions allow.h

This file was deleted.

8 changes: 4 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# (C) 2018, all rights reserved,
# (C) 2019, all rights reserved,
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand All @@ -20,8 +20,8 @@

set -e

WINDIVERT=WinDivert-1.4.2-A-MINGW
TOR=tor-win32-0.3.3.7
WINDIVERT=WinDivert-2.0.0-rc
TOR=tor-win32-0.3.5.7
VERSION=`cat VERSION`

echo "Checking for dependencies..."
Expand Down Expand Up @@ -66,7 +66,7 @@ echo "Copying \"LICENSE\"..."
cp LICENSE install/.

for FILE in \
"$WINDIVERT/x86_64/WinDivert64.sys" \
"$WINDIVERT/x64/WinDivert64.sys" \
"$WINDIVERT/x86/WinDivert32.sys" \
"$WINDIVERT/x86/WinDivert.dll" \
"Tor/libeay32.dll" \
Expand Down
10 changes: 5 additions & 5 deletions domain.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* domain.c
* Copyright (C) 2015, basil
* Copyright (C) 2019, basil
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -121,13 +121,13 @@ extern uint32_t domain_lookup_addr(const char *name0)

if (domain_blacklist_lookup(blacklist, name0))
{
debug("Block %s\n", name0);
debug(RED, "BLOCK", "%s", name0);
return 0; // Blocked!
}

if (InterlockedIncrement64(&rate) >= RATE_LIMIT)
{
debug("Block (rate limit)\n");
debug(RED, "BLOCK", "%s (rate limit)", name0);
return 0;
}

Expand All @@ -139,7 +139,7 @@ extern uint32_t domain_lookup_addr(const char *name0)
if (names[idx] != NULL)
{
// Name table is full!
debug("Block %s (name entry is full)\n", name0);
debug(RED, "BLOCK", "%s (name entry is full)", name0);
return 0;
}

Expand Down Expand Up @@ -220,7 +220,7 @@ extern void domain_cleanup(size_t count)
unlock(names_lock);

if (old_name != NULL)
debug("Cleanup name %s\n", old_name->name);
debug(YELLOW, "CLEANUP", "%s", old_name->name);
domain_deref(old_name);
}
}
Expand Down
6 changes: 4 additions & 2 deletions domain.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* domain.h
* Copyright (C) 2015, basil
* Copyright (C) 2019, basil
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand All @@ -21,8 +21,10 @@

#include <stdint.h>

#define ADDR_BASE 0x2C000000 // 44.0.0.0/24 (AMPRNet)
#define ADDR_BASE 0x2C000000 // 44.0.0.0/8 (AMPRNet)
#define ADDR_MAX 0x2CFFFFFF
#define ADDR_BASE_STR "44.0.0.0"
#define ADDR_MAX_STR "44.255.255.255"

static inline bool is_fake_addr(uint32_t addr)
{
Expand Down

0 comments on commit b8c2dc1

Please sign in to comment.