Everything you need to use Substrat.
Download the binary for your platform from the download page.
# macOS: remove quarantine flag
xattr -d com.apple.quarantine substrat-macos-arm64
# Make executable
chmod +x substrat-macos-arm64
# Verify
./substrat-macos-arm64 info
You should see version info and available commands printed to the terminal.
The most common use case: analyze a network capture file.
# Analyze a pcap — get grammar + anomalies + Wireshark plugin + fuzz corpus
./substrat-macos-arm64 re capture.pcap --wireshark ./dissectors --fuzz ./fuzz
That's it. Substrat reads the pcap, discovers the protocol structure, flags anomalies, generates a Wireshark dissector and 500 test packets.
The main command for pentest and forensics.
# Basic: grammar + anomalies
./substrat re capture.pcap
# With Wireshark dissector export
./substrat re capture.pcap --wireshark ./dissectors
# With fuzz corpus generation
./substrat re capture.pcap --fuzz ./fuzz_output
# Everything together, 1000 fuzz samples
./substrat re capture.pcap --wireshark ./dissectors --fuzz ./fuzz --fuzz-count 1000
# Limit to 50000 packets (for very large pcaps)
./substrat re capture.pcap --max-packets 50000
Pcap: 85 packets, 1 services (1 analyzable)
--- Flow: TCP|192.168.1.10:502 (85 packets, BINARY mode) ---
Coverage: 94%
Protocol grammar discovered:
MSG -> MAGIC_0 DATA_1 FIXED_2 TYPE_3 DATA_4 FIXED_5 DATA_6
MAGIC_0 -> 0x00
DATA_1 -> <bytes[1]>
FIXED_2 -> 0x00000006
TYPE_3 -> 0x01 | 0x02 | 0x03
DATA_4 -> <bytes[1]>
FIXED_5 -> 0x00
DATA_6 -> <bytes[3]>
Anomalies found: 5/85 packets
#80: FIXED_2 mismatch: expected 0x00000006, got 0x00010006
#81: FIXED_5 mismatch: expected 0x00, got 0xde
Wireshark dissector: ./dissectors/TCP_192.168.1.10_502.lua
Fuzz corpus: 500 samples -> ./fuzz/TCP_192.168.1.10_502/
Total CPU: 0.03s
Discover the grammar of any structured text file (one sample per line).
./substrat learn data.txt
Corpus: 100 lines, alphabet=6 chars
Strategy: wrap
Grammar (3 productions):
S->(S)
S->()
S->SS
bpc: 1.6030
Parse failures: 0/34
CPU: 0.04s
# Auto split: train on 2/3, test on 1/3
./substrat anomaly data.txt
# Separate train and test files
./substrat anomaly test.txt --train train.txt
Two types of anomalies:
./substrat compress data.txt
Raw: 2720 bits (340 chars x 8)
Compressed: 545 bits (1.6030 bpc)
Ratio: 20.0%
./substrat generate data.txt --n 20
Learns the grammar and generates N valid samples with controlled depth.
# macOS
cp ./dissectors/*.lua ~/.config/wireshark/plugins/
# Linux
cp ./dissectors/*.lua ~/.local/lib/wireshark/plugins/
# Windows
copy dissectors\*.lua %APPDATA%\Wireshark\plugins\
Then reload in Wireshark: Ctrl+Shift+L or restart.
The .bin files in the fuzz directory are raw binary packets, ready to send:
# With ncat
for f in ./fuzz/TCP_192.168.1.10_502/*.bin; do
ncat 192.168.1.10 502 < "$f"
done
Three mutation strategies:
| Protocol | Type | Result |
|---|---|---|
| DNS | Binary (real) | Transaction ID, Flags, Questions, Authority detected |
| MODBUS/TCP | Binary (SCADA) | Proto ID, Unit ID, Length. 5/5 anomalies detected |
| Telnet | Mixed (real) | Auto-split IAC binary + text commands |
| FTP | Text (real) | Token \r\n, FTP commands, 0 parse failures |
| HTTP | Text | Tokens HTTP, GET. Requests/responses separated |
| DHCP | Binary (real) | 4 packets (too few to analyze) |
Substrat works on any protocol — not just the ones listed above. If your protocol has a repeating structure, Substrat will find it. If you find a protocol that doesn't work well, send us the pcap.