injector

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package injector constructs fake TLS ClientHello packets for SNI-spoofing DPI bypass. This is a Go port of the upstream Python ClientHelloMaker (patterniha/SNI-Spoofing), producing byte-identical output so golden tests can verify parity.

Index

Constants

View Source
const (
	// RandLen is the size of the TLS client_random field.
	RandLen = 32
	// SessionIDLen is the fixed session_id length the template uses.
	SessionIDLen = 32
	// KeyShareLen is the X25519 key_share size.
	KeyShareLen = 32
	// OutputLen is the total fake ClientHello size. Constant across all SNIs
	// because the padding extension absorbs the difference.
	OutputLen = 517
)

Variables

View Source
var ErrInvalidInput = errors.New("snix/injector: invalid input size")

ErrInvalidInput is returned when random/session/key_share sizes are wrong, or SNI exceeds the padding budget.

Functions

func BuildClientHello

func BuildClientHello(rnd, sessID []byte, sni, keyShare []byte) ([]byte, error)

BuildClientHello constructs a 517-byte fake TLS 1.3 ClientHello with the given SNI and randomized handshake fields. Output is byte-identical to the upstream Python implementation for equal inputs.

rnd, sessID, keyShare MUST each be 32 bytes; sni MUST be <= 219 bytes. The result is newly allocated and safe to modify.

func BuildClientHelloPadded

func BuildClientHelloPadded(rnd, sessID, sni, keyShare []byte, extraPad int) ([]byte, error)

BuildClientHelloPadded returns a ClientHello whose total size is OutputLen + extraPad bytes, where extraPad ∈ [0, 65000]. The extension is byte-identical to BuildClientHello when extraPad == 0.

Extra bytes are appended to the padding extension. The record and handshake length fields are recomputed so the resulting packet remains a valid TLS record; any TLS parser (including the DPI) will see a well- formed ClientHello carrying the same SNI, key_share, and cipher suites as the fixed-size variant.

Breaking the fixed-517-byte signature is a key anti-fingerprinting win: a DPI that looked for "exact length 517 during handshake-ACK window" cannot match a variable-length stream.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL