Snort
π§ Tool Note β Category: Network Intrusion Detection/Prevention (NIDS/NIPS) | Open Source
π Quick Overview
What is it? The original open-source, signature-based network IDS/IPS. It inspects packets against a database of rules and raises an alert (IDS mode) or drops the traffic (IPS mode) when a packet matches a known attack pattern.
Official Website: https://www.snort.org/ License: GPLv2 (free); maintained by Cisco Talos Used in: CSF & NS (Unit III β IDS/IPS) Related concept: Network Defence Mechanisms
π― What Problem Does It Solve?
- Detects known attacks (exploits, malware C2, scans, policy violations) as they cross the network
- Gives a SOC visibility into what is happening on the wire, not just that something happened
- Can actively block traffic inline (IPS mode)
- Turns community threat research (rules) into automated detection
βοΈ How It Works
Snort processes every packet through a pipeline:
Packet β DAQ β Decoder β Preprocessors β Detection Engine β Output/Alert
- DAQ (Data AcQuisition): the abstraction layer that grabs packets β from
libpcap(passive tap/SPAN, IDS mode) or inline viaafpacket/nfq(IPS mode, sits between segments so it can drop). - Decoder: parses raw bytes into protocol structures (Ethernet β IP β TCP/UDP β payload) and flags malformed packets.
- Preprocessors (Snort 2) / Inspectors (Snort 3): normalise traffic before rule matching so attackers canβt evade with tricks β e.g.
frag3reassembles fragmented IP,streamreassembles TCP sessions,http_inspectnormalises URL encoding. Without this, an attack split across packets would slip past. - Detection Engine: matches the normalised packet against loaded rules. This is the heart β fast multi-pattern matching (Aho-Corasick) first narrows candidates, then full rule options are checked.
- Output: on match, writes an alert (fast/full/
unified2binary β read by Barnyard2 β SIEM), logs the packet, or drops it (IPS).
Detection is signature-based: Snort only catches what a rule describes. Unknown/zero-day attacks with no rule = no alert. (Contrast with anomaly-based detection β see Suricata and Network Defence Mechanisms.)
Snort 2 vs Snort 3: Snort 3 (current) is a rewrite β multi-threaded, faster, simpler config, but the classic single-thread Snort 2 rule syntax below still applies conceptually.
π§© Anatomy of a Rule
alert tcp any any -> 192.168.1.0/24 80 (msg:"Possible SQLi"; content:"UNION SELECT"; nocase; sid:1000001; rev:1;)
βrule βproto βsrc βdst βport βββββββββββ rule options βββββββββββ
header β addr/port β
action detection + metadata
- Action:
alert(log+alert),log,drop/reject(IPS),pass(whitelist). - Header: protocol, source/dest IP + port, direction (
->one-way,<>bidirectional). - Options:
content(byte/string to match),nocase,pcre(regex),flow(session state),sid(unique rule ID),rev(rule version),msg(alert text).
π Key Features
- Three run modes: sniffer, packet logger, NIDS/NIPS
- Huge rule ecosystem β Talos (official), ET Open (Emerging Threats, community)
- Inline IPS blocking
- Preprocessors that defeat evasion (fragmentation, session splitting)
- Rule language readable/writable by analysts
π¬ Typical Workflow
# Sniffer mode (like tcpdump)
snort -v
# Packet logger
snort -dev -l ./log
# NIDS mode with a config + ruleset
snort -c /etc/snort/snort.conf -i eth0 -A fast
# Test a rule file / config without running
snort -T -c /etc/snort/snort.confAlerts land in /var/log/snort/alert. In production the flow is Snort β unified2 β Barnyard2 β Splunk/SIEM so analysts triage in one place (Splunk, SOC Operations & Incident Lifecycle).
β οΈ Gotchas / Limitations
- Signature-based only β no rule, no detection. Keep rules updated (PulledPork/manual).
- Canβt inspect encrypted payloads (HTTPS/TLS) β sees metadata, not content.
- Noisy rulesets β false-positive flood; tuning (disabling/threshold-ing rules) is a real job (Unit III).
- Snort 2 is single-threaded β a busy link can drop packets; use Snort 3 or Suricata for multi-core.
π Related Notes
- Suricata β modern multi-threaded alternative, runs Snort rules
- Network Defence Mechanisms β IDS vs IPS, signature vs anomaly
- Splunk β where Snort alerts get correlated
- Wireshark β manual packet analysis of what Snort flags