Snort User Guide 3.2
Snort User Guide 3.2
Snort User Guide 3.2
2 Rules Headers
The rule header contains the information that defines the who, where, and what
of a packet, as well as what to do in
the event that a packet with all the
attributes indicated in the rule should show up. The first item in a rule is
the rule
action. The rule action tells Snort what to do when it finds a packet
that matches the rule criteria. There are 5
available default actions in Snort,
alert, log, pass, activate, and dynamic. In addition, if you are running Snort
in
inline mode, you have additional options which include drop, reject, and
sdrop.
1. alert - generate an alert using the selected alert method, and then
log the packet
2. log - log the packet
3. pass - ignore the packet
4. activate - alert and then turn on another dynamic rule
5. dynamic - remain idle until activated by an activate rule , then act as a
log rule
6. drop - block and log the packet
7. reject - block the packet, log it, and then send a TCP reset
if the protocol is TCP or an ICMP port unreachable
message if the protocol is
UDP.
8. sdrop - block the packet but do not log it.
You can also define your own rule types and associate one or more output
plugins with them. You can then use the
rule types as actions in Snort rules.
This example will create a type that will log to just tcpdump:
ruletype suspicious
{
type log
output log_tcpdump: suspicious.log
}
This example will create a rule type that will log to syslog and tcpdump:
database:
ruletype redalert
{
type alert
output alert_syslog: LOG_AUTH LOG_ALERT
output log tcpdump: suspicious.log
http://manual.snort.org/node29.html[29/01/2014 21:31:41]
3.2.2 Protocols
The next field in a rule is the protocol. There are four protocols that Snort
currently analyzes for suspicious behavior
- TCP, UDP, ICMP, and IP. In the
future there may be more, such as ARP, IGRP, GRE, OSPF, RIP, IPX, etc.
3.2.3 IP Addresses
The next portion of the rule header deals with the IP address and port
information for a given rule. The keyword any
may be used to define any
address. Snort does not have a mechanism to provide host name lookup for the IP
address
fields in the config file. The addresses are formed by a straight
numeric IP address and a CIDR[3] block. The CIDR
block
indicates the netmask that should be applied to the rule's address and any
incoming packets that are tested
against the rule. A CIDR block mask of /24
indicates a Class C network, /16 a Class B network, and /32 indicates a
Figure:
Example IP Address Negation Rule
This rule's IP addresses indicate any tcp packet with a source IP address not
originating from the internal network
and a destination address on the internal
network.
Figure:
IP Address Lists
Port numbers may be specified in a number of ways, including any ports, static
port definitions, ranges, and by
negation. Any ports are a wildcard value,
meaning literally any port. Static ports are indicated by a single port
number,
such as 111 for portmapper, 23 for telnet, or 80 for http, etc. Port ranges are
indicated with the range
operator :. The range operator may be applied in a
number of ways to take on different meanings, such as in Figure
.
http://manual.snort.org/node29.html[29/01/2014 21:31:41]
Figure:
Port Range Examples
you wanted to log everything except the X Windows ports, you could do something
like the rule in Figure .
Figure:
Example of Port Negation
consistently.
Figure:
Snort rules using the Bidirectional
Operator
Note:
Activate and Dynamic rules are being phased out in favor of a combination of
tagging ( ) and flowbits (
).
Activate/dynamic rule pairs give Snort a powerful capability. You can now have
one rule activate another when its
action is performed for a set number of
packets. This is very useful if you want to set Snort up to perform follow on
recording when a specific rule goes off. Activate rules act just like alert
rules, except they have a *required* option
http://manual.snort.org/node29.html[29/01/2014 21:31:41]
Activate rules are just like alerts but also tell Snort to add a rule when a
specific network event occurs. Dynamic
rules are just like log rules except are
dynamically enabled when the activate rule id goes off.
Figure:
Activate/Dynamic Rule Example
These rules tell Snort to alert when it detects an IMAP buffer overflow and
collect the next 50 packets headed for
port 143 coming from outside $HOME_NET
headed to $HOME_NET. If the buffer overflow happened and was
successful,
there's a very good possibility that useful data will be contained within the
next 50 (or whatever) packets
going to that same service port on the network,
so there's value in collecting those packets for later analysis.
http://manual.snort.org/node29.html[29/01/2014 21:31:41]