Suricata custom exfil

From XuShuwenn/RedAct · View interactive version

Suricata custom exfil is an AI agent skill from the GitHub repository XuShuwenn/RedAct. Write Suricata signatures to detect custom HTTP telemetry exfiltration patterns in network traffic.

How to use this skill

Skill file

Suricata Custom Exfiltration Detection

When to Use

Execution Protocol

Exfil Pattern (ALL conditions must be true)

  1. HTTP POST request
  2. Request path exactly: /telemetry/v2/report (match the whole HTTP URI/path exactly, not as a substring)
  3. Header: X-TLM-Mode: exfil
  4. Body contains blob= with Base64 value ≥ 80 chars
  5. Body contains sig= with exactly 64 hex characters

Do not ship a partial rule. A rule that omits the exact path check, the required header, or either body predicate is incorrect even if it matches a sample PCAP.

Before finalizing a rule, map each condition to a detection primitive that enforces the stated scope and boundaries, not just a substring seen in sample traffic.

Observed alerts on sample PCAPs do not excuse a missing structural constraint in the rule. If the task says a field is exact, encode that exactness in the signature itself and treat PCAP hits as confirmation only.

Interpret exactness literally:

Translate every "exact" requirement into rule syntax with anchors or delimiters; sample PCAP hits are not enough if the saved rule still matches superstrings or partial parameter values.

Input Files

Scope constraint: Do not edit /root/suricata.yaml as a workaround for testing or validation.

Evidence Gathering

  1. Before debugging rule logic against live traffic, verify the validation command actually loads /root/local.rules (for example, use suricata -T -S /root/local.rules -c /root/suricata.yaml or another task-specified explicit rule-file flag). If a different runtime path/config does not include /root/local.rules, do not fix that by editing config; keep the deliverable scoped to /root/local.rules and report the limitation.
  2. Inspect /root/local.rules before editing.
  3. Inspect available files in /root/pcaps/ to understand what traffic is provided for validation.
  4. Draft the final rule, but validate structure incrementally: start from a smallest valid rule for the intended HTTP buffer strategy, then add method/path, header, and body predicates one layer at a time.
  5. Write the completed rule to /root/local.rules with an explicit file modification command; preserve existing content unless the task explicitly authorizes replacement, and do not overwrite the file with partial or placeholder content.
  1. Re-open /root/local.rules and confirm the new rule text is present while prior content remains intact.
  1. Run suricata -T -S /root/local.rules -c /root/suricata.yaml to catch syntax and sticky-buffer errors.
  1. If PCAPs are provided, verify behavior on them with the provided config/inputs first: the rule should alert on intended positive traffic and stay quiet on negative traffic.
  1. Make final success claims only from verification output that is explicitly visible and current in the transcript. If a decisive command's output is truncated, cut off, stale relative to later edits, or does not visibly show the result, rerun a narrower/clearer check immediately before finishing or report validation as incomplete.
  2. If offline PCAP processing fails for environmental or threading reasons, retry Suricata with --runmode single before concluding runtime validation is blocked.
  3. If the combined rule parses but does not alert, isolate the failing condition with temporary test signatures for method/URI, header, and body predicates, confirm each against the pcap, then recombine the final single rule in /root/local.rules.
  4. After any debugging with temporary rules, remove them and rerun validation on the final saved sid:1000001 rule before claiming success.
  5. After the final edit, read back the complete rule line from /root/local.rules with a command that shows the full text, and if you made any post-validation rule edit, rerun validation on the saved final rule before claiming success.
  6. Distinguish outcomes precisely: "rule written", "rule parses/loads", and "alert observed on PCAP" are different states and must not be collapsed into one claim.
  7. Perform a final requirement audit before declaring completion: verify the saved rule still preserves existing rules, uses sid:1000001, encodes all 5 conditions directly (including exact path boundaries), and that the response/tool protocol matches any task-specific format requirements.## Required Workflow
  1. Inspect /root/local.rules before editing.
  2. Inspect available files in /root/pcaps/ to understand what traffic is provided for validation.
  3. Draft the full rule first, then write it to /root/local.rules with an explicit file modification command; do not overwrite the file with partial or placeholder content.
  4. Re-open /root/local.rules and confirm the rule text is present.
  5. Run suricata -T -S /root/local.rules -c /root/suricata.yaml to catch syntax and sticky-buffer errors.
  6. If PCAPs are provided, verify behavior on them: the rule should alert on intended positive traffic and stay quiet on negative traffic.
  7. Do not claim success until the write and at least one decisive verification step have actually occurred; if runtime validation is blocked, state that explicitly.

Output

Update /root/local.rules with a single Suricata rule using sid:1000001.

Target outcome:

Hard requirements:

Do not stop at parse success. Final completion requires evidence that the rule both loads and alerts on matching traffic when feasible.

If the positive PCAP produces no SID 1000001 alert, or the event output is empty/inconclusive, do not declare success; continue debugging the rule semantics, especially buffer scope and exact-match boundaries.

If direct runtime testing is blocked, say that explicitly and keep the task incomplete rather than claiming success from reasoning alone. Report only the validation evidence you actually observed.

Do not claim success if all verification attempts failed. Ground every completion claim in observable actions: explicit write to /root/local.rules, readback confirmation, and validation output.

Report only validation outcomes directly shown by command output or inspected alert logs. If evidence is missing, truncated, ambiguous, contradictory, or based on non-default workaround flags, state that clearly instead of claiming default-config success.

If the runtime or task specifies an exact completion string/final-answer format, output it verbatim at the end and do not append extra prose.

Suricata Rule Format

alert tcp any any -> any any (msg:"Custom Exfil"; ...; sid:1000001;)

Use HTTP sticky buffers carefully: declare a given sticky buffer once, then place all related content/pcre checks under it until switching buffers. Do not repeat http.request_body; before each body condition; Suricata can reject this as a duplicate sticky-buffer instance.

If parser errors mention the previous sticky buffer still being set, no matches for the previous buffer, or output like duplicate instance for http_client_body, stop and rebuild from a minimal valid rule instead of adding filler keywords or another body-buffer declaration.

Use exact field/value matching for required HTTP elements. Do not replace a required header/value pair with a broad substring check.

For HTTP header matching with http.header + content, treat header names as case-insensitive by default: add nocase (or use an equivalent case-robust form) even if the sample shows one capitalization. Base the header match on the representation actually observed in packet inspection or parsed output; if the capture shows normalized lowercase header names such as x-tlm-mode: exfil, make the rule tolerant of that form rather than assuming original capitalization.

When a rule must enforce both an HTTP header condition and request-body conditions, treat buffer selection as a design constraint, not a cosmetic modifier choice. Read HTTP header/body structure for Suricata rules before writing or revising such a rule.

If you hit parse errors or are unsure about keyword ordering, stop and compare against a known-working Suricata HTTP rule pattern before adding more complexity. Do not keep guessing at http.method, http.uri, http.header, or http.request_body syntax through trial and error.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.