# Feed Suricata, Snort & Zeek Streams They Won’t Silently Drop

> **FrameAssembly v3.3.0** · Operational Playbook (SecOps, Firewalls & IDS) · Canonical URL: https://frameassembly-lang.dev/use-cases/suricata-ids-testing

Give flow:established rules the real 3-way TCP handshake and checksums they demand, with zero background ARP/mDNS clutter.

- **Category:** SecOps, Firewalls & IDS
- **Capture Filename:** `ids_scan_test.frasm` (16 Ethernet frames)
- **Protocols Exercised:** `dns`, `tcp`, `tls`, `http`, `udp`

## Operational Problem

Classic IDS headache: you write a shiny new Suricata rule with flow:established,to_server, throw one lonely spoofed packet at it, nothing fires in eve.json, and you spend an hour blaming your regex when Suricata’s stream engine just threw your orphan packet in the trash.

Suricata, Snort 3, and Zeek track full TCP streams and check checksums by default. If your test capture skips syn -> syn ack -> ack or has off-by-one SEQ numbers after editing a payload string, the Layer 7 dissector (tls.sni, http.header, dns.query) never even runs.

Checking binary .pcap fixtures into Git isn’t much better: six months later when someone needs to change "bad-domain.test" to a new domain of a different byte length, nobody can edit the binary blob without corrupting the rest of the TCP stream.

## Scenario & Topology: One Clean 16-Frame Regression Capture for 4 Suricata / Zeek Detections

- **Topology:** `Scanner / Beacon (172.18.99.10) <-> Sensor / Gateway (172.18.10.50)`

Before pushing new rules to 40 sensors, this script builds four crisp triggers in one file: (1) a C2 DNS lookup <-> RCODE 5 (REFUSED) sinkhole reply; (2) an established TCP 443 stream carrying TLS 1.3 SNI "shadow-upload.example.net"; (3) an established TCP 80 POST from "ScannerBot/2.1" answered by an HTTP 403 WAF block; and (4) rapid SYN scan probes + a 2-piece fragmented IPv4 UDP packet (mf + fragoffset 185).

## FrameAssembly Workflow

Emits 16 noise-free frames covering a DNS sinkhole, stateful TLS 1.3 SNI, stateful HTTP POST/403, SYN scan, and fragmented IPv4 UDP.

### Adapt It for Your Network

1. Match scanner and target to $HOME_NET / $EXTERNAL_NET in your suricata.yaml.
2. Edit dns qname, tls clienthello sni, http headers, or fragment offsets in plain text.
3. Compile -> run suricata -r ids_scan_test.pcap -k none or zeek -C -r ids_scan_test.pcap -> check eve.json.

## Runnable Capture Specification (`ids_scan_test.frasm`)

```frameassembly
host scanner { ip 172.18.99.10 }
host target  { ip 172.18.10.50 }

flow dns_tls_and_waf_check(src, dst) {
    src -> dst dns query txid 0x4401 qname "c2-beacon.bad-domain.test" qtype "A" wait 1ms
    src <- dst dns response txid 0x4401 qname "c2-beacon.bad-domain.test" qtype "A" rcode 5 wait 2ms
    src -> dst tcp syn srcport 53443 dstport 443 win 65535 mss 1460 wait 1ms
    src <- dst tcp syn ack win 65535 mss 1460 wait 1ms
    src -> dst tcp ack wait 1ms
    src -> dst tls clienthello sni "shadow-upload.example.net" ciphersuite 4866 alpn "h2" wait 2ms
    src -> dst tcp syn srcport 53080 dstport 80 win 65535 mss 1460 wait 1ms
    src <- dst tcp syn ack win 65535 mss 1460 wait 1ms
    src -> dst tcp ack wait 1ms
    src -> dst http post uri "/admin/export" hosthdr "portal.local" useragent "ScannerBot/2.1" body "{\"dump\":true}" wait 2ms
    src <- dst http status 403 reason "Forbidden" body "{\"error\":\"blocked_by_waf\"}" wait 2ms
}

flow syn_scan_and_fragments(src, dst) {
    src -> dst tcp syn srcport 61001 dstport 21 wait 1ms
    src -> dst tcp syn srcport 61002 dstport 22 wait 1ms
    src -> dst tcp syn srcport 61003 dstport 80 wait 1ms
    src -> dst udp dstport 161 ipid 4421 mf fragoffset 0 wait 1ms
    src -> dst udp dstport 161 ipid 4421 fragoffset 185 wait 1ms
}

compile {
    dns_tls_and_waf_check(scanner, target)
    syn_scan_and_fragments(scanner, target)
}
```

## Equivalent CLI Commands

```bash
# 1. Build the IDS/WAF validation capture
frameassembly ids_scan_test.frasm ids_scan_test.pcap

# 2. Run Suricata offline against the generated .pcap (writes eve.json / fast.log)
suricata -r ids_scan_test.pcap -k none -l ./suricata_out/

# 3. Or run Zeek offline to generate dns.log, ssl.log, http.log, and conn.log
zeek -C -r ids_scan_test.pcap
```

## Protocol Reference Links

- [`dns` — Domain Name System over UDP or TCP](https://frameassembly-lang.dev/docs/protocols/dns) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/dns.md))
- [`tcp` — Transmission Control Protocol & RFC 7323 Options](https://frameassembly-lang.dev/docs/protocols/tcp) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/tcp.md))
- [`tls` — Transport Layer Security Record & Handshake Layer](https://frameassembly-lang.dev/docs/protocols/tls) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/tls.md))
- [`http` — Hypertext Transfer Protocol HTTP/1.1](https://frameassembly-lang.dev/docs/protocols/http) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/http.md))
- [`udp` — User Datagram Protocol](https://frameassembly-lang.dev/docs/protocols/udp) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/udp.md))
