What do the content and nocase keywords do in a Suricata rule?
content is the core of detection: the bytes (text, hex, or both) that must appear in the payload; matching is case-sensitive unless nocase follows, which makes text matching case-insensitive.
content:"evilliveshere"; makes the rule match only packets whose payload contains exactly that byte sequence. Content can be:
- text:
content:"GET"; - hex between pipes:
content:"|0d 0a|";(CR LF) - mixed:
content:"uid=0|28|root|29|";
By default the match is case-sensitive, so EvilLivesHere would not match. Adding nocase; right after the content makes that one content case-insensitive. It applies only to letters; hex bytes are always matched exactly.
Content matching is also what makes Suricata fast. The engine looks for content strings first with a very efficient multi-pattern search, and only evaluates more expensive checks (such as pcre) on packets that already contain the content. That is why a good rule always includes at least one distinctive content.
Go deeper:
Suricata: Payload Keywords (content, nocase, pcre) โ the full reference for
content, hex notation,nocaseand the modifiers that make matches precise.