sh0rch/packetveil

GitHub: sh0rch/packetveil

packetveil 是一个基于 eBPF/XDP 的 WireGuard 流量混淆器,通过将 UDP 流量伪装为 QUIC、SIP、Syslog 等协议外观来规避 DPI 探测。

Stars: 92 | Forks: 9

# gutd v3 — WireGuard 流量混淆器 (TC/XDP eBPF) [![CI](https://static.pigsec.cn/wp-content/uploads/repos/cas/f9/f917b9541767ed6e6628b7acc1f42d1ccd2380b66fa1f0599a4e6869131d00d7.svg)](https://github.com/sh0rch/gutd/actions/workflows/ci.yml) [![Release](https://static.pigsec.cn/wp-content/uploads/repos/cas/4a/4ae0322030dd3df110b2b8828b0ee4aec2d9de8a4125c57fbbf89b37c2445531.svg)](https://github.com/sh0rch/gutd/actions/workflows/release.yml) ### 基准测试:gutd vs wg-obfuscator | 工具 | TCP 带宽 | UDP 带宽 | UDP 丢包率 | |---|---|---|---| | **gutd (eBPF)** ([v3.0.15](https://github.com/sh0rch/packetveil/releases/tag/v3.0.15)) | 894 Mbits/sec | 794 Mbits/sec | 0.81% | | **gutd (用户态)** ([v3.0.15](https://github.com/sh0rch/packetveil/releases/tag/v3.0.15)) | 592 Mbits/sec | 454 Mbits/sec | 52% | | **wg-obfuscator** ([v1.5](https://github.com/ClusterM/wg-obfuscator/releases)) | 315 Mbits/sec | 221 Mbits/sec | 85% | * 性能测试使用 `iperf3` 在 GitHub Actions 的 Ubuntu 22.04 运行器上的 2 个独立网络命名空间之间进行。[查看测试逻辑和完整日志](https://github.com/sh0rch/packetveil/actions/runs/28407286821)。最后更新:2026-06-29 22:39 **gutd v3** 使用 Linux TC/XDP eBPF 数据路径透明地混淆 WireGuard UDP 流量。在出口流量上,TC BPF 程序将每个 WireGuard 数据包封装在选定的混淆信封中,使用 ChaCha 密钥流掩码有效载荷,并可选地进行填充。在入口流量上,XDP 程序会验证、剥离信封,并在 WireGuard 处理之前恢复原始数据包。WireGuard 完全感知不到 gutd 的存在。提供**纯用户态模式**(与 eBPF 路径线路兼容),适用于旧版内核、非特权容器、MikroTik RouterOS 和 **Windows**。 ## 混淆模式 | 模式 | `obfs=` | 线上表现形式 | 防探测 | 端口 | |---|---|---|---|---| | **QUIC** *(默认)* | `quic` | 伪 QUIC Long Header + SNI(看起来像 HTTPS/3) | XDP 回复 QUIC Version Negotiation | 任意 UDP 端口 | | **GUT** | `gut` | 类 GOST 随机 UDP — 无 QUIC/TLS 特征 | 静默丢弃 | 任意 UDP 端口 | | **SIP/RTP** | `sip` | 信令包封装在 SIP 头中;数据在 RTP 帧中 | XDP 回复 `200 OK` / `401` / `403` | `ports[0]` = SIP (5060),`ports[1+]` = RTP(至少需要 2 个) | | **Syslog** | `syslog` | 有效载荷经过 base64 编码隐藏在伪 syslog 消息中 | 静默丢弃 | 任意 UDP 端口(通常为 514) | 所有模式均在信封基础上应用 ChaCha 有效载荷掩码。通信双方必须使用相同的模式。 ## 功能 - 四种混淆模式:QUIC、GUT(类 GOST 随机 UDP)、SIP/RTP、Syslog —— 可按节点独立选择 - 在 XDP 层主动偏转 DPI 探测(QUIC:Version Negotiation;SIP:`200 OK`/`401`/`403`) - 使用 ChaCha 进行 WireGuard 有效载荷掩码(默认 4 轮) - veth 对上的 TC 出口钩子,物理网卡上的 XDP 入口钩子 - 端口条带化:每个节点支持多个 UDP 端口并按包轮换 - 概率性丢弃 Keepalive 以抑制 WireGuard 时序指纹 - 可变填充以混淆数据包大小 - 通过 SIGHUP 热重载(更新 BPF map,无需重启) - 纯用户态回退模式(零 eBPF 要求,可达约 500 Mbps) - 跨平台:Linux(eBPF + 用户态)、Windows(用户态)、RouterOS(用户态) - 多节点支持(每个节点一对 veth + BPF 程序) - 静态 musl 编译,零 OS 依赖 —— 可在空白的 `scratch` 容器中运行 - IPv4 和 IPv6 外部传输 - 为 NAT 后的客户端提供动态节点端点学习(`peer_ip = dynamic`) - 通过 `gutd status` 或 SIGUSR1 信号查看统计信息 ## 快速开始 在双方节点上生成共享密钥并创建最小化配置: ``` gutd genkey # → prints 256-bit hex key ``` ``` # /etc/gutd/gutd.conf (Linux) # C:\ProgramData\gutd\gutd.conf (Windows) [peer] peer_ip = 203.0.113.10 # remote peer public IP ports = 41000 key = # obfs = quic # quic (default) | gut | sip | syslog ``` ## 运行 ``` # eBPF 模式(Linux 默认,需要 root 且 kernel ≥ 5.17) sudo ./gutd /etc/gutd/gutd.conf # 纯用户空间模式(Linux — 无 eBPF,通过 capabilities 无需 root) GUTD_USERSPACE=1 ./gutd /etc/gutd/gutd.conf # Windows(始终为用户空间,安装时以 Administrator 身份运行) gutd.exe gutd.conf # 无需重启重载配置 (Linux) sudo kill -HUP $(pgrep gutd) ``` ## 构建 ``` # Linux(默认,带 eBPF) cargo build --release # Linux static musl binary ./build-musl.sh # Windows(仅用户空间,从 Linux 交叉编译) cargo build --release --target x86_64-pc-windows-gnu --no-default-features ``` 有关交叉编译和 musl 的详细信息,请参阅 [BUILD.md](BUILD.md)。 ## MTU 参考 每种混淆模式都会给每个 WireGuard 数据包增加不同大小的开销。 对于增加超过 16 字节开销的模式,您**必须**将 WireGuard 接口的 MTU 设置得低于默认的 1420, 否则过大的数据帧会被网络链路静默丢弃。 | 模式 | gutd 添加的头部 | 最大安全 WG MTU\* | |---|---|---| | `quic` | 16 字节 (QUIC short header) | **1420** | | `gut` | 10 字节 (GUT 头部) | **1420** | | `sip` | 22 字节 (RTP 12 + GUT 10) | **1400** | | `syslog` | base64 膨胀(约 4/3 倍) | **800** | \* 针对外部链路 MTU 为 1500 字节(标准以太网)。对于 PPPoE (1492) 或其他链路,请按比例调整。 **SIP 特殊要求:** `sip` 模式至少需要 **2 个端口** —— `ports[0]` 传输 SIP 信令包,`ports[1+]` 传输 RTP 数据帧。在 SIP 模式下,如果端口少于 2 个,gutd 将拒绝启动。 ## 内核兼容性(eBPF 模式) gutd 的 eBPF 程序使用 `bpf_loop`(内核 ≥ 5.17)和 `noinline` BPF 子程序。 由于状态剪枝和精度跟踪方面的验证器改进,BPF 验证器的复杂度预算(`processed insns`)在不同 内核版本之间差异很大。 | 内核 | QUIC | GUT | Syslog | SIP | 备注 | |---|---|---|---|---|---| | **≥ 6.1** | ✅ | ✅ | ✅ | ✅ | 全面测试通过;6.1 使用 `-mcpu=v3` + 验证器安全钳位 | | **5.17 – 6.0** | ⚠️ | ✅ | ⚠️ | ⚠️ | 只有 GUT 模式稳定可靠 | | **< 5.17** | ❌ | ❌ | ❌ | ❌ | 无 `bpf_loop`;请使用用户态模式 | ⚠️ = 可能会加载失败,具体取决于内核配置和编译器优化。 在旧版内核上使用 `GUTD_USERSPACE=1` 作为回退方案。 ``` # 正确的 SIP 配置示例 [peer] obfs = sip ports = 5060, 10000, 10001 # [0]=signaling [1+]=RTP mtu = 1400 sni = sip.example.com key = ``` ## 文档 | 文档 | 描述 | |---|---| | [doc/configuration.md](doc/configuration.md) | 完整配置参考、混淆模式、MTU 调优 | | [doc/running.md](doc/running.md) | 所有运行模式:基础、P2P、RouterOS、中继 | | [doc/architecture.md](doc/architecture.md) | 出口/入口数据路径、用户态守护进程、安全性 | | [doc/testing.md](doc/testing.md) | 单元测试与集成测试 | | [doc/troubleshooting.md](doc/troubleshooting.md) | 故障排除、防火墙说明 | | [BUILD.md](BUILD.md) | 构建说明 | | [METRICS.md](METRICS.md) | 统计计数器 | ## 许可证 双重许可:用户态代码采用 **MIT** 许可,eBPF/内核代码采用 **GPL-2.0-only** 许可。请参阅 [LICENSE](LICENSE)。
标签:Docker镜像, WireGuard, XDP, 可视化界面, 安全渗透, 流量伪装, 网络协议混淆, 虚拟专用网, 通知系统