Force Proxy to any Windows/MacOS/Linux Application TCP and UDP traffic
C ccybersecurityhttp3httpproxylinuxlinux-proxymacosmacos-appmacos-proxyproxifierproxifier-alternativeproxyclienttcpthick-clientudpwindivertwindows
ci(linux): get a real bpftool on Ubuntu runners
anof-cyber9a366b0a6ff9
diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.ymlindex 00d0484..1e3eb81 100644--- a/.github/workflows/build-linux.yml+++ b/.github/workflows/build-linux.yml@@ -29,12 +29,24 @@ jobs:gcc \make \clang \- bpftool \+ linux-tools-common \+ linux-tools-generic \libbpf-dev \libgtk-3-dev \pkg-configshell: bash+ - name: Locate bpftool+ # On Ubuntu "bpftool" is only a virtual package; the real binary ships in linux-tools-* and is not on PATH+ # for the runner's cloud kernel, so find it explicitly.+ run: |+ shopt -s nullglob+ candidates=(/usr/lib/linux-tools/*/bpftool)+ [ ${#candidates[@]} -gt 0 ] || { echo "bpftool binary not found"; ls /usr/lib/linux-tools 2>&1 || true; exit 1; }+ echo "BPFTOOL=${candidates[0]}" >> "$GITHUB_ENV"+ "${candidates[0]}" version | head -1+ shell: bash+- name: Verify dependenciesrun: |echo "=== Checking GCC ==="@@ -53,7 +65,7 @@ jobs:clang --version | head -1echo ""echo "=== Checking bpftool (skeleton generator) ==="- bpftool version | head -1+ "$BPFTOOL" version | head -1echo ""echo "=== Checking libbpf ==="pkg-config --modversion libbpf@@ -151,7 +163,7 @@ jobs:fail=0for t in e2e e2e_rules e2e_domains api_live; doecho "::group::$t"- sudo env PB_DIR="$PWD/Linux/output" bash "Linux/tests/$t.sh" || fail=1+ sudo env PB_DIR="$PWD/Linux/output" BPFTOOL="$BPFTOOL" bash "Linux/tests/$t.sh" || fail=1echo "::endgroup::"doneexit $faildiff --git a/.github/workflows/release-linux.yml b/.github/workflows/release-linux.ymlindex fcdcf21..8965bfc 100644--- a/.github/workflows/release-linux.yml+++ b/.github/workflows/release-linux.yml@@ -28,12 +28,24 @@ jobs:gcc \make \clang \- bpftool \+ linux-tools-common \+ linux-tools-generic \libbpf-dev \libgtk-3-dev \pkg-configshell: bash+ - name: Locate bpftool+ # On Ubuntu "bpftool" is only a virtual package; the real binary ships in linux-tools-* and is not on PATH+ # for the runner's cloud kernel, so find it explicitly.+ run: |+ shopt -s nullglob+ candidates=(/usr/lib/linux-tools/*/bpftool)+ [ ${#candidates[@]} -gt 0 ] || { echo "bpftool binary not found"; ls /usr/lib/linux-tools 2>&1 || true; exit 1; }+ echo "BPFTOOL=${candidates[0]}" >> "$GITHUB_ENV"+ "${candidates[0]}" version | head -1+ shell: bash+- name: Build projectrun: |cd Linuxdiff --git a/Linux/build.sh b/Linux/build.shindex a3e694e..96f2672 100755--- a/Linux/build.sh+++ b/Linux/build.sh@@ -18,7 +18,9 @@ need() { # command, install hintneed gcc "Install: sudo apt install build-essential | sudo dnf install gcc"need make "Install: sudo apt install make | sudo dnf install make"need clang "Needed to compile the eBPF program. Install: sudo apt install clang | sudo dnf install clang"-need bpftool "Needed to generate the eBPF skeleton. Install: sudo apt install bpftool | sudo dnf install bpftool"+BPFTOOL="${BPFTOOL:-bpftool}" # set BPFTOOL=/path/to/bpftool if it is not on PATH (e.g. /usr/lib/linux-tools/*/bpftool on Ubuntu)+export BPFTOOL+need "$BPFTOOL" "Needed to generate the eBPF skeleton. Install: sudo apt install linux-tools-generic (Ubuntu) | sudo apt install bpftool (Debian) | sudo dnf install bpftool"if [ ! -f /usr/include/bpf/libbpf.h ] && ! pkg-config --exists libbpf 2>/dev/null; thenecho "ERROR: libbpf development files not found. Install: sudo apt install libbpf-dev | sudo dnf install libbpf-devel"exit 1diff --git a/Linux/tests/e2e.sh b/Linux/tests/e2e.shindex 9106ca5..2607b05 100755--- a/Linux/tests/e2e.sh+++ b/Linux/tests/e2e.sh@@ -137,7 +137,7 @@ echo "== lifecycle"kill -INT "$PB_PID"; wait "$PB_PID" 2>/dev/nullout=$(curl -s -m 3 http://192.0.2.7/ 2>&1; echo "rc=$?")[[ "$out" != *hello-from* ]] && ok "after stop traffic is no longer redirected" || bad "still redirected after stop"-bpftool prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left behind" || ok "BPF programs detached"+"${BPFTOOL:-bpftool}" prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left behind" || ok "BPF programs detached"ss -ltn 2>/dev/null | grep -qE ":2401[0-9]" && bad "relay ports still listening" || ok "relay ports released"echodiff --git a/Linux/tests/e2e_domains.sh b/Linux/tests/e2e_domains.shindex 6f8c4c9..8cf9b0c 100755--- a/Linux/tests/e2e_domains.sh+++ b/Linux/tests/e2e_domains.sh@@ -64,7 +64,7 @@ grep -q "192.0.2.77 (app.example.test)" "$WORK/pb.out" && ok "connection log shoecho "== lifecycle"kill -INT "$PB_PID"; wait "$PB_PID" 2>/dev/nullout=$(dig @$DNSIP app.example.test +short +time=3 +tries=1 | head -1); has "DNS still works after ProxyBridge stops" "$out" "192.0.2.77"-bpftool prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left behind" || ok "BPF programs detached"+"${BPFTOOL:-bpftool}" prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left behind" || ok "BPF programs detached"echo; echo "passed=$PASS failed=$FAIL"[ "$FAIL" = 0 ] || { echo "---- dns log"; cat "$DLOG"; echo "---- proxy log"; cat "$PLOG"; echo "---- pb output"; tail -30 "$WORK/pb.out"; exit 1; }diff --git a/Linux/tests/gui_headless.sh b/Linux/tests/gui_headless.shindex ae4c1d2..d3e9d48 100755--- a/Linux/tests/gui_headless.sh+++ b/Linux/tests/gui_headless.sh@@ -52,7 +52,7 @@ chmod 600 "$WORK/cfg/config.ini"run_gui() { # active profilewrite_cfg "$1"GDK_BACKEND=broadway BROADWAY_DISPLAY=:9 PROXYBRIDGE_CONFIG_DIR="$WORK/cfg" LD_LIBRARY_PATH="$LIBDIR" "$GUI" > "$WORK/gui.out" 2>&1 & GUI_PID=$!- for _ in $(seq 60); do bpftool prog show 2>/dev/null | grep -q pb_connect4 && break; kill -0 $GUI_PID 2>/dev/null || break; sleep 0.25; done+ for _ in $(seq 60); do "${BPFTOOL:-bpftool}" prog show 2>/dev/null | grep -q pb_connect4 && break; kill -0 $GUI_PID 2>/dev/null || break; sleep 0.25; donesleep 1}stop_gui() {@@ -64,7 +64,7 @@ stop_gui() {echo "== profile Default"run_gui Defaultkill -0 $GUI_PID 2>/dev/null && ok "GUI started under Broadway" || { bad "GUI died: $(head -5 "$WORK/gui.out")"; }-bpftool prog show 2>/dev/null | grep -q pb_connect4 && ok "engine started by the GUI (eBPF programs attached)" || bad "no eBPF programs"+"${BPFTOOL:-bpftool}" prog show 2>/dev/null | grep -q pb_connect4 && ok "engine started by the GUI (eBPF programs attached)" || bad "no eBPF programs"out=$(curl -s -m 5 http://192.0.2.7/); has "rule 1 from the config file: curl -> proxy a" "$out" "hello-from-A dst=192.0.2.7:80"out=$(curl -s -m 5 http://198.51.100.7/); has "rule 2: curl -> proxy b (with credentials from the config)" "$out" "hello-from-B dst=198.51.100.7:80"out=$(curl -s -m 5 http://203.0.114.7/ 2>&1; echo "rc=$?"); has "rule 3: BLOCK" "$out" "rc=7"@@ -72,7 +72,7 @@ out=$(curl -s -m 2 http://203.0.113.7/ 2>&1; echo "rc=$?"); [[ "$out" != *hello-ip4=$(dig @$DNSIP app.example.test +short +time=3 +tries=1 | head -1)out=$(curl -s -m 5 http://$ip4/); has "domain rule from the config (*.example.test -> b) after a real DNS lookup" "$out" "hello-from-B dst=192.0.2.77:80"stop_gui-bpftool prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left after GUI exit" || ok "programs detached after GUI exit"+"${BPFTOOL:-bpftool}" prog show 2>/dev/null | grep -q pb_connect && bad "BPF programs left after GUI exit" || ok "programs detached after GUI exit"echo "== profile Alt (same GUI, different active profile)"run_gui Altdiff --git a/Linux/tests/scale.sh b/Linux/tests/scale.shindex 16ef4d0..7ff3dca 100755--- a/Linux/tests/scale.sh+++ b/Linux/tests/scale.sh@@ -14,7 +14,7 @@ sleep 1stdbuf -oL "$PB_DIR/ProxyBridge" --proxy a=socks5://127.0.0.1:19080 --rule "python3*:192.0.2.0/24:*:TCP:PROXY=a" > $WORK/pb.out 2>&1 & PB=$!for _ in $(seq 40); do grep -q "ProxyBridge started" $WORK/pb.out && break; sleep 0.25; donerss() { awk '/VmRSS/{print $2}' /proc/$PB/status; }-maps_kb() { bpftool map show 2>/dev/null | grep -oE 'memlock [0-9]+' | awk '{s+=$2} END{printf "%d", s/1024}'; }+maps_kb() { "${BPFTOOL:-bpftool}" map show 2>/dev/null | grep -oE 'memlock [0-9]+' | awk '{s+=$2} END{printf "%d", s/1024}'; }echo "baseline: ProxyBridge RSS=$(( $(rss) / 1024 )) MB BPF maps=$(maps_kb) KB threads=$(ls /proc/$PB/task | wc -l)"CPU0=$(awk '{print $14+$15}' /proc/$PB/stat)rm -f /tmp/pb_scale_ready /tmp/pb_scale_go