An Intrusion Detection System (IDS) is like a security camera for your network. It silently listens to all traffic passing through the wire and compares it in real-time against a database of malicious signatures. Snort is the world's most widely deployed IDS/IPS engine.
# 1. Define local network (HOME_NET)
ipvar HOME_NET 192.168.1.0/24
# 2. Define external network (EXTERNAL_NET)
ipvar EXTERNAL_NET !$HOME_NET
# 3. Include rule files
include $RULE_PATH/local.rules
A Snort rule is divided into two main parts: the Header and the Options.
[Action] [Protocol] [Src IP] [Src Port] -> [Dst IP] [Dst Port]
alert, log, drop.tcp, udp, icmp, ip.-> (unidirectional), <> (bidirectional).Intelligence warns us of an imminent brute force attack towards the internal FTP server using the "root" user. Write the exact Snort rule to intercept and alert on this malicious pattern in the network.
>_ START CTF 14 CHALLENGEalert tcp $EXTERNAL_NET any -> $HOME_NET 80 (msg:"SQL Injection Attempt"; content:"' OR 1=1"; nocase; sid:1000002; rev:1;)
alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"Nmap XMAS Scan"; flags:F,P,U; sid:1000003; rev:1;)
alert tcp $EXTERNAL_NET any -> $HOME_NET any (msg:"Malware C2 Beacon"; content:"|00 00 01 4A|"; sid:1000005;)
# Test configuration syntax:
snort -T -c /etc/snort/snort.conf -i eth0
# Run printing alerts to console:
snort -A console -q -c /etc/snort/snort.conf -i eth0