Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
S

sni-spoofing-rust

> DevOps
Open source

DPI bypass via fake TLS ClientHello injection with wrong TCP sequence number. Rust port of @patterniha's SNI-Spoofing. Linux, macOS, Windows. Works with v2ray/x

850 stars0 likes2 views
WebsiteGitHub

About

DPI bypass via fake TLS ClientHello injection with wrong TCP sequence number. Rust port of @patterniha's SNI-Spoofing. Linux, macOS, Windows. Works with v2ray/x

sni-spoof-rs

Rust implementation of patterniha's SNI-Spoofing DPI bypass technique. Credit for the original method goes to @patterniha.

sni-spoof-rs is a local TCP forwarder and desktop helper for Cloudflare-fronted VLESS/VMess/Trojan/Xray-style configs. It injects a fake TLS ClientHello with an intentionally wrong TCP sequence number immediately after the TCP handshake. Passive DPI sees the fake SNI and may whitelist the flow; the real server drops that fake packet because it is outside the receive window; then the real TLS traffic passes normally.

English Guide | راهنمای فارسی

English Guide

What You Get

  • Native CLI proxy for Linux, macOS, and Windows.
  • Native desktop UI for Linux, macOS, and Windows.
  • Built-in Xray launcher for VLESS and Trojan links.
  • Bundled UI packages that include the matching Xray binary next to the app.
  • HTTP/HTTPS proxy on 127.0.0.1:1080 and SOCKS5 proxy on 127.0.0.1:1081.
  • LAN sharing mode using 0.0.0.0 so phones or other devices on the same trusted network can use the connection.
  • Built-in fake-SNI scanner for finding domains that still pass on your ISP.
  • Public IP check through the local proxy, so the UI can show whether the tunnel is actually working.
  • Optional log persistence toggle for users who do not want logs written to the UI state file.
  • Experimental Xray TUN inbound mode for elevated desktop runs.
  • Docker image for running one shared proxy box for a local network.
  • GitHub Actions release builds for Linux, macOS, Windows, and GHCR Docker images.

Platform Requirements

This tool must touch raw packets. Normal user permissions are not enough for proxy mode.

Platform Requirement
Linux Run as root, or grant CAP_NET_RAW/needed network capabilities
macOS Run with sudo so BPF devices can be opened
Windows Run as Administrator; keep WinDivert files next to the executable

Scanner mode does not need root/admin because it only opens normal outbound TLS sockets.

Download

Prebuilt binaries are available from:

  • GitHub Releases
  • The releases/ folder, for users who can clone/download the repo but cannot open the Releases page

The release assets include:

File Platform
sni-spoof-rs-linux-amd64 Linux x86_64 CLI
sni-spoof-rs-linux-amd64-musl Linux x86_64 static musl CLI for older distros
sni-spoof-rs-linux-arm64 Linux aarch64 CLI
sni-spoof-rs-macos-amd64 macOS Intel CLI
sni-spoof-rs-macos-arm64 macOS Apple Silicon CLI
sni-spoof-rs-ui-linux-amd64 Linux x86_64 desktop UI
sni-spoof-rs-ui-macos-amd64 macOS Intel desktop UI
sni-spoof-rs-ui-macos-arm64 macOS Apple Silicon desktop UI
sni-spoof-rs-ui-linux-amd64-bundle.tar.gz Linux x86_64 desktop UI plus Xray
sni-spoof-rs-ui-macos-amd64-bundle.tar.gz macOS Intel desktop UI plus Xray
sni-spoof-rs-ui-macos-arm64-bundle.tar.gz macOS Apple Silicon desktop UI plus Xray
sni-spoof-rs-windows-amd64.zip Windows CLI, UI, Xray, Wintun, and WinDivert files

Fastest Path: Desktop UI

The UI is the easiest way to use the project with VLESS/Trojan links.

bash
cargo build --release --features ui --bin sni-spoof-rs-ui
sudo ./target/release/sni-spoof-rs-ui

On Windows, run sni-spoof-rs-ui.exe as Administrator.

In the UI:

  1. Paste one or more vless://... or trojan://... links in Xray Import, one config per line.
  2. Pick the active config from the dropdown.
  3. Press Parse selected. The UI resolves the real Cloudflare upstream and fills connect.
  4. Press Start all-in-one.
  5. Configure your browser or app:
    • HTTP/HTTPS proxy: 127.0.0.1:1080
    • SOCKS5 proxy: 127.0.0.1:1081
  6. Press Fetch my IP or Check IP to verify that traffic exits through the local proxy.

If your pasted link already points to 127.0.0.1:40443, the UI accepts it and resolves the real upstream from host= or sni=. This matches links generated for other local proxy apps.

If you use a *-bundle.tar.gz UI package or the Windows zip, keep xray/xray.exe beside the UI executable; the app will discover it automatically. The Download Xray button installs Xray into a persistent app data folder and updates xray_binary, so it stays available after restart instead of living in a temporary directory.

The UI saves form values, imported links, selected config, theme, scanner settings, and recent logs in sni-spoof-rs-ui-state.json next to the executable. Set SNI_SPOOF_UI_STATE=/path/to/state.json to use another location. Logs are persistent and can be exported from the Logs panel. Turn off Logging in the Logs panel if you do not want new logs kept in memory or written to the state file.

The Xray TUN mode checkbox adds an experimental Xray TUN inbound. Run elevated, keep HTTP/SOCKS enabled while testing, and watch for routing loops if another VPN/TUN client is already active. On Windows, wintun.dll must be beside xray.exe; the Windows zip and Download Xray button install it automatically.

Sharing With Other Devices

Use this only on a trusted local network.

In the UI, press Share on LAN. It sets:

  • Xray HTTP/HTTPS proxy: 0.0.0.0:1080
  • Xray SOCKS5 proxy: 0.0.0.0:1081
  • SNI listener: 0.0.0.0:40443

Then set your phone or another device to use your computer's LAN IP, for example:

  • HTTP/HTTPS proxy: 192.168.1.20:1080
  • SOCKS5 proxy: 192.168.1.20:1081

Make sure your OS firewall allows inbound connections to those ports.

Manual CLI Setup

Use CLI mode when you want to integrate with another v2ray/xray client yourself.

Step 1: Find the Cloudflare IP

Your config usually has a server domain like myserver.example.com. Resolve it:

bash
nslookup myserver.example.com

You should get a Cloudflare IP, often in ranges such as 104.*, 172.67.*, 188.114.*, 162.159.*, or 141.101.*.

Step 2: Create config.json

json
{
  "graceful_shutdown_sec": 0,
  "listeners": [
    {
      "listen": "127.0.0.1:40443",
      "connect": "CLOUDFLARE_IP:443",
      "fake_sni": "security.vercel.com",
      "conn_timeout_sec": 5,
      "handshake_timeout_sec": 2,
      "keepalive_time_sec": 11,
      "keepalive_interval_sec": 2
    }
  ]
}

Replace CLOUDFLARE_IP with the resolved IP.

Field Description
listen Local address and port where sni-spoof-rs accepts client connections
connect Cloudflare IP and port to forward to; use an IP, not a hostname
fake_sni Fake SNI inserted into the intentionally invalid ClientHello
conn_timeout_sec Upstream TCP connect timeout
handshake_timeout_sec Time to wait for the fake packet ACK confirmation
keepalive_time_sec Idle time before TCP keepalive starts
keepalive_interval_sec Time between TCP keepalive probes
idle_timeout Optional top-level timeout for idle relays
buffer_size Top-level relay buffer size in KiB
graceful_shutdown_sec Top-level shutdown drain time; 0 exits immediately

Multiple listeners are supported. Each listener maps one local port to one upstream.

Step 3: Rewrite Your Client Address

In your v2ray/xray client config, change only the server address and port:

  • Address: 127.0.0.1
  • Port: 40443

Keep UUID/password, SNI, host, path, transport type, TLS settings, fingerprint, and other fields unchanged.

Step 4: Run

bash
# Linux/macOS
sudo ./sni-spoof-rs config.json

# Windows, from an Administrator terminal
sni-spoof-rs.exe config.json

Then connect your v2ray/xray client as usual.

Docker Shared Proxy

The Docker image runs sni-spoof-rs and Xray together as shared HTTP/HTTPS and SOCKS5 proxies.

bash
docker build -f docker/Dockerfile -t sni-spoof-proxy .

docker run -d --name snispoof \
  --cap-add=NET_RAW --cap-add=NET_ADMIN \
  -p 1080:1080 \
  -p 1081:1081 \
  -e VLESS_URI='vless://your-full-link-here' \
  -e FAKE_SNI='security.vercel.com' \
  sni-spoof-proxy

Use:

  • HTTP/HTTPS proxy: :1080
  • SOCKS5 proxy: :1081

Check:

bash
curl -x http://127.0.0.1:1080 https://icanhazip.com
curl --socks5-hostname 127.0.0.1:1081 https://icanhazip.com
docker logs snispoof

Finding a Working fake_sni

If your current fake_sni stops working, run the scanner:

bash
./sni-spoof-rs scan
./sni-spoof-rs scan -o working.txt
./sni-spoof-rs scan --target 172.67.139.236:443
./sni-spoof-rs scan --concurrency 30 --timeout 4

Pick an ok result and put it in fake_sni.

The scanner only tests reachability of candidate fake SNIs. It does not guarantee that every ISP, route, or server config will work. If your ISP performs full TLS MITM instead of passive SNI filtering, this bypass may not be enough.

Logging and Debugging

Default logs are quiet. For more detail:

bash
sudo RUST_LOG=info ./sni-spoof-rs config.json
sudo RUST_LOG=debug ./sni-spoof-rs config.json

Useful log lines:

  • fake ClientHello injected: packet injection happened.
  • server ACK confirmed, fake was ignored: upstream ignored the fake packet and relay can start.
  • timeout waiting for fake ACK: packet injection or packet capture did not confirm in time.
  • Connection reset by peer: upstream or Xray closed the connection.

On macOS, if the route goes through a utun interface, the tool detects and parses the utun BPF packet header directly.

Build From Source

bash
cargo build --release
cargo build --release --features ui --bin sni-spoof-rs-ui

For local cross-platform builds:

bash
make all
make ui

GitHub Actions builds and publishes release assets when a v* tag is pushed. Docker images are published to GHCR on release tags.

How It Works

  1. The client connects to the local listener.
  2. sni-spoof-rs dials the Cloudflare upstream.
  3. A sniffer records the TCP initial sequence number and the final ACK of the TCP handshake.
  4. The injector sends a fake TLS ClientHello with seq = ISN + 1 - len(fake).
  5. Passive DPI reads the fake SNI.
  6. The real server drops the fake packet because it is outside the receive window.
  7. sni-spoof-rs waits for an ACK proving the fake was ignored.
  8. The real TLS handshake and relay continue normally.

راهنمای فارسی

این ابزار چیست؟

sni-spoof-rs یک ابزار Rust برای دور زدن DPI مبتنی بر SNI است. ابزار یک ClientHello جعلی با SNI دلخواه می‌فرستد، اما شماره sequence آن را عمدا اشتباه می‌گذارد. DPI غیرفعال معمولا همان SNI جعلی را می‌بیند، ولی سرور واقعی آن پکت را دور می‌اندازد و ترافیک اصلی TLS بدون تغییر ادامه پیدا می‌کند.

این ابزار برای کانفیگ‌های پشت Cloudflare مناسب است؛ مخصوصا VLESS/VMess/Trojan/Xray که از CDN عبور می‌کنند.

امکانات

  • نسخه CLI برای Linux، macOS و Windows.
  • رابط گرافیکی دسکتاپ برای Linux، macOS و Windows.
  • اجرای داخلی Xray برای لینک‌های VLESS و Trojan.
  • بسته‌های UI آماده که Xray مناسب همان سیستم را کنار برنامه دارند.
  • پروکسی HTTP/HTTPS روی 127.0.0.1:1080.
  • پروکسی SOCKS5 روی 127.0.0.1:1081.
  • حالت اشتراک در شبکه محلی با 0.0.0.0 برای استفاده گوشی یا دستگاه‌های دیگر.
  • اسکنر داخلی برای پیدا کردن fake_sni قابل استفاده روی ISP شما.
  • چک کردن IP عمومی از داخل پروکسی برای فهمیدن اینکه اتصال واقعا برقرار شده یا نه.
  • امکان خاموش کردن ذخیره لاگ برای کسانی که نمی‌خواهند لاگ در فایل state نوشته شود.
  • حالت آزمایشی Xray TUN برای اجرای دسکتاپ با دسترسی بالا.
  • نسخه Docker برای راه‌اندازی یک پروکسی مشترک روی یک سیستم.
  • ساخت خودکار فایل‌های Release و Docker image با GitHub Actions.

نیازمندی دسترسی

حالت proxy باید به پکت‌های خام دسترسی داشته باشد؛ بنابراین اجرای عادی کافی نیست.

سیستم عامل نیازمندی
Linux اجرا با root یا capabilityهای لازم مثل CAP_NET_RAW
macOS اجرا با sudo برای باز کردن BPF device
Windows اجرا با Administrator و وجود فایل‌های WinDivert کنار برنامه

حالت sc

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Rustcensorship-circumventioncloudflaredpi-bypassproxy

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理