# Poke Stateful Firewalls, Suricata, Zeek & OT Conduits

> **FrameAssembly v3.2.2** · Workflow Guide 03 · Canonical URL: https://frameassembly-lang.dev/docs/test-firewalls-and-ids

Craft sessions that actually survive stateful TCP tracking, or intentionally inject Xmas scans, fragments, and rogue SQL/Modbus writes to prove your sensors are awake.

## Key Takeaways

- Stateful firewalls and Suricata (`flow:established,to_server;`) silently drop lone spoofed L7 packets — give them a 3-line `->` / `<-` handshake first.
- Or go full gremlin: override `seq`, `acknum`, Xmas flags (`fin psh urg`), or IPv4 fragments (`mf`, `fragoffset`) to verify your scrubbers actually block garbage.
- Test Purdue Level 1–3 OT rules (`modbus`, `dnp3` CRC-16, `s7comm`, `opcua`) in a `.pcap` instead of gambling with a live plant PLC.

## 1. Why Lone Spoofed Packets Get Ghosted by Suricata & NGFWs

Modern firewalls (Palo Alto, FortiGate, Check Point, Firepower) and IDS engines (Suricata, Zeek) track full TCP streams. Fire a naked TLS `ClientHello` or HTTP `POST` with no prior `SYN -> SYN-ACK -> ACK` and the sensor shrugs and drops it as mid-stream noise, leaving you wondering why your shiny new detection rule never fired.

Three handshake lines in `.frasm` open the flow cleanly, and your L7 payload rides in on the exact expected `seq` and `acknum` so `flow:established` rules evaluate every byte.

### `suricata_tls_sni_check.frasm`

```frameassembly
// Test Suricata tls.sni Shadow-IT rule on TCP 443
// Run: suricata -r suricata_tls_sni_check.pcap -l ./logs
host workstation { ip 10.10.20.45 }
host shadow_saas { ip 198.51.100.77 }

compile {
    workstation -> shadow_saas tcp syn srcport 53110 dstport 443 win 65535 mss 1460 sackperm wait 1ms
    workstation <- shadow_saas tcp syn ack win 65535 mss 1460 sackperm wait 1ms
    workstation -> shadow_saas tcp ack wait 1ms
    workstation -> shadow_saas tls clienthello handshakeversion 0x0303 sni "unapproved-upload.example.net" alpn "h2" wait 2ms
    workstation <- shadow_saas tls alert
}
```

```bash
# Compile and feed straight into Suricata + Zeek offline mode (zero root!)
frameassembly suricata_tls_sni_check.frasm
suricata -r suricata_tls_sni_check.pcap -l ./suricata-out
zeek -C -r suricata_tls_sni_check.pcap
```

## 2. Intentional Chaos: Out-of-State ACKs, Xmas Scans & IPv4 Fragments

Half of security testing is proving bad packets get *dropped*. Whenever you explicitly specify `fin psh urg`, custom `seq` / `acknum` overrides, or IPv4 fragmentation flags (`ipid`, `mf`, `fragoffset`), FrameAssembly puts your exact bogus flags on the wire while keeping IP/TCP checksums valid so the NIC doesn’t eat the frame before the firewall sees it.

### `firewall_anomaly_probes.frasm`

```frameassembly
host red_scanner { ip 203.0.113.99 }
host dmz_bastion { ip 192.0.2.25 }

compile {
    // 1. Out-of-state ACK probe -> expect RST or silent drop
    red_scanner -> dmz_bastion tcp ack srcport 44900 dstport 22 seq 9000 acknum 1 win 1024 wait 5ms
    red_scanner <- dmz_bastion tcp rst seq 1 wait 10ms

    // 2. Classic TCP Xmas tree packet (FIN + PSH + URG) -> HTTPS 443
    red_scanner -> dmz_bastion tcp fin psh urg srcport 44901 dstport 443 seq 1000 urgent 0 wait 10ms

    // 3. Two-piece IPv4 UDP fragment pair (mf -> fragoffset 1)
    red_scanner -> dmz_bastion udp srcport 44902 dstport 161 ipid 0x3344 mf fragoffset 0 payload "AAAAAAAA" wait 1ms
    red_scanner -> dmz_bastion udp srcport 44902 dstport 161 ipid 0x3344 fragoffset 1 payload "BBBBBBBB"
}
```

## 3. OT / ICS Conduit Checks Without Brick-Risking a Live PLC

Poking a live turbine or water-plant PLC just to verify Claroty, Dragos, Nozomi, or an industrial firewall blocks Function Code 6 writes is a career-limiting move. Build authentic `modbus`, `dnp3` (with real IEEE 1815 per-chunk CRC-16), `s7comm`, `bacnet`, `ethernetip`, and `opcua` traces in user space instead:

### `ot_modbus_write_audit.frasm`

```frameassembly
// Prove OT firewall allows FC 03 (Read) <-> alerts on FC 06 (Write)
host eng_ws { ip 172.16.30.15 }
host plc_01 { ip 172.16.10.50 }

compile {
    eng_ws -> plc_01 tcp syn srcport 50900 dstport 502 win 64240 mss 1460 vlan 30 wait 1ms
    eng_ws <- plc_01 tcp syn ack win 64240 mss 1460 vlan 30 wait 1ms
    eng_ws -> plc_01 tcp ack vlan 30 wait 1ms
    // Allowed: Read Holding Registers (FC 03)
    eng_ws -> plc_01 modbus txid 1 unitid 1 readholdingregisters addr 40001 count 2 vlan 30 wait 3ms
    eng_ws <- plc_01 modbus txid 1 unitid 1 readholdingregisters isresponse value 1500 vlan 30 wait 5ms
    // Unauthorized: Write Single Register (FC 06) -> should fire conduit alert!
    eng_ws -> plc_01 modbus txid 2 unitid 1 writesingleregister addr 40001 value 9999 vlan 30
}
```
