Aller au contenu principal

Suricata rules

The structure of the Suricata rules used by the PiRogue to raise alerts, and where they are stored. To understand how the PiRogue detects threats, see Network traffic analysis.

Where the rules live​

WhatWhere
The rules used by your PiRogue/var/lib/suricata/rules/suricata.rules
Suricata configuration/usr/share/pirogue/suricata/suricata.yaml
Online copy of the rulessuricata-rules on GitHub
Default rule setsProofPoint Emerging Threats Open and Echap, refreshed every day
Resource consumption

The number of rules and the amount of monitored traffic directly drive RAM usage. On a device with limited memory, a large ruleset can slow the whole PiRogue down. Suricata is automatically disabled on devices with less than 2.5 GB of RAM.

Anatomy of a rule​

Every rule has three parts: an action, a header and options.

alert dns $HOME_NET any -> any any (msg:"PTS LOCATION TRACKER Device Atlas (maw[.]re)"; metadata: type tracker; dns.query; content:"maw.re"; depth:6; nocase; endswith; fast_pattern; reference:url,esther.codes; classtype:targeted-activity; sid:1001016; rev:1;)
PartIn the example
Actionalert
Headerdns $HOME_NET any -> any any
Optionseverything between the parentheses: (msg:"…"; content:"maw.re"; … sid:1001016;)

Action​

What Suricata does when the rule matches. The PiRogue only observes traffic (IDS mode), so its rules use alert.

ActionEffect
alertLog an alert
passStop inspecting the packet
dropDrop the packet and log an alert (IPS mode only)
rejectReject the packet (IPS mode only)

Which traffic the rule applies to: protocol source_ip source_port direction destination_ip destination_port.

  • Protocol: tcp, udp, icmp, dns, http, tls… or ip for everything. See the list of protocols.
  • Addresses: IPv4 or IPv6, with operators such as ! (not), [a,b] (group) and a/b (range), or variables like $HOME_NET and $EXTERNAL_NET. See rule variables.
  • Ports: source and destination ports, or any.
  • Direction: -> for one direction, <> for both.

Options​

Extra criteria in parentheses, separated by semicolons. The most useful ones:

  • msg: the message displayed in the alert
  • sid: the unique ID of the rule
  • classtype: the category of the threat
  • reference: where to learn more (a URL, a CVE…)
  • content: the pattern to look for in the payload

See the meta keywords for the full list.

What the example does​

The rule above reads: alert on any DNS query, from the local network to anywhere, whose domain is maw.re, a domain used by a known location tracker. When it matches, Suricata logs an alert with the message, the category and a reference.

Going further​