spoof-tunnel

ParsaKSHApache-2.0更新放缓

基于 eBPF/XDP 的客户端-服务端隧道,利用 IP 欺骗绕过三层防火墙和网络审查,实现受限网络下的连通。

client-server tunnel with IP-Spoofing

v3.1.0-beta.0发布于 2026-05-22 01:11 UTC364star115fork同步于 2026-11-07 07:34 UTC

怎么上手

由 README 提炼,执行前请确认
bash <(curl -Ls https://raw.githubusercontent.com/ParsaKSH/spoof-tunnel/main/panel/install.sh)
硬件要求按 README 说明

README 未说明具体 CPU/内存/显存要求;需 Linux 环境,两端服务器都必须具备发送伪造源 IP 包的能力,运行需 root 或 CAP_NET_RAW 权限。

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

用双向 IP 伪造把隧道流量伪装成单向包,绕过 DPI 和有状态防火墙

基于 eBPF/XDP 的客户端-服务端隧道,利用 IP 欺骗绕过三层防火墙和网络审查,实现受限网络下的连通。

核心能力

  • 客户端与服务端互相伪造源 IP,解耦逻辑会话与物理地址
  • 用 raw socket 手工构造 IPv4/IPv6 头并计算校验和
  • 支持 ICMP Echo、ICMPv6、UDP、TCP SYN 四种承载
  • 用户态实现类 TCP 可靠性层:序列号、ACK 位图、重传
  • 单主会话内用 StreamID 多路复用 SOCKS5 连接

容易踩的坑

两端都必须能发送伪造包,建议先用内置 spoof-tester 或 iptables SNAT 加 tcpdump 验证;raw socket 需要 root 或 CAP_NET_RAW,普通用户直接跑会失败;启动前须用 ./spoof keygen 生成密钥并互换双方公钥填入配置。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v3.1.0-beta.0
  1. v3.1.0-beta.0最新正式版2026-05-22 · 2026-05-22 01:11 UTC

    High-Performance XDP/eBPF Transport (Kernel Bypass)

    This release introduces a major architectural upgrade to the Spoof Tunnel transport layer by integrating eBPF and XDP (eXpress Data Path). By bypassing the traditional Linux kernel networking stack, the tunnel now achieves significantly higher throughput and lower CPU overhead on the receiver end.

    Key Features

    eBPF/XDP Kernel-Bypass: Receivers can now intercept and process TCP/UDP/ICMP packets at the NIC driver level before they reach the kernel's sk_buff allocation layer. Zero-Copy to Userspace: Packets are parsed and validated inside the kernel, and their payloads are sent directly to the Go transport layer via a high-performance BPF Ring Buffer. Automatic Fallback: If XDP is unsupported by the kernel (needs Linux ≥ 5.8) or fails to attach, the system automatically falls back to the standard raw socket implementation with zero configuration changes. Configurable Interface: Easily enable XDP by specifying the network interface (e.g., xdp_interface: "enp1s0") in the JSON configuration.

    Technical Improvements & Fixes

    Advanced BPF Verifier Bypass: Implemented sophisticated inline assembly (core::arch::asm!) to satisfy strict kernel verifier constraints for dynamic length checking, bypassing LLVM optimizer issues. Robust IP Fragmentation Handling: XDP automatically detects IP fragments (MF flag or frag offset > 0) and passes them to the standard kernel stack, ensuring seamless compatibility with high MTU WireGuard setups. Cross-Language FFI: Cleanly separated the Rust workspace into spoof-transport (raw sockets), xdp-ebpf (kernel program), and xdp-loader (Aya userspace manager) with seamless CGo bindings.

    Performance Impact

    In benchmark testing (WireGuard MTU 1328), the XDP receiver delivered a ~74% increase in maximum throughput (780 Mbps vs 448 Mbps) while eliminating kernel-side packet drops.

    • How to use Add the xdp_interface field to your receiver node's configuration:
    {
      "xdp_interface": "eth0"
    }
    

    What's Changed

    Full Changelog: https://github.com/ParsaKSH/spoof-tunnel/compare/v3.0.3-beta.0...v3.1.0-beta.0

  2. v3.0.3-beta.0pre-release2026-05-17 · 2026-05-17 14:20 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/ParsaKSH/spoof-tunnel/compare/v3.0.2...v3.0.3-beta.0

  3. v3.0.22026-05-16 · 2026-05-16 11:37 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/ParsaKSH/spoof-tunnel/compare/v3.0.1...v3.0.2

  4. v3.0.2-beta.0pre-release2026-05-09 · 2026-05-09 20:25 UTC
    查看更新说明
  5. v3.0.12026-05-06 · 2026-05-06 23:20 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/ParsaKSH/spoof-tunnel/compare/v1.0.3...v3.0.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Spoof Tunnel

    Persian-فارسی

    Spoof Tunnel is a Layer 3/Layer 4 tunneling proxy designed to bypass Deep Packet Inspection (DPI) and strict stateful firewalls through mutual bidirectional IP spoofing.

    Unlike traditional tunneling protocols that establish a stateful connection between a fixed client IP and a fixed server IP, Spoof Tunnel completely decouples the logical session from the physical network addresses by forging the Source IP field in the IP header at both endpoints.

    [!IMPORTANT] Both your servers must be able to send spoofed packets.

    To test this, you can use the following command temporarily on any of your servers:

    iptables -t nat -A POSTROUTING -d target-ip -j SNAT --to-source spoof-ip

    then:

    ping target-ip

    and use a tool like tcpdump on the opposite server:

    tcpdump icmp

    if you see the spoofed packets, means your source side can send spoofed packets.

    You can also use the much more accurate spoof-tester tool built into the core and panel. (It is highly recommended to use it before configuring your tunnel.)

    How the Project Came to Be: The Origin of Spoof Tunnel

    The concept of a bidirectional spoofing tunnel emerged in response to the severe internet blackout in Iran following the bloody uprising on January 8 and 9, 2026 (18-19 Dey 1404). During this complete disconnection from the global internet, our primary objective was to reverse-engineer the exact scope and layer of the imposed restrictions.

    Upon investigating the BGP routes for Iranian IP prefixes, we observed a surprising detail: unlike the internet shutdown in Afghanistan where BGP routes simply disappeared, Iran's IP ranges were still actively being announced globally. This strongly indicated that the international physical infrastructure was still intact.

    Subsequently, it became apparent that certain government-affiliated Iranian entities were able to whitelist their specific IP addresses, successfully restoring their international connectivity. This observation led to the hypothesis that the restriction was being enforced at Layer 3, specifically filtering based on srcIP and dstIP.

    This hypothesis was definitively confirmed when we discovered that a select few foreign IP addresses (such as specific ranges from Hetzner) could still establish inbound connections to Iran. The evidence clearly demonstrated that the "blackout" was not a physical severance, but rather a stringent, whitelist-based Layer 3 firewall policy.

    In this highly restricted environment, the idea of a spoofing tunnel was conceived. By manipulating the IP headers, we could simulate whitelisted traffic. However, as is inherent to IP spoofing, if a spoofed packet is sent to a server, the server will inherently route its reply back to the spoofed IP address—not the actual origin host.

    Therefore, a standard unidirectional spoof was insufficient. We required a robust bidirectional mutual spoofing mechanism where both the client and the server forge their IP headers and are predetermined instances well-aware of each other's actual physical IPs, enabling them to establish and maintain a logical connection despite the asymmetrical, forged routing.

    Quick Install (Tunnel Core + GUI Panel):

    bash <(curl -Ls https://raw.githubusercontent.com/ParsaKSH/spoof-tunnel/main/panel/install.sh)
    

    1. Core Architecture: Mutual IP Spoofing

    1.1 Asymmetric Data Flow

    In a typical scenario, the client and server agree on specific IP addresses to spoof:

    • Client → Server (Upload): The client transmits packets with a forged source IP (e.g., Client_Spoof_IP) addressed to the server's actual listening IP.
    • Server → Client (Download): The server responds by transmitting packets with a forged source IP (e.g., Server_Spoof_IP) addressed to the client's actual IP.

    This creates a scenario where intermediate firewalls see unidirectional flows that do not logically match any active state mappings, effectively bypassing connection tracking tables (conntrack) and traffic fingerprinting.

    1.2 Raw Socket Implementation

    To inject packets with arbitrarily modified Layer 3 headers, Spoof Tunnel utilizes raw sockets (AF_INET, SOCK_RAW). It constructs the entire IPv4/IPv6 header manually, calculating the corresponding IP checksums in software.

    • gopacket and pcap are heavily utilized to bypass the host kernel's network stack.
    • BPF Filters: To prevent the host OS from dropping inbound spoofed packets or responding with ICMP Destination Unreachable / TCP RST, an aggressive Berkeley Packet Filter (BPF) limits the capture scope strictly to the tunnel's expected flow, bypassing local routing limits.

    2. Supported Transports

    2.1 ICMP (Echo Mode)

    The tunnel encapsulates encrypted chunks inside standard ICMP Echo Request (Type 8) and ICMP Echo Reply (Type 0) packets. To network middleboxes, the traffic appears as benign ping sweeps or monitoring traffic.

    2.2 ICMPv6 Mode

    In addition to ICMP, ICMPv6 is also supported. Since firewalls that fully block IPv6 infrastructure tend to place fewer restrictions on the ICMPv6 protocol itself, you can carry your payload using the ICMPv6 protocol number over IPv4.

    2.3 UDP Mode

    Standard UDP datagrams are utilized with dynamically shiftable source ports. The protocol mimics connectionless DNS or custom UDP application patterns.

    2.4 TCP (SYN flag) Mode

    In addition to the other three protocols, plain TCP is supported. During heavy censorship events, the Iranian firewall tends to block UDP and most other protocols first — TCP is typically the last protocol to be fully shut down.


    3. The Reliability Layer

    Because ICMP and UDP provide no delivery guarantees, Spoof Tunnel implements a custom TCP-like reliability layer in user space. This is mandatory for maintaining stable TLS handshakes and in-order stream delivery.

    • Packet Sequencing and ACKs: Every payload packet is wrapped in a SeqDataPacket format containing a monotonic sequence number (4 bytes). The recipient acknowledges data via AckPacket, utilizing a 64-bit acknowledgment bitmap for handling blocks of data efficiently.
    • Flow Control & Buffers: The RecvBuffer maintains an internal map of sequences. Out-of-order packets are buffered and data is strictly delivered to the target socket in-order.
    • Retransmission Engine: An active background goroutine sweeps the SendBuffer every 100ms. Unacknowledged packets exceeding the retransmit_timeout are resent using exponential backoff up to a defined max_retries limit.

    4. Session Multiplexing

    Establishing a new tunnel session incurs significant latency. To mitigate this, Spoof Tunnel implements an internal multiplexer (Mux).

    A single "Master Session" is established over the unreliable link. All incoming local TCP SOCKS5 connections are assigned a virtual 4-byte StreamID and multiplexed within this single master session.

    • 0x01 MuxStreamOpen: Followed by [StreamID:4][TargetLen:2][Target String]
    • 0x02 MuxStreamData: Followed by [StreamID:4][Raw Payload]
    • 0x03 MuxStreamClose: Followed by [StreamID:4]
    • 0x04 MuxStreamAck: Server acknowledgment for successful proxy stream creation.

    5. Cryptography

    Security and obfuscation are enforced via ChaCha20-Poly1305 AEAD. AEAD ensures that not a single byte of the IP payload or tunnel header structure is visible or modifiable by an active MITM attacker without immediately dropping the connection.

    Each session initializes a randomized nonce mechanism to prevent replay attacks, while the static pre-shared Base64 keys act as the master cryptographic secret.


    6. Asymmetric Transport Protocols

    Each client or server can independently choose a different transport protocol for each direction. For example, the client sends via TCP while the server responds via ICMPv6. Choose based on your specific server's censorship constraints.

    7. Simple UDP-Pipe

    Starting from v2, to improve performance and reduce processing overhead, the core has been refactored into a simple UDP pipe. It listens on a UDP port; you send any UDP traffic to it, the core tunnels the packet to the server, and on the server side it forwards to any endpoint you configure.

    As a result, features like FEC, ChaCha20 crypto, SOCKS, ACK/TCP-like system, etc. have been removed from the core.

    The recommended approach is to create a local IPv4/IPv6 tunnel using WireGuard. You can refer to this WireGuard local IPv6 setup script: https://github.com/ParsaKSH/TAQ-BOSTAN/blob/main/wireguard.sh

    On the client side, set the endpoint in /etc/wireguard/TAQBOSTANwg.conf to 127.0.0.1 and the port the client core is listening on. An MTU of 1280 is recommended.

    8. Spoof IP List Support

    Starting from v3, instead of a single spoof IP, you can provide a list of IPs. The core will cycle through them in round-robin order, using a new IP from the list for each outgoing packet.

    The reason for this feature: the infrastructure firewall may enforce bandwidth or volume limits on whitelisted IPs. Using a single IP means its limits directly degrade your tunnel quality.

    To learn how to find valid spoof IPs, see the Spoof Tester section below.

    9. Low-Level Modules Rewritten in Rust

    Starting from v2, the high-load parts of the core responsible for packet-level processing and IP header manipulation have been rewritten in Rust for minimum CPU overhead and maximum performance.

    10. Built-in Spoof Packet Tester & IP Discovery Tool

    10.1 Supported Transports: ICMP & TCP

    The tester module currently supports two protocols — TCP and ICMP — which you can choose based on your needs.

    10.2 IP Range Input Support

    You can provide individual IPs or IP ranges to test which ones can be used for spoofing. The module expands the ranges and sends spoofed packets from each IP individually. The receiver side waits for packets and records any that arrive successfully.

    Supported input formats:

    • Single IP → 192.168.1.1
    • IP range → 192.168.1.1-192.168.1.255
    • CIDR range → 192.168.1.0/24

    10.3 Configurable Packet Loss Threshold

    You can specify the maximum acceptable packet loss percentage per spoof IP on each side.

    10.4 Sender & Receiver Modes

    This module requires two servers (nodes) — one acts as sender, the other as receiver.

    How to use:

    1. Set the client (Iran server) to sender mode. Configure: protocol, IP range file, target IP (foreign server), attempts per IP, max allowed packet loss, and timeout.
    2. Set the server (foreign server) to receiver mode with the same settings.
    3. Start the receiver first, then immediately start the sender.
    4. After the timeout, the receiver will have a list of IPs whose spoofed packets arrived, along with each IP's packet loss rate.
    5. Repeat the process in reverse — client becomes receiver, server becomes sender.
    6. If both servers support spoofing, you'll have a list of valid spoof IPs for each direction.

    Important: The output of the client in receiver mode should be used as the spoof IP list on the server side, and vice versa.


    Starting from v2, a web management panel is included for ease of use. Install it using the install script at: https://github.com/ParsaKSH/spoof-tunnel/blob/main/panel/install.sh

    On Iran-based servers, you may need to run the script steps manually.

    All core features — including the tunnel instances and the tester module — are fully accessible through the panel.


    Usage Instructions

    1. Build the Binary

    Spoof Tunnel is written in Go. You can build it using the standard Go toolchain:

    CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o spoof ./cmd/spoof/
    

    2. Generate Cryptographic Keys

    Before starting the tunnel, generate a pair of Base64 private/public keys for both the server and the client.

    ./spoof keygen
    

    Take note of the Private Key and Public Key. The Server's Public Key must be placed in the Client's peer_public_key field, and vice versa.

    3. Running the Service

    Note: Raw sockets require elevated privileges. You must execute both binaries as root (or assign the CAP_NET_RAW capability).

    On the Server:

    sudo ./spoof -c server-config.json
    

    On the Client:

    sudo ./spoof -c client-config.json
    

    Once connected, the client opens a SOCKS5 proxy on 127.0.0.1:1080 (by default) that routes all traffic through the spoofed tunnel.


    Client Config (v1)

    SectionKeyTypeDescription
    modemodestringMust be "client"
    transporttypestring"udp" or "icmp"
    transporticmp_modestring"echo" or "reply" (ICMP only)
    transportprotocol_numberint0 (default, unused for ICMP/UDP)
    listenaddressstringSOCKS5 listening address (e.g. 127.0.0.1)
    listenportintSOCKS5 listening port (e.g. 1080)
    serveraddressstringRemote server actual IP
    serverportintRemote server port (for UDP)
    spoofsource_ipstringIP this client claims when sending outbound packets
    spoofpeer_spoof_ipstringExpected spoofed source IP of incoming server packets
    cryptoprivate_keystringClient's Base64 private key
    cryptopeer_public_keystringServer's Base64 public key
    performancebuffer_sizeintMain packet buffer size
    performancemtuintMax payload before encapsulation (e.g. 1400)
    performancesession_timeoutintMaster session timeout (seconds)
    performanceworkersintNumber of packet processing goroutines
    performanceread_bufferintKernel socket read buffer size
    performancewrite_bufferintKernel socket write buffer size
    fecenabledboolEnable Reed-Solomon Forward Error Correction
    fecdata_shardsintNumber of data shards
    fecparity_shardsintNumber of parity shards
    logginglevelstring"info", "debug", "warn", or "error"
    loggingfilestringLog file path (empty = stdout)

    Server Config (v1)

    SectionKeyTypeDescription
    modemodestringMust be "server"
    transporttypestring"udp" or "icmp"
    transporticmp_modestring"echo" or "reply" (ICMP only)
    transportprotocol_numberint0 (default)
    listenaddressstringTunnel listening IP (e.g. 0.0.0.0)
    listenportintUDP listening port (ignored for ICMP)
    spoofsource_ipstringIP this server claims when sending outbound packets
    spoofsource_ipv6stringIPv6 version of source_ip
    spoofpeer_spoof_ipstringExpected spoofed source IP of incoming client packets
    spoofpeer_spoof_ipv6stringIPv6 version of peer_spoof_ip
    spoofclient_real_ipstringClient's actual real IP
    spoofclient_real_ipv6stringIPv6 version of client_real_ip
    cryptoprivate_keystringServer's Base64 private key
    cryptopeer_public_keystringClient's Base64 public key
    performancebuffer_sizeintMain packet buffer size
    performancemtuintMax payload before encapsulation
    performancesession_timeoutintMaster session timeout (seconds)
    performanceworkersintNumber of packet processing goroutines
    performanceread_bufferintKernel socket read buffer size
    performancewrite_bufferintKernel socket write buffer size
    reliabilityenabledboolEnable custom TCP-like reliability layer
    reliabilitywindow_sizeintMax unacknowledged packets in flight
    reliabilityretransmit_timeout_msintBase retransmission timeout (ms)
    reliabilitymax_retriesintMax retransmission attempts per packet
    reliabilityack_interval_msintHow often to send ACKs (ms)
    fecenabledboolEnable Reed-Solomon Forward Error Correction
    fecdata_shardsintNumber of data shards
    fecparity_shardsintNumber of parity shards
    keepaliveenabledboolEnable periodic keepalive pings
    keepaliveinterval_secondsintSeconds between keepalive packets
    keepalivetimeout_secondsintSession drop timeout if no activity
    logginglevelstring"info", "debug", "warn", or "error"
    loggingfilestringLog file path (empty = stdout)

    Usage Instructions

    Spoof Tunnel is developed in both Go and Rust. To build from source yourself (instead of using GitHub Actions releases), you need both compilers installed.

    Clone the repository:

    git clone --depth=1 https://github.com/ParsaKSH/spoof-tunnel.git
    

    Enter the project directory:

    cd spoof-tunnel
    

    Build using make:

    make core
    

    To build both the panel and the core (requires Node.js and npm):

    make all
    

    Note: Building manually is not required — you can use pre-built releases from GitHub.

    Client (Local) Config

    KeyTypeDescription
    modestringRole of the core: client or server (local)
    listenstringUDP endpoint the local core listens on (e.g. 127.0.0.1:5000) — send your traffic here
    remotestringServer IP (foreign server)
    remote_portintPort the server listens on (for UDP/TCP)
    recv_portintPort the client listens on (for TCP/UDP)
    spoof-ipstringSingle spoof IP (use if not using a list)
    spoof-ip-filestringPath to spoof IP list file (use instead of single IP)
    spoof-portintSource port placed in outgoing packets (for TCP/UDP)
    send-transportstringTransport the client uses to send packets (ICMP/ICMPv6/TCP/UDP)
    recv-transportstringTransport the server uses to send packets back (ICMP/ICMPv6/TCP/UDP)

    Server (Remote) Config

    KeyTypeDescription
    modestringRole of the core: client or server (remote)
    forwardstringEndpoint to forward received traffic to (e.g. 127.0.0.1:51820)
    client_ipstringClient IP (Iran server)
    client_portintPort the client listens on (for UDP/TCP)
    listen_portintPort the server listens on to receive client packets (for TCP/UDP)
    spoof-ipstringSingle spoof IP (use if not using a list)
    spoof-ip-filestringPath to spoof IP list file (use instead of single IP)
    spoof-portintSource port placed in outgoing packets (for TCP/UDP)
    send-transportstringTransport the server uses to send packets (ICMP/ICMPv6/TCP/UDP)
    recv-transportstringTransport the client uses to send packets to the server (ICMP/ICMPv6/TCP/UDP)

    All config parameters can be provided either in a JSON file and run with ./spoof run -c config.json, or as command-line flags:

    ./spoof remote --forward 127.0.0.1:51820 --spoof-ip-file /path/to/src.txt ...
    

    Support & Donation

    If you find this project useful and would like to support its continued development, you can make a cryptocurrency donation using the link below:


    Developed and tested during the complete Iranian internet blackout following the bloody uprising on 18 and 19 Dey (January 8–9, 2026).