Transparent Tor Proxy โ route all system traffic through Tor
Project description
๐ก๏ธ TTP โ Transparent Tor Proxy
A Linux CLI tool that transparently routes all system traffic through the Tor network using nftables.
Features โข Contribute โข Requirements โข Installation โข Usage โข How It Works
No per-application setup needed โ just sudo ttp start and every connection goes through Tor.
[!CAUTION] TTP is a tool designed to aid privacy by routing traffic through Tor. However, no tool can guarantee 100% anonymity. Your safety also depends on your behavior (e.g., using a regular browser vs. Tor Browser, signing into accounts, etc.). Always use TTP as part of a multi-layered security strategy.
[!WARNING] If you are a whistleblower or are engaging in high-risk activities, DO NOT use TTP. Instead, use officially audited and reliable tools like TailsOS or the Tor Browser directly. The authors and contributors of TTP assume no responsibility for your safety or the consequences of using this software.
๐ค Call for Contributors
We are actively looking for developers to join the TTP project! Whether you are a student looking to learn or a seasoned professional, your help is welcome.
We are particularly seeking Senior Developers with expertise in:
- ๐ก๏ธ Linux Networking (nftables, routing tables, network namespaces).
- ๐ง Tor Internals (daemon configuration, Stem library, circuit management).
- ๐ System-level Python (asynchronous I/O, process management, security best practices).
If you want to contribute to making transparent proxying safer and more robust, please check out our Contributing Guidelines or dive right into the Issues.
โจ Features
- ๐ System-wide transparent proxy โ all TCP traffic is redirected to Tor's TransPort, all DNS queries go through Tor's DNSPort.
- ๐ก๏ธ DNS leak prevention โ dual-mode DNS management (
resolvectl/resolv.conffallback) with symlink-aware detection. - ๐ซ IPv6 leak prevention โ all outgoing IPv6 is blocked to avoid ISP-level leaks.
- ๐ Crash-safe โ a lock file tracks session state; even after
kill -9or a power outage, the next run detects the orphaned session and restores the network. - โก Atomic firewall rules โ
nftablesrules are loaded withnft -f(all-or-nothing), avoiding dangerous intermediate states. - ๐ญ IP rotation โ
ttp refreshrequests a new Tor circuit for a fresh exit IP. - ๐ก๏ธ SELinux optimization โ Compiles a custom SELinux policy from source (
.te) on Fedora/RHEL to allow Tor to bind to necessary ports. No opaque binaries shipped. - ๐ง Multi-distro โ auto-detects
apt-get,pacman,dnf, andzypperfor Tor installation. Handles Debian multi-instance services (tor@default), Fedora (toranonuser), and more. - ๐ ๏ธ Auto-configuration โ validates and sanitizes
torrcbefore starting, removing invalid settings and appending missing options.
โ๏ธ Requirements
- Linux with systemd (tested on Debian 12+, Ubuntu 22.04+, Fedora 40+, Arch Linux)
- Python 3.10+
- nftables (pre-installed on most modern distros)
- Root privileges (required for firewall and DNS modifications)
๐ Installation
Choose the method that best fits your needs. Native packages are strongly recommended for system stability, security, and clean uninstallation.
1. Native Packages (Recommended)
Installing via native packages ensures that all system dependencies (tor, nftables) and kernel-level optimizations (SELinux) are managed by your OS package manager.
- Debian / Ubuntu:
sudo apt install ./packaging/ttp_0.1.1_all.deb - Fedora / RHEL:
sudo dnf install ./packaging/ttp-0.1.1-1.fc43.noarch.rpm - Arch Linux:
cd packaging && makepkg -si
2. Manual Source Install (Developer/Universal)
If you are a developer or want to install from the repository:
git clone https://github.com/onyks-os/TransparentTorProxy.git
cd TransparentTorProxy
sudo ./scripts/install.sh
[!TIP] Why use
./install.sh?
Unlike standard Python installers, this script is "intelligent". On Red Hat-based systems, it detects if SELinux is in Enforcing mode and dynamically compiles a custom policy module (fromttp_tor_policy.te) to allow Tor to bind to the non-standard ports required by TTP (9040, 9053). This kernel-level optimization cannot be performed bypip.
3. Fallback: pipx / pip (PEP 668)
[!WARNING] Note on Linux Distributions (PEP 668)
Recent versions of Ubuntu/Debian prevent globalpip installto protect system stability. Using these methods will bypass TTP's kernel-level optimizations (SELinux) and won't handle system dependencies automatically.
Option A: pipx (Recommended Fallback)
pipx installs TTP in an isolated environment but makes the command available globally.
pipx install transparent-tor-proxy
Option B: Standard pip with venv
If you prefer standard pip, use a virtual environment to avoid the externally-managed-environment error.
# 1. Create the environment
python3 -m venv ~/.local/share/ttp-venv
# 2. Install the package
~/.local/share/ttp-venv/bin/pip install transparent-tor-proxy
# 3. Create a symbolic link to use 'ttp' everywhere
sudo ln -s ~/.local/share/ttp-venv/bin/ttp /usr/local/bin/ttp
[!CAUTION] Uninstallation Warning: Running
pipx uninstallor deleting the venv only removes the Python code. If TTP is active, your firewall and DNS will remain hijacked. Always usettp stopbefore uninstalling via pip, or use./scripts/uninstall.shif you installed via the source script. [!NOTE]
After installation, thettpcommand is available system-wide.
๐ป Usage
[!IMPORTANT] All commands require
sudo. Exceptttp statusandttp --help.
Start the proxy
sudo ttp start
[TTP] Detecting Tor... found (v0.4.9.6), service active (user: debian-tor).
[TTP] Stateless nftables rules applied (Table: inet ttp).
[TTP] DNS set via resolvectl on interface ens3.
[TTP] Waiting for Tor to bootstrap...
[TTP] Tor is 100% bootstrapped.
[TTP] Verifying Tor routing...
[TTP] โ
Session active. Exit IP: 109.70.100.11
[TTP] Use 'ttp stop' to terminate. 'ttp refresh' to change IP.
Stop the proxy
sudo ttp stop
[TTP] Removing nftables rules...
[TTP] Restoring DNS...
[TTP] ๐ด Session terminated. Traffic in cleartext.
Change exit IP
sudo ttp refresh
Sends NEWNYM to Tor via the control interface โ all active circuits are rotated and you get a new exit IP.
Check status
sudo ttp status
[TTP] Status: ACTIVE
[TTP] Exit IP: 185.181.61.201
[TTP] Session started: 2026-04-19T01:07:33.384801+00:00
[TTP] Process PID: 3392
๐ Manual Leak Verification
To confirm that the tunnel is working correctly and no leaks are present:
-
Verify Tor Exit IP:
curl -s https://check.torproject.org/api/ip
-
Verify DNS Routing:
# Should return a valid IP via Tor's DNSPort dig +short A check.torproject.org
-
DNS Leak Test (Terminal):
# This TXT query SHOULD return an EMPTY output dig +short TXT whoami.ipv4.akahelp.net
Note: An empty output is the expected behavior under Tor. Tor's transparent resolver does not support TXT records; if this command returns your real ISP's IP, you have a DNS leak.
-
Web-based Verification: Always perform additional tests on dnsleaktest.com and ipleak.net.
Full Uninstallation
To remove TTP completely from the system:
sudo ./scripts/uninstall.sh
๐ง How It Works
- Detection โ checks if Tor is installed, which systemd service runs the daemon, and dynamically detects the Tor user.
- Installation โ if Tor is missing, detects the system's package manager and installs it automatically.
- Configuration โ sanitizes
torrc, validates withtor --verify-config, restarts the correct service. - Firewall โ generates
nftablesrules in a dedicatedinet ttptable:- Stateless approach โ no system backups needed; cleanup is an atomic
nft destroy table. - Multi-Chain Protection:
prerouting: Intercepts traffic if TTP is used as a gateway.output(NAT): Redirects local TCP/DNS to Tor's ports.filter_out(Filter): Acts as a Kill-Switch.
- Execution Sequence:
- Exclude Tor user (prevents routing loops).
- Exclude root processes (system stability).
- Intercept DNS (UDP
:53) and redirect to Tor's DNSPort. - Accept loopback and local traffic (required for redirected packets).
- Redirect all TCP to Tor's TransPort (
:9040). - Drop all IPv6 output to prevent leaks.
- Kill-Switch (Reject): Terminate any cleartext traffic that bypassed redirection (e.g., pre-existing connections).
- Stateless approach โ no system backups needed; cleanup is an atomic
- DNS โ redirects DNS resolution to
127.0.0.1viaresolvectlor/etc/resolv.conf. - Bootstrap โ waits for Tor to reach 100% bootstrap via the control interface.
- Verification โ confirms traffic is routed through Tor via multiple endpoints (
check.torproject.org,ipify,ifconfig.me) for resilience. - State โ writes a JSON lock file at
/var/lib/ttp/ttp.lockfor crash recovery.
๐ Crash Recovery
TTP is designed to always restore your network, even in edge cases:
| Scenario | What happens |
|---|---|
ttp stop |
Normal cleanup: firewall restored, DNS restored, lock deleted |
Ctrl+C / kill |
Signal handler catches SIGINT/SIGTERM and runs cleanup before exit |
kill -9 / Power Outage |
Next ttp start detects the orphaned lock file and auto-restores the network |
| Manual emergency | Run sudo ./scripts/restore-network.sh to flush all nftables rules, reset DNS, and delete the lock file |
โ ๏ธ Known Behavior
[!WARNING]
- Tor Browser: Applications using an explicit SOCKS5 proxy will create a double Tor hop. Use a regular browser instead while TTP is active.
- Chromium-based Browsers (DoH Leak): Chrome, Brave, and Edge might use DNS-over-HTTPS (DoH), which bypasses system DNS settings. To prevent leaks:
- Disable "Secure DNS" in browser settings.
- Ideally, avoid Chromium-based browsers entirely while using TTP; use Firefox instead (ensuring its own "DNS over HTTPS" setting is also disabled). This still DOES NOT ensure the absence of leaks.
- IPv6: All IPv6 traffic is blocked to prevent leaks. Future versions may support IPv6 through Tor.
- Exit IP variation: Different connections may show different exit IPs due to Tor stream isolation. After
ttp refresh, all connections get new circuits.
๐งช Development & Testing
TTP uses a Makefile to automate and standardize the testing pipeline. This ensures that every change is verified against unit and integration tests before being committed.
The "Pre-Push" Rule
[!IMPORTANT] Always run
make verifybefore pushing code. If this command fails, the code is NOT ready for production.
Essential Commands
| Command | Goal |
|---|---|
make test |
Runs fast Unit Tests locally (no root needed, fully mocked). |
make integration-debian |
Runs full system tests inside a privileged Docker container (Debian). |
make integration-all |
Runs integration tests for all supported distros (Debian, Fedora, Arch). |
make verify |
The Gold Standard: Runs Unit Tests + All Integration Tests. |
Advanced: Real-World VM Testing
While Docker integration tests are fast and atomic, they don't capture 100% of the kernel/systemd nuances. For critical changes, it is highly recommended to test in a real QEMU VM:
# Start a specific VM (e.g., arch)
./scripts/vm/start.sh arch
# Sync current code to the VM
./scripts/vm/send.sh
# Snapshot management for easy rollbacks
./scripts/vm/snapshot.sh arch save before-risky-test
Diagnostics
If something goes wrong, run the diagnostic command:
sudo ttp diagnose
๐๏ธ Project Structure
โโโ pyproject.toml # Package metadata and dependencies
โโโ README.md
โโโ CONTRIBUTING.md # Contribution guidelines
โโโ SECURITY.md # Security policy
โโโ scripts/ # Installation and VM management scripts
โ โโโ install.sh # System-wide installer
โ โโโ uninstall.sh # System-wide uninstaller
โ โโโ restore-network.sh # Emergency network recovery script
โ โโโ vm/ # QEMU VM management scripts
โโโ assets/ # Branding and demo assets
โ โโโ gif/ # Demo animations
โโโ packaging/ # Build scripts for .deb, .rpm, and Arch packages
โ โโโ build_deb.sh
โ โโโ build_rpm.sh
โ โโโ ttp.spec
โ โโโ PKGBUILD
โ โโโ ttp.service
โโโ ttp/ # Source code
โ โโโ resources/ # Internal package resources (SELinux policies, etc.)
โ โโโ cli.py # Typer entry point
โ โโโ exceptions.py # Custom exception hierarchy
โ โโโ tor_detect.py # Tor detection logic
โ โโโ tor_install.py # Auto-install & configuration
โ โโโ firewall.py # Atomic nftables management
โ โโโ dns.py # DNS leak prevention
โ โโโ state.py # Lock file and crash recovery
โ โโโ tor_control.py # Tor daemon interaction and API
โ โโโ system_info.py # System diagnostic gathering
โโโ tests/ # Unit tests (mocked)
โโโ docs/
โโโ architecture.md # Technical Architecture & Design
๐ค Contributing & Security
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
- Check out our Contributing Guidelines to get started.
- Please review our Security Policy before reporting vulnerabilities.
๐ License
MIT. See LICENSE for more information.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transparent_tor_proxy-0.1.1.tar.gz.
File metadata
- Download URL: transparent_tor_proxy-0.1.1.tar.gz
- Upload date:
- Size: 928.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
17b48427967317e9f1ea446c43c31e1c5d83291b363fdca94a2e516d11dbcba0
|
|
| MD5 |
5fb8d87bbfa22f4e20976901ab3cc9a8
|
|
| BLAKE2b-256 |
16649cd5bc19c0c738dc657f3d7aa018d1cdbf4e8f5d6521acb0103fceca153c
|
File details
Details for the file transparent_tor_proxy-0.1.1-py3-none-any.whl.
File metadata
- Download URL: transparent_tor_proxy-0.1.1-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62bb4d013af281d8a5c7331def8ac959d51ca657699175ac2a0b6f749cf665c2
|
|
| MD5 |
7fb5101635452d3322b174be01236f0c
|
|
| BLAKE2b-256 |
81cdc81e568ab7312ff2e681e46616378156bb685b74de652f421ee4244abcb7
|