Overview
The Decoy transform generates duplicate packets with a low TTL value that expire before reaching the destination. These decoy packets confuse DPI systems that attempt to reconstruct traffic, causing them to see corrupted or invalid protocol streams.Structure
Configuration
When enabled, sends a decoy packet before the real packet. The decoy has low TTL and expires in transit, while the real packet reaches the destination.
When enabled, sends a decoy packet after the real packet. Both settings can be enabled to send decoys both before and after.
The TTL (Time To Live) value for decoy packets. Low values (1-3) ensure the decoy expires quickly:
- 1: Expires at first router
- 2: Expires at second hop
- 3: Expires at third hop
Probability (0.0 to 1.0) of generating a decoy packet. Values:
- 0.0: Never generate decoys (disabled)
- 0.5: 50% chance per packet
- 1.0: Always generate decoys
Methods
new
create_decoy
- Copying the original packet
- Setting TTL to the configured
ttlvalue - Inverting the IP identification field bytes (XOR with 0xFF)
Some(decoy) if the packet is valid IPv4, None otherwise.
should_send_decoy
true if a decoy should be generated, false otherwise.
apply
TransformResult::Fragmented if decoys were generated, TransformResult::Continue otherwise.
Behavior
- Decoys are only generated if
send_beforeorsend_afteris enabled - Probability check determines if decoy generation happens for each packet
- Only IPv4 packets can have decoys generated (minimum 20 bytes)
- When
send_beforeis enabled:- The decoy becomes the first packet (modified data buffer)
- The real packet is emitted as a subsequent packet
- When
send_afteris enabled:- The real packet stays first
- The decoy is emitted as a subsequent packet
- Both modes can be active simultaneously
- Decoy packets have modified IP ID to make them appear different
- Low TTL ensures decoys expire before reaching the destination
Example Configuration
Always send decoy before
50% chance of decoy after
Decoy sandwich
Disabled
Code Example
From decoy.rs:206:Decoy Creation Logic
From decoy.rs:20:- TTL is set to a low value
- IP identification field is inverted
Probability Check
From decoy.rs:42:seed % 1000 < (probability * 1000)
The seed is generated in apply() using:
How Decoys Defeat DPI
- Middlebox confusion: DPI systems see the decoy packet and attempt to parse it
- Decoy expires: The decoy never reaches the destination due to low TTL
- Real packet arrives: The destination receives only the real packet
- Desynchronization: The DPI system’s view of the connection differs from reality
- Signature failure: Protocol signatures fail to match due to extra/modified packets
Use Cases
- DPI evasion: Confuse DPI systems that reconstruct TCP streams
- Middlebox testing: Detect presence of middleboxes along the path
- Censorship circumvention: Defeat censorship systems that inspect initial packets
- Protocol obfuscation: Make protocol detection unreliable
Important Notes
- Decoys only work with IPv4 packets
- TTL should be set low enough to expire before the destination
- Network topology affects effective TTL values
- High decoy rates may trigger rate limiting or anomaly detection
- Decoys do not reach the destination server, so server-side logging is unaffected