Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
docs(linux): describe the eBPF design; update dependencies and ignores
anof-cyberd3f2becd611e
diff --git a/.gitignore b/.gitignoreindex eb335bf..0ebd9fb 100644--- a/.gitignore+++ b/.gitignore@@ -99,6 +99,26 @@ Linux/cli/main.oLinux/cli/proxybridge-cliLinux/src/libproxybridge.soLinux/src/ProxyBridge.o+Linux/src/*.o+Linux/src/proxybridge.skel.h+Linux/src/bpf/*.o+Linux/cli/ProxyBridge+Linux/gui/*.o+Linux/gui/ProxyBridgeGUI+Linux/ProxyBridgeGUI+Linux/src/tests/rules_test+Linux/src/tests/dns_test+Linux/**/*.o+Linux/**/*.skel.h+Linux/**/vmlinux.h+Linux/gui/tests/config_test+Linux/src/tests/relay_test+Linux/src/tests/relay_test_*+Linux/tests/hookbench+Linux/tests/thrbench+Linux/tests/api_live_test+Linux/**/__pycache__/+!Linux/tests/*.pyAndroid/**iOS/**# Windows build intermediates (MSVC import lib / export file / objects)diff --git a/Linux/README.md b/Linux/README.mdindex 11ef83f..521a062 100644--- a/Linux/README.md+++ b/Linux/README.md@@ -34,7 +34,7 @@ curl -Lo deploy.sh https://raw.githubusercontent.com/InterceptSuite/ProxyBridge/This script will:- Download the latest release from GitHub automatically- Detect your Linux distribution-- Install all required dependencies (libnetfilter-queue, iptables, GTK3)+- Install all required dependencies (libbpf, GTK3)- Install ProxyBridge CLI, GUI, and library to system paths- Update library cache (ldconfig)- Verify installation@@ -63,7 +63,7 @@ This script will:```The setup script will:-- Install runtime dependencies (libnetfilter-queue, iptables, GTK3)+- Install runtime dependencies (libbpf, GTK3)- Copy binaries to `/usr/local/bin` (ProxyBridge CLI and GUI)- Copy library to `/usr/local/lib` (libproxybridge.so)- Update library cache@@ -137,8 +137,16 @@ sudo ProxyBridge --proxy socks5://127.0.0.1:1080 \sudo ProxyBridge --proxy socks5://192.168.1.4:4444 \--rule "curl:3.19.110.0-3.19.115.255:*:TCP:PROXY"-# Cleanup after crash (removes iptables rules)-sudo ProxyBridge --cleanup+# Several proxies, each rule picks its own (name=type://[user:pass@]host:port)+sudo ProxyBridge \+ --proxy tor=socks5://127.0.0.1:9050 \+ --proxy burp=http://127.0.0.1:8080 \+ --rule "firefox:*:*:BOTH:PROXY=tor" \+ --rule "curl;wget:*:*:TCP:PROXY=burp" \+ --rule "*:10.0.0.0/8:*:BOTH:DIRECT"++# IPv6 and CIDR targets+sudo ProxyBridge --rule "curl:2001:db8::/32;10.0.0.0/8:443:TCP:PROXY"```#### Command Line Options@@ -146,86 +154,75 @@ sudo ProxyBridge --cleanup```sudo ProxyBridge --help+____ ____ _ _| _ \ _ __ _____ ___ _ | __ ) _ __(_) __| | __ _ ___| |_) | '__/ _ \ \/ / | | | | _ \| '__| |/ _` |/ _` |/ _ \| __/| | | (_) > <| |_| | | |_) | | | | (_| | (_| | __/|_| |_| \___/_/\_\\__, | |____/|_| |_|\__,_|\__, |\___|- |___/ |___/ V3.2.0+ |___/ |___/ V4.0Universal proxy client for Linux applications- Author: Sourav Kalal/InterceptSuite- GitHub: https://github.com/InterceptSuite/ProxyBridge+ Author: Sourav Kalal/InterceptSuite+ GitHub: https://github.com/InterceptSuite/ProxyBridgeUSAGE:- ProxyBridge [OPTIONS]+ cli/ProxyBridge [OPTIONS]OPTIONS:- --proxy <url> Proxy server URL with optional authentication- Format: type://ip:port or type://ip:port:username:password+ --proxy <spec> Add a proxy (repeatable). The first one is the default.+ Format: [name=]type://[user:pass@]host:portExamples: socks5://127.0.0.1:1080- http://proxy.com:8080:myuser:mypass+ work=http://alice:[email protected]:8080+ tor=socks5://[::1]:9050+ Legacy form type://host:port:user:pass is still accepted.Default: socks5://127.0.0.1:4444- --rule <rule> Traffic routing rule (can be specified multiple times)- Format: process:hosts:ports:protocol:action- process - Process name(s): curl, cur*, *, or multiple separated by ;- hosts - IP/host(s): *, google.com, 192.168.*.*, or multiple separated by ; or ,- ports - Port(s): *, 443, 80;8080, 80-100, or multiple separated by ; or ,+ --rule <rule> Traffic routing rule (repeatable, first match wins)+ Format: process:hosts:ports:protocol:action[=proxy]+ process - name or path glob(s): curl, chrom*, *, or several separated by ; or ,+ hosts - IPv4/IPv6, CIDR (10.0.0.0/8), ranges (1.2.3.4-1.2.3.9),+ octet patterns (192.168.*.*) or *; several separated by ; or ,+ ports - *, 443, 80;8080, 8000-9000protocol - TCP, UDP, or BOTH- action - PROXY, DIRECT, or BLOCK+ action - PROXY, DIRECT, or BLOCK; PROXY=name (or PROXY=2) picks a specific proxyExamples:curl:*:*:TCP:PROXY- curl;wget:*:*:TCP:PROXY- *:*:53:UDP:PROXY- firefox:*:80;443:TCP:DIRECT+ firefox:*:*:BOTH:PROXY=work+ curl;wget:10.0.0.0/8:*:TCP:DIRECT+ *:*:53:UDP:PROXY=tor- --dns-via-proxy <bool> Route DNS queries through proxy- Values: true, false, 1, 0- Default: true+ --dns-via-proxy <bool> Route DNS queries through the proxy (true/false/1/0, default true)- --verbose <level> Logging verbosity level- 0 - No logs (default)- 1 - Show log messages only- 2 - Show connection events only- 3 - Show both logs and connections+ --verbose <level> 0 none (default), 1 logs, 2 connections, 3 both- --cleanup Cleanup resources (iptables, etc.) from crashed instance- Use if ProxyBridge crashed without proper cleanup+ --cleanup No-op, kept for compatibility: the eBPF programs detach automatically--help, -h Show this help messageEXAMPLES:- # Basic usage with default proxy- sudo ProxyBridge --rule curl:*:*:TCP:PROXY-- # Multiple rules with custom proxy- sudo ProxyBridge --proxy socks5://192.168.1.10:1080 \- --rule curl:*:*:TCP:PROXY \- --rule wget:*:*:TCP:PROXY \- --verbose 2+ sudo cli/ProxyBridge --rule curl:*:*:TCP:PROXY- # Route DNS through proxy with multiple apps- sudo ProxyBridge --proxy socks5://127.0.0.1:1080 \- --rule "curl;wget;firefox:*:*:BOTH:PROXY" \- --dns-via-proxy true --verbose 3+ sudo cli/ProxyBridge --proxy socks5://192.168.1.10:1080 --proxy work=http://proxy.corp:8080 \+ --rule firefox:*:*:BOTH:PROXY --rule curl:*:*:TCP:PROXY=work --verbose 2NOTE:- ProxyBridge requires root privileges to use nfqueue.- Run with 'sudo' or as root user.-+ ProxyBridge needs root and a Linux kernel >= 5.8 with BTF and cgroup v2 (eBPF datapath).+ Credentials given on the command line are visible to other users via ps.```#### Rule Format-**Format:** `process:hosts:ports:protocol:action`+**Format:** `process:hosts:ports:protocol:action[=proxy]`-- **process** - Process name(s): `curl`, `curl;wget;firefox`, `fire*`, or `*`-- **hosts** - Target IP/hostname(s): `*`, `192.168.1.1`, `192.168.*.*`, `10.10.1.1-10.10.255.255`, or `192.168.1.1;10.10.10.10`-- **ports** - Target port(s): `*`, `443`, `80;443;8080`, `80-8000`, or `80;443;8000-9000`+- **process** - Name or path glob(s): `curl`, `curl;wget;firefox`, `fire*`, `*chrome*`, `/usr/bin/*`, or `*`. Matched against the executable's file name and full path, case-sensitive+- **hosts** - `*`, IPv4/IPv6 addresses, CIDR (`10.0.0.0/8`, `2001:db8::/32`), ranges (`10.10.1.1-10.10.255.255`), octet patterns (`192.168.*.*`, `10.1-5.*.*`), **domain names** (`github.com`, `*.github.com`, `api?.example.org`), or a list mixing any of these separated by `;` or `,`. A plain domain matches exactly that name; use `*.` for subdomains. See [Domain rules](#domain-rules)+- **ports** - `*`, `443`, `80;443;8080`, `80-8000`, or `80;443;8000-9000`- **protocol** - `TCP`, `UDP`, or `BOTH`-- **action** - `PROXY`, `DIRECT`, or `BLOCK`+- **action** - `PROXY`, `DIRECT`, or `BLOCK`. `PROXY=name` (or `PROXY=2`, the 1-based position of a `--proxy`) uses a specific proxy; plain `PROXY` uses the first one++Rules are evaluated **in order and the first match wins** (put specific rules before general ones).**Examples:**```bash@@ -239,10 +236,19 @@ NOTE:--rule "fire*:*:*:TCP:PROXY" # Matches firefox, firebird, etc.# Target specific IPs and ports---rule "curl:192.168.*;10.10.*.*:80;443;8080:TCP:PROXY"+--rule "curl:192.168.*.*;10.10.*.*:80;443;8080:TCP:PROXY"++# Specific proxy per rule+--rule "firefox:*:*:BOTH:PROXY=tor"-# IP range matching+# Domain names (exact and wildcard), each rule with its own proxy+--rule "firefox:*.github.com;github.com:443:TCP:PROXY=work"+--rule "*:*.internal.corp:*:BOTH:PROXY=burp"++# IP range / CIDR / IPv6--rule "curl:3.19.110.0-3.19.115.255:*:TCP:PROXY"+--rule "curl:10.0.0.0/8:*:TCP:DIRECT"+--rule "curl:2001:db8::/32:443:TCP:PROXY"# Allow direct connection (bypass proxy)--rule "burpsuite:*:*:TCP:DIRECT"@@ -250,9 +256,30 @@ NOTE:**Notes:**- Process names are case-sensitive on Linux-- Use `*` as the process name to set a default action for all traffic-- Press `Ctrl+C` to stop ProxyBridge-- On crash, use `--cleanup` flag to remove iptables rules+- Interpreted programs (python, node, java) are identified by the interpreter binary, e.g. `python3.12`+- A `PROXY` rule whose proxy does not exist is treated as `BLOCK` (traffic never leaks around a missing proxy)+- Press `Ctrl+C` to stop ProxyBridge; the kernel hooks are removed automatically, even if ProxyBridge crashes++## Domain rules++Applications resolve a name themselves and then connect to an IP address, so the kernel only ever sees the address. To apply domain rules ProxyBridge builds, like the macOS version, an **IP → domain-name map from the DNS answers the application received**:++1. When at least one enabled rule contains a domain pattern, the DNS traffic (UDP and TCP, port 53) of every process covered by such a rule is routed through ProxyBridge's relay, which forwards it to the original resolver unchanged (directly, or through a proxy if your rules say so) and reads the answers.+2. A and CNAME records are recorded (`www.shop.test -> cdn.edge.net -> 198.51.100.7` makes the address match rules for **either** name). The mapping is installed in the kernel **before** the answer is delivered to the application, so even the very first connection already matches.+3. Names are also loaded from `/etc/hosts` at start.+4. The map is bounded (32,768 addresses, oldest evicted first). It has no TTL: an address keeps its names until it is evicted, so applications that cache DNS answers keep matching.++Cost: DNS from covered processes takes one extra loopback hop (about +90 µs per query measured on a loopback test server); processes not covered by any domain rule are not touched at all.++**What domain rules cannot match** (the application never reveals the name to the system):+- DNS-over-HTTPS / DNS-over-TLS (Firefox "Secure DNS", Chrome "Secure DNS", systemd-resolved with DoT): the answers are encrypted. Turn them off in the application or use IP rules+- Addresses that are hard-coded or taken from a config file instead of being resolved+- IPv6 destinations (`AAAA` records are not mapped yet)+- Shared hosting: if two names share one IP, whichever name was resolved last matches; a rule for the other name matches too++## Multiple proxies++Add as many `--proxy` entries (CLI) or proxies (GUI) as you need; each rule chooses its own with `PROXY=name`. Proxy hosts may be IP addresses or **host names** (resolved with a 5 s deadline and a cache, so a slow resolver cannot stall traffic). A rule that references a proxy that no longer exists blocks instead of leaking.## Use Cases@@ -266,29 +293,23 @@ NOTE:## Current Limitations-- **IPv4 only** (IPv6 not supported)-- **WSL (Windows Subsystem for Linux) NOT supported** - Neither WSL1 nor WSL2 work with ProxyBridge:- - **WSL2**: Kernel does not support `nfnetlink_queue` module- - Extension shows as "builtin" but is non-functional at runtime- - NFQUEUE handle creation fails- - **WSL1**: Uses a translation layer instead of a real Linux kernel- - Does not support Netfilter/iptables properly- - NFQUEUE is completely unavailable- - **Works on:** Native Linux, VirtualBox VMs, VMware, cloud instances (AWS, GCP, Azure), bare-metal servers- - **Does NOT work on:** WSL1, WSL2, Docker containers with limited capabilities- - **Windows users:** Use the Windows version of ProxyBridge instead - it's specifically designed for Windows and works perfectly-- **Root privileges required** - NFQUEUE and iptables require root access-- **GUI requires GTK3** - Command-line interface works without GUI dependencies+- **Needs a recent kernel**: Linux 5.8+ with BTF (`/sys/kernel/btf/vmlinux`) and cgroup v2 mounted (default on current Ubuntu, Debian, Fedora, Arch). Older kernels are not supported+- **Root privileges required** - loading the eBPF programs needs root (CAP_BPF/CAP_SYS_ADMIN)+- **Native IPv6 UDP to a PROXY rule fails closed** - an unconnected UDP socket sending to a native IPv6 address cannot be redirected (kernel limitation); the `sendto()` returns `EPERM` and applications fall back to IPv4/TCP. Connected IPv6 UDP sockets, IPv6 TCP and UDP to IPv4 destinations through dual-stack sockets all work+- **IPv4 is the fully supported path**; IPv6 (TCP, connected UDP) works for IP rules but has no domain matching and the limits above+- **IPv6-only (`IPV6_V6ONLY`) sockets** connecting to a proxied destination fail (the redirect uses a v4-mapped loopback address)+- **Domain rules only see names the application resolved through DNS that ProxyBridge could observe** - see [Domain rules](#domain-rules) for what that means (DoH/DoT and hard-coded IPs are not matched)+- **Only new connections are affected** - connections that were already open when a rule was added/changed keep their route until they reconnect+- **WSL is not supported** - WSL1/WSL2 kernels do not ship BTF/cgroup-BPF. Use native Linux, VMs, cloud instances or bare metal+- **GUI requires GTK3** - the command-line interface works without GUI dependencies## Things to Note-- **DNS Traffic Handling**: DNS traffic on TCP and UDP port 53 is handled separately from proxy rules. Even if you configure rules for port 53, they will be ignored. Instead, DNS routing is controlled by the `--dns-via-proxy` flag (enabled by default). When enabled, all DNS queries are routed through the proxy; when disabled, DNS queries use direct connection.-+- **DNS Traffic Handling**: with `--dns-via-proxy true` (default) DNS (port 53) follows your rules like any other traffic; with `false`, DNS always uses a direct connection regardless of rules.- **Automatic Direct Routing**: Certain IP addresses and ports automatically use direct connection regardless of proxy rules:- - **Broadcast addresses** (255.255.255.255 and x.x.x.255) - Network broadcast- - **Multicast addresses** (224.0.0.0 - 239.255.255.255) - Group communication- - **APIPA addresses** (169.254.0.0/16) - Automatic Private IP Addressing (link-local)+ - **Loopback** (127.0.0.0/8, ::1) and **0.0.0.0/8**+ - **Multicast / broadcast / reserved** (224.0.0.0 and above, ff00::/8) and IPv6 link-local (fe80::/10)- **DHCP ports** (UDP 67, 68) - Dynamic Host Configuration ProtocolThese addresses and ports are used by system components, network discovery, and essential Linux services.@@ -302,9 +323,8 @@ NOTE:- **Testing UDP/HTTP3/DTLS Support**: If you need to test UDP, HTTP/3, and DTLS support with a SOCKS5 proxy, try [Nexus Proxy](https://github.com/InterceptSuite/nexus-proxy) - a proxy application created specifically to test ProxyBridge with advanced UDP protocols.- **Root Privileges**: ProxyBridge requires root access to:- - Create NFQUEUE handles for packet interception- - Add/remove iptables rules in mangle and nat tables- - Listen on relay ports (34010 for TCP, 34011 for UDP)+ - Load the eBPF programs and attach them to the root cgroup+ - Listen on its local relay ports (24010 for TCP, 24011 for UDP; the next free pair is used if they are taken)Always run with `sudo` or as root user.@@ -315,135 +335,45 @@ NOTE:## How It Works-ProxyBridge uses Linux Netfilter NFQUEUE to intercept TCP/UDP packets and applies user-defined rules to route traffic through proxies.--**Case 1: Packet does not match any rules**+ProxyBridge hooks the **socket calls** (`connect()`, `sendmsg()`, `recvmsg()`) with eBPF programs attached to the root cgroup. It never inspects or queues packets, so the TCP data path of every application is untouched.```-Application → TCP/UDP Packet → NFQUEUE → ProxyBridge- ↓- [No Match or DIRECT]- ↓- Packet Verdict: ACCEPT- ↓- Direct Connection → Internet+ application kernel (eBPF, cgroup sock_addr hooks) ProxyBridge (userspace)+ ----------- -------------------------------------- -----------------------+ connect(dst) ───────► which executable is this? ─► which rules apply?+ no rule / DIRECT ─────► unchanged (zero extra cost on the data path)+ BLOCK ─────► connect() fails with EPERM+ PROXY(id) ─────► destination rewritten to 127.0.0.1:relay,+ original destination saved ──────────────► relay reads it,+ talks SOCKS5 / HTTP CONNECT+ cannot decide ─────► sent to the relay as "decide" ───────────► full rule engine decides+ (and teaches the kernel)```-**Case 2: Packet matches proxy rule**--```-Application → TCP/UDP Packet → NFQUEUE → ProxyBridge- ↓- [PROXY Rule Match]- ↓- Packet Verdict: ACCEPT + Mark- ↓- iptables NAT REDIRECT- ↓- Relay Server (34010/34011) ← Packet- ↓- [Store Original Destination]- ↓- SOCKS5/HTTP Protocol Conversion- ↓- Proxy Server (Burp Suite/InterceptSuite)- ↓- Forward to Original Destination- ↓- Internet- ↓- Response Returns- ↓- Relay Server- ↓- [Restore Original Source IP/Port]- ↓- Application Receives Response-```--**Detailed Traffic Flow:**--1. **Applications Generate Traffic** - User-mode applications (curl, wget, firefox, games) create TCP/UDP packets+**Kernel side** ([src/bpf/proxybridge.bpf.c](src/bpf/proxybridge.bpf.c))+- Identifies the calling process by its executable's `(device, inode)` and looks up a precompiled **class** (the ordered list of rules whose process pattern matches that binary). Rules are compiled to bounded map lookups: port ranges, IPv4 ranges and protocol are evaluated in the kernel; anything it cannot express (octet patterns, IPv6 patterns, many ranges) is handled by the relay+- TCP: rewrites the destination to the local relay and passes the original destination via a `sockops` hook keyed by the client's source port+- UDP: encodes the original destination as a loopback **flow address** (`127.x.y.z`); the relay replies from that address and a `recvmsg` hook restores the real source, so one socket can talk to many destinations+- `getpeername()` on redirected sockets returns the original destination+- Memory is bounded: fixed-size maps (about a few MB in total), LRU maps for per-flow state-2. **Kernel Interception** - iptables rules in the mangle table send packets to NFQUEUE:- ```bash- iptables -t mangle -A OUTPUT -p tcp -j NFQUEUE --queue-num 0- iptables -t mangle -A OUTPUT -p udp -j NFQUEUE --queue-num 0- ```--3. **NFQUEUE Delivery** - libnetfilter_queue delivers packets to ProxyBridge in userspace+**Userspace side** ([src/pb_relay.c](src/pb_relay.c), [src/pb_rules.c](src/pb_rules.c), [src/pb_bpf.c](src/pb_bpf.c))+- Rule engine: validation, globs, IPv4/IPv6, CIDR, ranges, first-match-wins; the reference semantics for everything the kernel cannot decide+- epoll based relay with bounded resources: SOCKS5 (with user/pass) and HTTP CONNECT for TCP, SOCKS5 UDP ASSOCIATE for UDP, direct forwarding for the slow path, idle timeouts, connection cap+- Several proxies can be configured; every rule chooses its own+- Binaries the kernel has not seen yet take a one-time slow path through the relay; the result is cached in the kernel so later connections skip it-4. **Rule Evaluation** - ProxyBridge inspects each packet and applies configured rules:- - **BLOCK** → Packet verdict: DROP (no network access)- - **DIRECT** → Packet verdict: ACCEPT (direct connection)- - **NO MATCH** → Packet verdict: ACCEPT (direct connection)- - **PROXY** → Packet verdict: ACCEPT + set mark (1 for TCP, 2 for UDP)--5. **NAT Redirection** - For PROXY-matched packets, iptables NAT rules redirect marked packets:- ```bash- iptables -t nat -A OUTPUT -p tcp -m mark --mark 1 -j REDIRECT --to-port 34010- iptables -t nat -A OUTPUT -p udp -m mark --mark 2 -j REDIRECT --to-port 34011- ```+**Why this design:** an earlier eBPF attempt (3.1.0) evaluated rules per packet in the kernel and was abandoned for memory and latency reasons. This design avoids both problems: decisions are made once per connection (not per packet), rules are compiled into small bounded maps, and everything the kernel cannot express goes to userspace once per connection.-6. **Relay Servers** - Local relay servers (34010 for TCP, 34011 for UDP):- - Intercept redirected packets using getsockopt(SO_ORIGINAL_DST)- - Store original destination IP and port- - Convert raw TCP/UDP to SOCKS5/HTTP proxy protocol- - Perform proxy authentication if configured- - Forward to configured proxy server--7. **Proxy Forwarding** - Proxy server (Burp Suite/InterceptSuite) forwards traffic to the original destination--8. **Response Handling** - Return traffic flows back through relay servers, which restore original source IP/port--**Key Technical Points:**--- **NFQUEUE vs WinDivert**: Linux uses Netfilter NFQUEUE (kernel feature) instead of WinDivert (Windows kernel driver)--- **Why NFQUEUE Instead of eBPF**: While eBPF is the modern approach for Linux networking tasks and offers better performance, ProxyBridge uses NFQUEUE due to fundamental limitations discovered during development:- - **Original Plan**: ProxyBridge 3.1.0 for Linux was initially developed using eBPF after weeks of implementation- - **eBPF Memory Limitations**: eBPF provides limited memory space, which proved insufficient for ProxyBridge's feature set:- - ProxyBridge supports multiple complex proxy rules with wildcard matching, IP ranges, and process patterns- - Storing and evaluating these rules within eBPF's memory constraints was not feasible- - Alternative workarounds added excessive latency (200-500ms+ per packet)- - **Performance Requirements**: ProxyBridge's core design goals couldn't be met with eBPF:- - Work efficiently with minimal memory usage under high load- - Handle high traffic volumes (10,000+ concurrent connections)- - **Network speed impact must be ≤2-5% for proxied traffic only**- - **Zero performance impact on direct (non-proxied) traffic**- - eBPF implementation with all required features caused 15-30% slowdown on all traffic- - **NFQUEUE Advantages**:- - Userspace processing allows unlimited memory for complex rule evaluation- - Selective packet inspection - only examines packets, doesn't slow down uninspected traffic- - Mature, stable kernel interface available on all Linux distributions- - Lower latency than eBPF workarounds when handling complex rule sets-- **Verdict**: NFQUEUE provides the right balance of flexibility, performance, and compatibility for ProxyBridge's requirements. While eBPF excels for simple packet filtering, ProxyBridge's advanced rule engine and protocol conversion needs are better served by NFQUEUE's userspace processing model.--- **Packet Marking**: ProxyBridge marks packets (mark=1 for TCP, mark=2 for UDP) instead of modifying destination-- **iptables Integration**: Uses mangle table (pre-routing processing) + nat table (port redirection)-- **Transparent Redirection**: Applications remain completely unaware of proxying-- **SO_ORIGINAL_DST**: Socket option retrieves original destination after NAT redirect-- **Multi-threaded**: Separate threads for packet processing, TCP relay, UDP relay, and connection cleanup--**Architecture Advantages:**--- No kernel modules required (uses built-in Netfilter)-- Works on any Linux distribution with iptables and NFQUEUE support-- Leverages proven kernel infrastructure (Netfilter/iptables)-- Separate packet marking prevents packet modification in NFQUEUE-- Clean separation: NFQUEUE for inspection, iptables for redirection+**Cleanup:** the programs are attached through BPF links, so the kernel removes them automatically when ProxyBridge exits or crashes. There are no iptables rules or system settings to restore.## Build from Source### Requirements-- Linux kernel with NFQUEUE support (virtually all modern distributions)-- GCC compiler-- Make+- Linux kernel 5.8+ with BTF and cgroup v2 (to run); GCC, Make, **clang** and **bpftool** (to build the eBPF object and skeleton)- Development libraries:- - libnetfilter-queue-dev (Debian/Ubuntu) or libnetfilter_queue-devel (Fedora/RHEL)- - libnfnetlink-dev (Debian/Ubuntu) or libnfnetlink-devel (Fedora/RHEL)+ - libbpf-dev (Debian/Ubuntu) or libbpf-devel (Fedora/RHEL)- libgtk-3-dev (optional, for GUI) or gtk3-devel (Fedora/RHEL)- pkg-config@@ -454,23 +384,20 @@ Application → TCP/UDP Packet → NFQUEUE → ProxyBridge**Debian/Ubuntu/Mint:**```bashsudo apt-get update- sudo apt-get install build-essential gcc make \- libnetfilter-queue-dev libnfnetlink-dev \- libgtk-3-dev pkg-config+ sudo apt-get install build-essential gcc make clang bpftool \+ libbpf-dev libgtk-3-dev pkg-config```**Fedora:**```bash- sudo dnf install gcc make \- libnetfilter_queue-devel libnfnetlink-devel \- gtk3-devel pkg-config+ sudo dnf install gcc make clang bpftool \+ libbpf-devel gtk3-devel pkg-config```**Arch/Manjaro:**```bash- sudo pacman -S base-devel gcc make \- libnetfilter_queue libnfnetlink \- gtk3 pkg-config+ sudo pacman -S base-devel gcc make clang bpf \+ libbpf gtk3 pkg-config```2. **Clone or download ProxyBridge source code:**@@ -515,15 +442,8 @@ After successful build, binaries will be in the `output/` directory:**Library:**```bashcd src-gcc -Wall -Wextra -O3 -fPIC -D_GNU_SOURCE \- -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE \- -Wformat -Wformat-security -Werror=format-security \- -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv \- -c ProxyBridge.c -o ProxyBridge.o--gcc -shared -Wl,-z,relro,-z,now -Wl,-z,noexecstack -s \- -o libproxybridge.so ProxyBridge.o \- -lpthread -lnetfilter_queue -lnfnetlink+make # builds bpf/proxybridge.bpf.o, proxybridge.skel.h and libproxybridge.so+make test-rules # parser/matcher unit tests (ASan + UBSan)```**CLI:**@@ -541,6 +461,8 @@ gcc -o ProxyBridge main.o \-lproxybridge -lpthread```+**Config location:** the GUI stores profiles, proxies and rules in `/etc/proxybridge/config.ini` (mode 0600). Set `PROXYBRIDGE_CONFIG_DIR` to use another directory (used by the tests).+## UninstallationTo remove ProxyBridge from your system:@@ -564,20 +486,7 @@ sudo rm -f /etc/ld.so.conf.d/proxybridge.confsudo ldconfig```-**Cleanup after crash:**--If ProxyBridge crashed and left iptables rules:-```bash-sudo ProxyBridge --cleanup-```--Or manually remove iptables rules:-```bash-sudo iptables -t mangle -D OUTPUT -p tcp -j NFQUEUE --queue-num 0-sudo iptables -t mangle -D OUTPUT -p udp -j NFQUEUE --queue-num 0-sudo iptables -t nat -D OUTPUT -p tcp -m mark --mark 1 -j REDIRECT --to-port 34010-sudo iptables -t nat -D OUTPUT -p udp -m mark --mark 2 -j REDIRECT --to-port 34011-```+**Cleanup after crash:** nothing to do. ProxyBridge attaches its eBPF programs through BPF links, which the kernel removes when the process exits or crashes. To check: `sudo bpftool cgroup tree /sys/fs/cgroup` should list no `pb_*` programs.## License@@ -588,3 +497,19 @@ MIT License - See LICENSE file for details**Author:** Sourav Kalal / InterceptSuite**GitHub:** https://github.com/InterceptSuite/ProxyBridge**Documentation:** https://github.com/InterceptSuite/ProxyBridge/tree/master/Linux++## Testing++```bash+cd Linux/src && make && cd ../cli && make # build+cd ../src && make test-rules # rule engine + DNS parser tests (no root needed)+cd tests && ./run_relay_test.sh both # relay tests, plain and ASan/UBSan (no root needed)+cd ../../tests && sudo ./e2e.sh # end-to-end with real kernel hooks (root)+sudo ./e2e_domains.sh # domain rules with a real resolver client (root, needs dig)+sudo ./e2e_rules.sh # every rule form + every proxy type, incl. HTTP auth and UDP rules (root)+sudo ./api_live.sh # library API: edit/move/disable/delete rules and proxies on the live datapath (root)+sudo ./e2e_openssh.sh # interoperability with a real third-party SOCKS5 server (OpenSSH ssh -D), 40 MB each way (root)+sudo ./scale.sh 10000 # 10,000 concurrent proxied connections (root)+sudo ./gui_headless.sh <ProxyBridgeGUI> <libdir> # the real GTK GUI under the Broadway backend (root, needs broadwayd)+cd ../gui/tests && gcc -I../../src -I.. -D_GNU_SOURCE $(pkg-config --cflags gtk+-3.0) config_test.c ../gui_config.c -o /tmp/config_test $(pkg-config --libs gtk+-3.0) && /tmp/config_test # GUI config/profile tests+```diff --git a/Linux/deploy.sh b/Linux/deploy.shindex d9dd929..a9c64d3 100644--- a/Linux/deploy.sh+++ b/Linux/deploy.sh@@ -150,35 +150,35 @@ install_dependencies() {ubuntu|debian|linuxmint|pop|elementary|zorin|kali|raspbian|mx|antix|deepin|lmde)echo "Using apt package manager..."apt-get update -qq- apt-get install -y libnetfilter-queue1 libnfnetlink0 iptables libgtk-3-0+ apt-get install -y libbpf1 libgtk-3-0;;fedora)echo "Using dnf package manager..."- dnf install -y libnetfilter_queue libnfnetlink iptables gtk3+ dnf install -y libbpf gtk3;;rhel|centos|rocky|almalinux)echo "Using yum package manager..."- yum install -y libnetfilter_queue libnfnetlink iptables gtk3+ yum install -y libbpf gtk3;;arch|manjaro|endeavouros|garuda)echo "Using pacman package manager..."- pacman -Sy --noconfirm libnetfilter_queue libnfnetlink iptables gtk3+ pacman -Sy --noconfirm libbpf gtk3;;opensuse*|sles)echo "Using zypper package manager..."- zypper install -y libnetfilter_queue1 libnfnetlink0 iptables gtk3+ zypper install -y libbpf1 gtk3;;void)echo "Using xbps package manager..."- xbps-install -Sy libnetfilter_queue libnfnetlink iptables gtk3+ xbps-install -Sy libbpf gtk3;;*)echo "WARNING: Unknown distribution '$DISTRO' (family: '$DISTRO_LIKE')"echo ""echo "Please manually install the following packages:"- echo " Debian/Ubuntu: sudo apt install libnetfilter-queue1 libnfnetlink0 iptables libgtk-3-0"- echo " Fedora: sudo dnf install libnetfilter_queue libnfnetlink iptables gtk3"- echo " Arch: sudo pacman -S libnetfilter_queue libnfnetlink iptables gtk3"+ echo " Debian/Ubuntu: sudo apt install libbpf1 libgtk-3-0"+ echo " Fedora: sudo dnf install libbpf gtk3"+ echo " Arch: sudo pacman -S libbpf gtk3"echo ""read -p "Continue anyway? (y/n) " -n 1 -rechodiff --git a/Linux/setup.sh b/Linux/setup.shindex a365a16..55a6ac4 100644--- a/Linux/setup.sh+++ b/Linux/setup.sh@@ -53,36 +53,36 @@ install_dependencies() {ubuntu|debian|linuxmint|pop|elementary|zorin|kali|raspbian|mx|antix|deepin|lmde)echo "Using apt package manager..."apt-get update -qq- # libgtk-3-0 is for runtime, libnetfilter-queue1 for functionality- apt-get install -y libnetfilter-queue1 libnfnetlink0 iptables libgtk-3-0+ # libgtk-3-0 is for the GUI, libbpf for the eBPF datapath+ apt-get install -y libbpf1 libgtk-3-0;;fedora)echo "Using dnf package manager..."- dnf install -y libnetfilter_queue libnfnetlink iptables gtk3+ dnf install -y libbpf gtk3;;rhel|centos|rocky|almalinux)echo "Using yum package manager..."- yum install -y libnetfilter_queue libnfnetlink iptables gtk3+ yum install -y libbpf gtk3;;arch|manjaro|endeavouros|garuda)echo "Using pacman package manager..."- pacman -Sy --noconfirm libnetfilter_queue libnfnetlink iptables gtk3+ pacman -Sy --noconfirm libbpf gtk3;;opensuse*|sles)echo "Using zypper package manager..."- zypper install -y libnetfilter_queue1 libnfnetlink0 iptables gtk3+ zypper install -y libbpf1 gtk3;;void)echo "Using xbps package manager..."- xbps-install -Sy libnetfilter_queue libnfnetlink iptables gtk3+ xbps-install -Sy libbpf gtk3;;*)echo "WARNING: Unknown distribution '$DISTRO' (family: '$DISTRO_LIKE')"echo ""echo "Please manually install the following packages:"- echo " Debian/Ubuntu: sudo apt install libnetfilter-queue1 libnfnetlink0 iptables libgtk-3-0"- echo " Fedora: sudo dnf install libnetfilter_queue libnfnetlink iptables gtk3"- echo " Arch: sudo pacman -S libnetfilter_queue libnfnetlink iptables gtk3"+ echo " Debian/Ubuntu: sudo apt install libbpf1 libgtk-3-0"+ echo " Fedora: sudo dnf install libbpf gtk3"+ echo " Arch: sudo pacman -S libbpf gtk3"echo ""read -p "Continue anyway? (y/n) " -n 1 -recho