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
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
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.
127.0.0.1:1080 and SOCKS5 proxy on 127.0.0.1:1081.0.0.0.0 so phones or other devices on the same trusted network can use the connection.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.
Prebuilt binaries are available from:
releases/ folder, for users who can clone/download the repo but cannot open the Releases pageThe 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 |
The UI is the easiest way to use the project with VLESS/Trojan links.
cargo build --release --features ui --bin sni-spoof-rs-ui
sudo ./target/release/sni-spoof-rs-uiOn Windows, run sni-spoof-rs-ui.exe as Administrator.
In the UI:
vless://... or trojan://... links in Xray Import, one config per line.connect.127.0.0.1:1080127.0.0.1:1081If 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.
Use this only on a trusted local network.
In the UI, press Share on LAN. It sets:
0.0.0.0:10800.0.0.0:10810.0.0.0:40443Then set your phone or another device to use your computer's LAN IP, for example:
192.168.1.20:1080192.168.1.20:1081Make sure your OS firewall allows inbound connections to those ports.
Use CLI mode when you want to integrate with another v2ray/xray client yourself.
Your config usually has a server domain like myserver.example.com. Resolve it:
nslookup myserver.example.comYou should get a Cloudflare IP, often in ranges such as 104.*, 172.67.*, 188.114.*, 162.159.*, or 141.101.*.
config.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.
In your v2ray/xray client config, change only the server address and port:
127.0.0.140443Keep UUID/password, SNI, host, path, transport type, TLS settings, fingerprint, and other fields unchanged.
# Linux/macOS
sudo ./sni-spoof-rs config.json
# Windows, from an Administrator terminal
sni-spoof-rs.exe config.jsonThen connect your v2ray/xray client as usual.
The Docker image runs sni-spoof-rs and Xray together as shared HTTP/HTTPS and SOCKS5 proxies.
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-proxyUse:
:1080:1081Check:
curl -x http://127.0.0.1:1080 https://icanhazip.com
curl --socks5-hostname 127.0.0.1:1081 https://icanhazip.com
docker logs snispooffake_sniIf your current fake_sni stops working, run the scanner:
./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 4Pick 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.
Default logs are quiet. For more detail:
sudo RUST_LOG=info ./sni-spoof-rs config.json
sudo RUST_LOG=debug ./sni-spoof-rs config.jsonUseful 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.
cargo build --release
cargo build --release --features ui --bin sni-spoof-rs-uiFor local cross-platform builds:
make all
make uiGitHub Actions builds and publishes release assets when a v* tag is pushed. Docker images are published to GHCR on release tags.
seq = ISN + 1 - len(fake).sni-spoof-rs یک ابزار Rust برای دور زدن DPI مبتنی بر SNI است. ابزار یک ClientHello جعلی با SNI دلخواه میفرستد، اما شماره sequence آن را عمدا اشتباه میگذارد. DPI غیرفعال معمولا همان SNI جعلی را میبیند، ولی سرور واقعی آن پکت را دور میاندازد و ترافیک اصلی TLS بدون تغییر ادامه پیدا میکند.
این ابزار برای کانفیگهای پشت Cloudflare مناسب است؛ مخصوصا VLESS/VMess/Trojan/Xray که از CDN عبور میکنند.
127.0.0.1:1080.127.0.0.1:1081.0.0.0.0 برای استفاده گوشی یا دستگاههای دیگر.fake_sni قابل استفاده روی ISP شما.حالت proxy باید به پکتهای خام دسترسی داشته باشد؛ بنابراین اجرای عادی کافی نیست.
| سیستم عامل | نیازمندی |
|---|---|
| Linux | اجرا با root یا capabilityهای لازم مثل CAP_NET_RAW |
| macOS | اجرا با sudo برای باز کردن BPF device |
| Windows | اجرا با Administrator و وجود فایلهای WinDivert کنار برنامه |
حالت sc
No open issues yet, or sync has not completed.