Snort
Snort is an open-source Intrusion Detection System (IDS) and Intrusion Prevention System (IPS).
-
It is widely used for real-time traffic analysis and packet logging on IP networks.
-
Snort can detect various types of attacks, including Buffer Overflow Attacks, stealth port scans, CGI attacks, SMB probes, and much more.
-
It can perform protocol analysis and content searching/matching, and it is used to detect a variety of attacks and probes, such as buffer overflows, stealth port scans, CGI attacks, SMB probes, and OS fingerprinting attempts.
Example Snort Rule
alert tcp $EXTERNAL_NET any -> $HOME_NET 80 (msg:"WEB-MISC Command injection attempt"; flow:to_server,established; content:"cmd="; nocase; sid:1000001;)

Start
Windows
snort -i2 -A console -c C:\Snort\etc\snort.conf -l C:\Snort\log -K ascii
Here: 2 is interface no.
Enable Ethernet
snort -dev -i 2.
Check snort conf
snort -T -c snort.conf
Snort is a widely utilized, open-source network intrusion detection system (NIDS) that also functions as an intrusion prevention system (IPS). It was originally created by Martin Roesch and is currently developed by Cisco.
Snort is considered a very useful intrusion detection and prevention technology due to the frequent availability of signatures from public authors.
I. Core Functionality and Operation
Snort is designed to analyze network traffic in real-time, functioning across three main modes:
- Packet Sniffer: It can function as a straight packet sniffer, similar to tcpdump.
- Packet Logger: It can log packets to disk, a useful mode for network traffic debugging.
- Network Intrusion Detection System (NIDS)/Intrusion Prevention System (IPS) Mode: In this mode, it monitors network traffic and analyzes it against a user-defined rule set.
Technical Mechanism
- Real-time Analysis: Snort is capable of performing real-time traffic analysis and packet logging on IP networks.
- Packet Sniffing: Snort uses the popular libpcap library (or Winpcap on Windows) to perform its packet sniffing functions.
- Promiscuous Mode: Snort decodes all packets passing through the network when attached to the network media in promiscuous mode.
- Detection Methods: It performs protocol analysis and content searching/matching.
- Attack Detection: Snort is used to detect a variety of attacks and probes, including buffer overflows, stealth port scans, CGI attacks, SMB probes, and OS fingerprinting attempts.
II. Snort Rules and Configuration
Snort’s rule engine is flexible and allows custom rules to be established to meet the security needs of a specific network. These rules help differentiate between normal Internet activities and malicious activities.
Rule Structure
Snort rules must be short, precise, and easy to understand, and must be contained on a single line. Each rule is divided into two logical sections:
- Rule Header: Contains the rule’s action, the protocol, source/destination IP addresses, port information, and direction.
- Rule Options: Includes alert messages and specific criteria about the inspected part of the packet to determine if action should be taken.
Rule Components
- Protocols: Snort supports three available IP protocols for rule definitions: TCP, UDP, and ICMP.
- Rule Actions: The rule header determines "what to do" when a packet matches the criteria. The six available default actions in Snort are: alert, log, pass, drop, reject, and sdrop.
- Direction Operator: The direction operator indicates the flow of traffic, which can be in a single direction (
->) or bidirectionally (<>). - IP Addresses/Ports: IP addresses can be defined using numeric IP addresses qualified with a CIDR netmask, the keyword "any," or by using the negation operator ("!"). Port ranges are indicated by the range operator ":".
Detecting Specific Attacks with Snort
Snort rules are specifically used to detect various web application attacks, such as SQL injection attacks, by matching specific code sequences and regular expressions within the packet content. An example of a log derived from an IDS solution using Snort analysis indicates the detection of "SQL Injection Paranoid" based on content matching specific regular expressions.
III. Snort in Security and Countermeasures
Snort is employed in various network security defense layers:
- Ping Sweep Defense: Snort, along with other IDSes and IPSes, is used to detect and prevent ping sweep attempts.
- Threat Intelligence: Technical threat intelligence, such as malicious IP addresses collected from active campaigns, is often fed directly into security devices like IDS and IPS, firewalls, and endpoint security systems to enhance detection mechanisms.
- IDS Evasion Defense: To prevent IDS evasion, security professionals must ensure that Snort rules are perfectly configured to avoid Denial-of-Service (DoS) attacks that could be triggered by Snort false positives.
- Honeypots: Snort_inline, a modified version of the Snort IDS, is capable of packet manipulation and is used in second-generation honeynets (GenII) to block known attacks and prevent attacker bouncing.
- Promiscuous Mode Detection: The Nmap Scripting Engine (NSE) includes a script called
sniffer-detectthat can be used to check if a system on a local Ethernet has its network card running in the promiscuous mode. This script can be run using Nmap with Snort's capabilities in mind.