Overview
The Fragment transform splits outgoing packets into smaller fragments, making it harder for DPI systems to detect protocol signatures. This transform is particularly effective against systems that expect complete protocol handshakes in single packets.Structure
Configuration
Minimum fragment size in bytes. Packets smaller than this will not be fragmented.
Maximum fragment size in bytes. When
randomize is false, all fragments will be this size.If set, the packet will be split at exactly this byte offset into two fragments. This takes precedence over min/max size settings.
When enabled, fragment sizes will vary pseudo-randomly between
min_size and max_size. When disabled, all fragments will be max_size.Methods
new
fragment_data
apply
min_size, it passes through unchanged.
Returns: TransformResult::Fragmented if fragmentation occurred, TransformResult::Continue otherwise.
Behavior
- Packets smaller than or equal to
min_sizeare not fragmented - When
split_at_offsetis set, the packet is split into exactly two fragments at that offset - Otherwise, packets are split into multiple fragments based on
min_size,max_size, andrandomizesettings - The first fragment replaces the original packet data, subsequent fragments are emitted via the flow context
- All data is preserved - fragments can be reassembled to recover the original packet
- Fragment count statistics are tracked in
ctx.state.transform_state.fragment.fragments_generated
Example Configuration
Basic fragmentation
Split at specific offset
- Fragment 1: bytes 0-4
- Fragment 2: bytes 5-end
Randomized fragmentation
Code Example
From fragment.rs:133:Validation
The following validation rules are enforced in config.rs:76-88:min_sizemust be greater than 0max_sizemust be greater than or equal tomin_size