Suricata cheatsheet

🛡️ Suricata Cheatsheet


1️⃣ Rule Structure

action protocol src_ip src_port -> dst_ip dst_port (options)
alert tcp $EXTERNAL_NET any -> $HOME_NET 80
(msg:"HTTP test"; sid:1000001; rev:1;)

2️⃣ IP Address Keywords & Lists

ExampleMeaning
anyAny IP address
!1.1.1.1Every IP except 1.1.1.1
![1.1.1.1, 1.1.1.2]Exclude 1.1.1.1 and 1.1.1.2
$HOME_NETHOME_NET from suricata.yaml
[$EXTERNAL_NET, !$HOME_NET]External network excluding home
[10.0.0.0/24, !10.0.0.5]Subnet except host

3️⃣ Port Keywords, Ranges & Lists

ExampleMeaning
anyAny port
[80,81,82]Ports 80, 81, 82
[80:82]Range 80–82
[1024:]1024 to max port
!80All ports except 80
[80:100,!99]80–100 excluding 99
[1:80,![2,4]]1–80 except 2 and 4

4️⃣ Rule Numbering (SID Allocation)

SID RangeDescription
1000000–1999999Custom / Local rules
2000000–2099999Emerging Threats (ET Open)
2100000–2103999Forked Snort GPL
2200000–2200999Decoder events
2210000–2210999Stream events
2220000–2299999Reserved
2400000–2528999Dynamically updated
2800000–2899999ET Pro (paid)

Note: SID is the last keyword (or second-to-last if rev is used).


5️⃣ Rule Actions

ActionDescription
alertGenerate alert
dropDrop packet (IPS)
rejectDrop + RST / ICMP
passIgnore traffic

6️⃣ Common Rule Options

OptionDescription
msgAlert message
sidSignature ID
revRevision
classtypeAttack class
prioritySeverity
contentPayload match
flowTraffic direction
thresholdRate limit alerts

7️⃣ Example Rules

alert tcp $EXTERNAL_NET any -> $HOME_NET 22
(msg:"External SSH attempt"; sid:1000001; rev:1;)
alert tcp any [1024:] -> $HOME_NET any
(msg:"High source port"; sid:1000003; rev:1;)

8️⃣ Default File Locations

ItemPath
Config/etc/suricata/suricata.yaml
Rules/var/lib/suricata/rules/
Local ruleslocal.rules
Alerts/var/log/suricata/eve.json

9️⃣ Useful Commands

# Validate suricata config
suricata -T -c /etc/suricata/suricata.yaml

# Reload rules
sudo systemctl restart suricata

# Check log
tail -f /var/log/suricata/eve.json



Viết nhận xét

Các bạn có thể viết lời nhận xét cho bài viết, nhưng cần tuân thủ một số quy tắc sau:

» Các nhận xét/bình luận phải nghiêm túc, không dung tục, không spam.
» Nội dung phải liên quan tới chủ đề bài viết.
» Viết bằng tiếng việt có dấu hoặc tiếng Anh. Nội dung viết không dấu sẽ bị xóa.
» Hãy để lại tên của bạn khi nhận xét/bình luận, để tôi có thể dễ dàng trả lời bạn khi cần.