Outline • Introduction to Intrusion Detection • What is Snort? • Installing Snort • Snort Rules • Snort in Action • Third-Party Enhancements • Conclusion
Introduction to Intrusion Detection • Network defense or “protection” model • Planning • Prevention • Detection • Response • Intrusion detection is the process of discovering, analyzing, and reporting unauthorized or damaging network or computer activities
Introduction to Intrusion Detection • All network and computer activities fall in one of three categories: • Normal • Abnormal but not malicious • Malicious • Intrusion detection operates in two arenas: • What a computer says: network traffic • What a computer thinks: computer processes
Introduction to Intrusion Detection • Network traffic is monitored by network-based intrusion detection systems (NIDS) • Computer processes are monitored by host-based intrusion detection systems (HIDS) • So-called “hybrid” systems examine network traffic to or from a host, as well as processes on that host • NIDS are easier to deploy and manage, but HIDS may give greater visibility to events
Intrusion Detection Basics • Intrusions have “signatures” • Examples • Directory Traversal Vulnerability • Solaris Sadmind/IIS worm (2001) • Allowed HTTP GET requests to change to root directory with “../../”. • Allowed to copy cmd.exe into the Scripts directory. • Gained control usually at admin level GET/ scripts/../../winnt/system32/cmd.exe /c+ copy+\wint\system32\CMD.exe+root.exe
Intrusion Detection Basics • Code Red Worm 2001 • Exploited vulnerability in IIS 4.0 and 5.0 • Buffer overflow vulnerability • Footprint: /default.ida?NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN%u9090%u6858%ucbcd3%7801%u9090%u6805%ucbd3%u7801
Intrusion Detection Basics • Most known attacks have an attack signature. • Sequence of bytes that characterize an attack packet almost for sure. • Intrusion Detection System can look for footprints, drop the packet, and raise an alert.
Intrusion Detection Basics • IDS Firewall • Firewall needs to process all packets. • Filtering capacity at firewall limited by need to deliver packets in timely manner. • IDS can take its time. • IDS does not drop packets, but sends alerts and logs.
Intrusion Detection Basics • Intrusion Detection System can be deployed • Network IDS (behind the firewall and internal router.) • Host based IDS (at all hosts) • Distributed IDS (throughout the local network at strategic locations)
Packet Sniffing NIDS • Load up a good rules set and let it run! • www.whitehats.com • Automatically generates alerts and logs full packet data • Alternative alerting/actions can be handled by something like Swatch • email alerts, active response, etc
Snort • A packet sniffer: capture and display packets from the network with different levels of detail on the console • Packet logger: log data in text file • Honeypot monitor: deceiving hostile parties • NIDS: network intrusion detection system
What is Snort? • Snort is a fast, flexible, small-footprint, open-source NIDS developed by the security community and a “benevolent dictator” • Lead coder: Marty Roesch, now founder of Sourcefire (www.sourcefire.com) • Initially developed in late 1998 as a sniffer with consistent output, unlike protocol-dependent output of TCPDump • Licensed under GPL, but version 2.0 may change to a different license
What is snort? • NIDS: A network intrusion detection system (NIDS) is an intrusion detection system that tries to detect malicious activity such as denial of service attacks, port scans or even attempts to crack into computers by monitoring network traffic. • Snort: an open source network intrusion prevention and detection system. It uses a rule-based language combining signature, protocol and anomaly inspection methods • Snort: the mostwidely deployed intrusion detection and prevention technology and it has become the de facto standard technology worldwide in the industry.
Introducing Snort • Snort is: • Small (~1.2M source distribution) • Portable (Linux, Solaris, *BSD, IRIX, HP-UX, WIN32) • Fast (High probability of detection for a given attack on “average” networks) • Configurable (Easy rules language, many reporting/logging options) • Free (GPL/Open Source Software) • Current version 1.8.1 as of Aug 2001
Snort architecture From: Nalneesh Gaur, Snort: Planning IDS for your enterprise, http://www.linuxjournal.com/article/4668, 2001.
Snort components From: Rafeeq Ur Rehman, Intrusion Detection Systems with Snort: Advanced IDS Techniques with Snort, Apache, MySQL, PHP, and ACID.
Logical components of snort • Packet Decoder: takes packets from different types of network interfaces (Ethernet, SLIP,PPP…), prepare packets for processing • Preprocessor: (1) prepare data for detection engine; (2) detect anomalies in packet headers; (3) packet defragmentation;(4) decode HTTP URI; (5) reassemble TCP streams. • Detection Engine: the most important part, applies rules to packets • Logging and Alerting System • Output Modules: process alerts and logs and generate final output.
TCP/IP layer Snort work on network (IP) layer, transport (TCP/UDP) layer protocol, and application layer Physical layer
Detection Engine • ※Things need to be done for detection engine: • The IP header of the packet • The transport layer header. TCP, UDP, ICMP etc. • The application layer level header. Header of DNS, FTP, SNMP, SMTP • Packet payload ※Requirement • Time critical • Fast ※How to do these? Apply rules to the packets using a Boyer-Moore string matching algorithm
Detection engine • Number of rules • Traffic load on the network • Speed of network and machine • Efficiency of detection algorithm
Rule Header Features • IP addresses • negation, CIDR blocks • TCP/UDP ports • negation, ranges, greater than/less than • uni/bi-directional port/address consideration
IP TTL IP ID Fragment size TCP Flags TCP Ack number TCP Seq number Payload size Content Content offset Content depth Session recording ICMP type ICMP code Alternate log files Rule Option Features
Snort Rules • TCP: TCP protocol, for example SMTP, HTTP, FTP • UDP: For example DNS traffic • ICMP: For example ping, traceroute. • IP: For example IPSec, IGMP
Snort Rules • Content: Content checked by the Boyer Moore pattern matching algorithm. • Flow: Link to the detection plug-ins.
Rules • In a single line • Rules are created by known intrusion signatures. • Usually place in snort.conf configuration file. rule header rule options
Rule examples destination ip address Apply to all ip packets Destination port Source ip address Source port # Rule options Alert will be generated if criteria met Rule header
Detection engine order to scan the rules • Snort does not evaluate the rules in the order that they appear in the Snort rules file. In default, the order is: • Alert rules • Pass rules • Log rules
Snort Rules • Rules contains the rule header and the rule option. alert tcp !10.1.1.0/24 any -> 10.1.1.0/24 any (flags: SF; msg: “SYN-FIN scan) Alerts to traffic from outside the 10.1.1.x subnet to the 10.1.1.x subnet with the Syn and the Fin flags set.
Snort Rules • Rule Header Fields • Action Field • Alert • Log • Pass (no longer look at package) • Activate (turns on other rules) • Dynamic (needs to be turned on by another rule)
Snort Rules • Rule Header Fields • Protocol Field • TCP • UDP • ICMP • IP • Others (ARP, RARP, GRE, …) to come
Snort Rules • Rule Header Fields • Source and Destination IP Address Field • Format: Address/netmask or any or • Address x.x.x.x • Netmask = bits of network mask • For example • 22.214.171.124/8 Class A • 126.96.36.199/16 Class b • 188.8.131.52/24 Class C • 184.108.40.206 host address • Special keywords: • any • ! (negation) • $HOME_NET (variable defined elsewhere)
Snort Rules • Rule Header Fields • Source and Destination Port Field • Static port: 111 • All ports: any • Range: 110:3000 • Negation: !80 • Less than or equal :1023 • Greater than or equal :1024
Snort Rules • Rule Header Fields • Direction Indicator (optional) • -> • Source information specified to the left of arrow, destination information specified to the right of the arrow
Snort Rules • Rule Options • Separated by parentheses alert tcp !$HOME_NET any -> $HOME_NET any (flags: SF; \ msg: “Syn-Fin” scan”;)
Snort Rules • Rule Options • Msg Option • Allows user to assign an appropriate message to the output of a triggered rule. • Alert or log entries only give the packet, not the rule that was triggered.
Snort Rules • Rule Options • Msg Option alert udp any any -> 220.127.116.11 / 24 31337 \ (msg: “Back Orifice”;) Rule: Log: [**] Back Orifice [**] 05/10-08:44:26.398345 18.104.22.168:60256 -> 22.214.171.124:31337 UDP TTL:41 TOS:0x0 ID:49951 Len: 8
Snort Rules • Rule Options • Logto Option • Specifies filename to which to log the activity. • Allows to separate the annoyances from the truly dangerous. alert udp any any -> 126.96.36.199 / 24 31335 \ (msg: “trinoo port”; logto “DDoS”)
Snort Rules • Rule Options • TTL option • Allows to use the time to live field in packet • Format: ttl: number alert udp any any -> 188.8.131.52 / 24 33000;34000 \ (msg: “Unix traceroute”; ttl: 1;)
Snort Rules • Rule Options • ID option • 16-bit value found in the IP header of each datagram. alert udp any any -> 184.108.40.206 / 24 33000;34000 \ (msg: “Suspicious IP Identification”; ID: 0;)
Snort Rules • Rule Options • Dsize option • Size of payload alert icmp any any -> 220.127.116.11 / 24 any \ (msg: “Large ICMP payload”; dsize: >1024;)
Snort Rules • Rule Options • Sequence Option • Value of tcp sequence number • Ack option • Value of ack number in tcp alert tcp any any -> any any \ (msg: “Possible Shaft DDoS”; seq: 0x28374839;) alert tcp any any -> any any \ (msg: “nmap tcp ping”; flags: A; ack: 0;)
Snort Rules • Rule Options • Itype and Icode Options • Select ICMP message type and operations code alert icmp 18.104.22.168/24 any -> 22.214.171.124 / 24 any \ (msg: “port unreachable”; itype: 3; icode: 3;)
Snort Rules • Rule Options • Flags option alert tcp any any -> any any \ (msg: “null scan”; flags: 0;)
Snort Rules • Rule Options • Content Option alert udp $EXTERNAL_NET any -> $HOME_NET 53 \ (msg: “Exploit bind tsig Overflow attempt”; \ content: “|00 FA 00 FF|”; content: “/bin/sh”;)
Snort Rules • Rule Options • Offset option • Specifies offset of content • Depth option • Specifies how far into packet to search for content • Nocase option • Makes content searches case insensitive • Regex Option • Allows wildcards in content searches
Snort Rules • Rule Options • Session Options • Allows to capture TCP session. • Rest Option • Allows an automatic active response • Tag Option • Allows to dynamically capture additional packages after a rule triggers.
Challenges with snort • Misuse detection – avoid known intrusions • Rules database is larger and larger • It continues to grow • snort version 2.3.2, there are 2,600 rules • 80% of them are signatures • Snort spends 80% work time to do string match • Anomaly detection – identify new attacks • Probability of detection is low