Table of Contents

PFSense - Suricata - Rules - Breakdown of a rule

Example Rule

alert ip any any -> any any (msg:"IP detected"; sid:2; rev:1;)

where


NOTE: Aliases can also be used.

alert ip $HOME_NET any -> $EXTERNAL_NET $HTTP_PORTS (msg:"IP detected"; sid:2; rev:1;)

where:

  • $HOME_NET: An alias of internal IPs.
  • $EXTERNAL_NET: An alias of non HOME_NET.
  • $HTTP_PORTS: An alias of ports.

Actions

Actions are performed in the following precedence order by default if multiple rules exist; but can be changed through Action Order.


Protocol

NOTE: Suricata also allows you to specify layer 7 protocols as well, such as HTTP (http), SSL and TLS (tls for both), FTP (ftp) and SMB (smb).


Source IP and Port; Direction; Destination IP and Port

any any -> any any

Source and Destination IP can be configured as:

Ports act similarly:

Direction Specification:

NOTE: Built-in Variables include:

  • HOME_NET:
  • EXTERNAL_NET:

Rule Options

Options fall into different categories:


msg:"IP detected"; sid:2; rev:1;

Other Rule Examples

alert icmp any any -> \
      any any (msg:"PING detected"; \
      sid:2; rev:1;)


alert tcp any any <> \
      any any (pcre:"/3\d{3}\
      (\s|-)?\d{6}(\s|-)?\d{5}/";\
      msg:"American Express card number \
      detected in clear text";content: \
      "amex";nocase;sid: 9000003;rev:1;)


alert tcp 1.2.3.4 1024 - > 5.6.7.8 80


# Detect SSH protocol anomalies.
alert tcp any any -> any 22 (msg:"ALERT TCP port 22 but not SSH"; app-layer-protocol:!ssh; sid:2271009; rev:1;)


# Non-TLS traffic on TLS ports.
alert tcp any any -> any [443,465] (msg:"Detected non-TLS on TLS port"; flow:to_server; app-layer-protocol:!tls; threshold: type limit, track by_src, seconds 90, count 1; sid:210003; rev:1;)


alert tcp $EXTERNAL_NET any -> $HTTP_SERVERS $HTTP_PORTS (msg:\".htpasswd access attempt\"; flow:to_server,established; content:\".htpasswd\"; nocase; sid:210503; rev:1;)