Snort 3 User Manual

User Manual:

Open the PDF directly: View PDF PDF.
Page Count: 305 [warning: Documents this large are best viewed by clicking the View PDF Link!]

Snort 3 User Manual i
Snort 3 User Manual
Snort 3 User Manual ii
REVISION HISTORY
NUMBER DATE DESCRIPTION NAME
Snort 3 User Manual iii
Contents
1 Overview 1
1.1 First Steps ....................................................... 2
1.2 Configuration ..................................................... 3
1.2.1 Environment ................................................. 4
1.2.2 Command Line ................................................ 4
1.2.3 Configuration File .............................................. 4
1.2.4 Rules ..................................................... 5
1.2.5 Converting Your 2.X Configuration ..................................... 5
1.3 Output ......................................................... 6
1.3.1 Basic Statistics ................................................ 6
1.3.2 Alerts ..................................................... 6
1.3.3 Files and Paths ................................................ 6
1.3.4 Performance Statistics ............................................ 7
2 Concepts 7
2.1 Terminology ...................................................... 7
2.2 Modules ........................................................ 8
2.3 Parameters ....................................................... 9
2.4 Plugins ........................................................ 10
2.5 Operation ....................................................... 10
2.5.1 Snort 2 Processing .............................................. 11
2.5.2 Snort 3 Processing .............................................. 11
2.6 Rules ......................................................... 11
2.7 Pattern Matching ................................................... 12
2.7.1 Rule Groups ................................................. 12
2.7.2 Fast Patterns ................................................. 13
2.7.3 Rule Evaluation ................................................ 13
3 Tutorial 13
3.1 Dependencies ..................................................... 13
3.2 Building ........................................................ 14
3.3 Running ........................................................ 15
3.4 Tips .......................................................... 15
3.5 Help .......................................................... 17
3.6 Common Errors .................................................... 17
3.7 Gotchas ........................................................ 18
Snort 3 User Manual iv
4 Usage 19
4.1 Environment ...................................................... 19
4.2 Help .......................................................... 19
4.3 Sniffing and Logging ................................................. 20
4.4 Configuration ..................................................... 20
4.5 IDS mode ....................................................... 21
4.6 Plugins ........................................................ 21
4.7 Output Files ...................................................... 22
4.8 DAQ Alternatives ................................................... 22
4.9 Logger Alternatives .................................................. 23
4.10 Shell .......................................................... 23
4.11 Signals ......................................................... 23
5 Features 24
5.1 AppId ......................................................... 24
5.1.1 Overview ................................................... 24
5.1.2 Dependency Requirements .......................................... 24
5.1.3 Configuration ................................................. 25
5.1.4 Session Application Identifiers ........................................ 26
5.1.5 AppId Usage Statistics ............................................ 26
5.1.6 Open Detector Package (ODP) Installation ................................. 26
5.1.7 User Created Application Detectors ..................................... 27
5.1.8 Application Detector Creation Tool ..................................... 27
5.2 Binder ......................................................... 28
5.3 Byte rule options ................................................... 28
5.3.1 byte_test ................................................... 28
Examples ................................................... 29
5.3.2 byte_jump .................................................. 29
Examples ................................................... 29
5.3.3 byte_extract .................................................. 29
Other options which use byte_extract variables ............................... 29
Examples ................................................... 30
5.3.4 byte_math ................................................... 30
Examples ................................................... 30
5.3.5 Testing Numerical Values .......................................... 30
5.4 DCE Inspectors .................................................... 33
5.4.1 Overview ................................................... 33
5.4.2 Quick Guide ................................................. 33
5.4.3 Target Based ................................................. 34
Snort 3 User Manual v
5.4.4 Reassembling ................................................. 35
5.4.5 SMB ..................................................... 35
Finger Print Policy .............................................. 35
File Inspection ................................................ 35
5.4.6 TCP ...................................................... 36
5.4.7 UDP ..................................................... 36
5.4.8 Rule Options ................................................. 36
dce_iface ................................................... 36
dce_opnum .................................................. 37
dce_stub_data ................................................. 38
byte_test and byte_jump ........................................... 38
5.5 File Processing .................................................... 38
5.5.1 Overview ................................................... 39
5.5.2 Quick Guide ................................................. 39
5.5.3 Pre-packaged File Magic Rules ....................................... 40
5.5.4 File Policy .................................................. 40
5.5.5 File Capture .................................................. 40
5.5.6 File Events .................................................. 41
5.6 High Availability ................................................... 41
5.6.1 HA ...................................................... 41
5.6.2 Connector ................................................... 42
Connector (parent plugin class) ....................................... 42
TcpConnector ................................................. 42
FileConnector ................................................. 43
5.6.3 Side Channel ................................................. 43
5.7 FTP .......................................................... 44
5.7.1 Configuring the inspector to block exploits and attacks ........................... 44
ftp_server configuration ........................................... 44
ftp_client configuration ............................................ 47
ftp_data .................................................... 47
5.8 HTTP Inspector .................................................... 47
5.8.1 Overview ................................................... 48
5.8.2 Configuration ................................................. 48
request_depth and response_depth ...................................... 48
gzip ...................................................... 49
normalize_utf ................................................. 49
decompress_pdf ............................................... 49
decompress_swf ............................................... 49
normalize_javascript ............................................. 49
Snort 3 User Manual vi
URI processing ................................................ 49
5.8.3 Detection rules ................................................ 51
http_uri and http_raw_uri .......................................... 52
http_header and http_raw_header ...................................... 52
http_trailer and http_raw_trailer ....................................... 53
http_cookie and http_raw_cookie ...................................... 53
http_true_ip .................................................. 53
http_client_body ............................................... 53
http_raw_body ................................................ 53
http_method ................................................. 53
http_stat_code ................................................ 53
http_stat_msg ................................................. 53
http_version .................................................. 54
http_raw_request and http_raw_status .................................... 54
file_data and packet data ........................................... 54
5.8.4 Timing issues and combining rule options .................................. 54
5.9 HTTP/2 Inspector ................................................... 56
5.10 Performance Monitor ................................................. 56
5.10.1 Overview ................................................... 56
5.10.2 Base Tracker ................................................. 57
5.10.3 Flow Tracker ................................................. 57
5.10.4 FlowIP Tracker ................................................ 58
5.10.5 CPU Tracker ................................................. 58
5.10.6 Formatters .................................................. 58
5.11 POP and IMAP .................................................... 58
5.11.1 Overview ................................................... 58
5.11.2 Configuration ................................................. 58
b64_decode_depth .............................................. 58
qp_decode_depth ............................................... 58
bitenc_decode_depth ............................................. 59
uu_decode_depth ............................................... 59
Examples ................................................... 59
5.12 Port Scan ....................................................... 59
5.12.1 Overview ................................................... 60
5.12.2 Scan levels .................................................. 61
5.12.3 Tuning Portscan ............................................... 62
5.13 Sensitive Data Filtering ................................................ 63
5.13.1 Hyperscan .................................................. 63
5.13.2 Syntax .................................................... 63
Snort 3 User Manual vii
Pattern .................................................... 63
Threshold ................................................... 64
Obfuscating Credit Cards and Social Security Numbers ........................... 64
5.13.3 Example ................................................... 64
5.13.4 Caveats .................................................... 64
5.14 SMTP ......................................................... 65
5.14.1 Overview ................................................... 65
5.14.2 Configuration ................................................. 65
normalize and normalize_cmds ....................................... 65
ignore_data .................................................. 65
ignore_tls_data ................................................ 65
max_command_line_len ........................................... 65
max_header_line_len ............................................. 65
max_response_line_len ............................................ 65
alt_max_command_line_len ......................................... 66
invalid_cmds ................................................. 66
valid_cmds .................................................. 66
data_cmds .................................................. 66
binary_data_cmds .............................................. 66
auth_cmds .................................................. 66
xlink2state .................................................. 66
b64_decode_depth .............................................. 66
qp_decode_depth ............................................... 67
bitenc_decode_depth * default to 25 ..................................... 67
uu_decode_depth ............................................... 67
Log Options ................................................. 67
5.14.3 Example ................................................... 67
5.15 Telnet ......................................................... 68
5.15.1 Configuring the inspector to block exploits and attacks ........................... 68
5.16 Wizard ......................................................... 69
6 Basic Modules 69
6.1 active ......................................................... 69
6.2 alerts .......................................................... 70
6.3 attribute_table ..................................................... 70
6.4 classifications ..................................................... 70
6.5 daq ........................................................... 71
6.6 decode ......................................................... 72
6.7 detection ........................................................ 72
Snort 3 User Manual viii
6.8 event_filter ...................................................... 73
6.9 event_queue ...................................................... 73
6.10 high_availability ................................................... 74
6.11 host_cache ....................................................... 74
6.12 host_tracker ...................................................... 74
6.13 hosts .......................................................... 75
6.14 inspection ....................................................... 75
6.15 ips ........................................................... 76
6.16 latency ......................................................... 76
6.17 memory ........................................................ 77
6.18 network ........................................................ 77
6.19 output ......................................................... 78
6.20 packets ........................................................ 78
6.21 process ........................................................ 79
6.22 profiler ......................................................... 79
6.23 rate_filter ....................................................... 80
6.24 references ....................................................... 80
6.25 rule_state ....................................................... 80
6.26 search_engine ..................................................... 81
6.27 side_channel ..................................................... 82
6.28 snort .......................................................... 82
6.29 suppress ........................................................ 86
7 Codec Modules 86
7.1 arp ........................................................... 87
7.2 auth .......................................................... 87
7.3 ciscometadata ..................................................... 87
7.4 eapol .......................................................... 87
7.5 erspan2 ........................................................ 88
7.6 erspan3 ........................................................ 88
7.7 esp ........................................................... 88
7.8 eth ........................................................... 88
7.9 fabricpath ....................................................... 88
7.10 gre ........................................................... 89
7.11 gtp ........................................................... 89
7.12 icmp4 ......................................................... 89
7.13 icmp6 ......................................................... 90
7.14 igmp .......................................................... 91
7.15 ipv4 .......................................................... 91
Snort 3 User Manual ix
7.16 ipv6 .......................................................... 92
7.17 llc ........................................................... 92
7.18 mpls .......................................................... 93
7.19 pbb .......................................................... 93
7.20 pgm .......................................................... 93
7.21 pppoe ......................................................... 94
7.22 tcp ........................................................... 94
7.23 token_ring ....................................................... 95
7.24 udp .......................................................... 95
7.25 vlan .......................................................... 95
7.26 wlan .......................................................... 96
8 Connector Modules 96
8.1 file_connector ..................................................... 96
8.2 tcp_connector ..................................................... 96
9 Inspector Modules 97
9.1 appid ......................................................... 97
9.2 arp_spoof ....................................................... 97
9.3 back_orifice ...................................................... 98
9.4 binder ......................................................... 98
9.5 data_log ........................................................ 99
9.6 dce_http_proxy .................................................... 99
9.7 dce_http_server ....................................................100
9.8 dce_smb ........................................................100
9.9 dce_tcp ........................................................103
9.10 dce_udp ........................................................105
9.11 dnp3 ..........................................................106
9.12 dns ...........................................................106
9.13 dpx ..........................................................107
9.14 file_id .........................................................107
9.15 file_log ........................................................108
9.16 ftp_client .......................................................109
9.17 ftp_data ........................................................109
9.18 ftp_server .......................................................109
9.19 gtp_inspect ......................................................110
9.20 http2_inspect .....................................................111
9.21 http_inspect ......................................................111
9.22 imap ..........................................................116
Snort 3 User Manual x
9.23 modbus ........................................................117
9.24 normalizer .......................................................117
9.25 packet_capture ....................................................120
9.26 perf_monitor .....................................................120
9.27 pop ..........................................................121
9.28 port_scan .......................................................122
9.29 reg_test ........................................................125
9.30 reputation .......................................................125
9.31 rpc_decode ......................................................126
9.32 sip ...........................................................126
9.33 smtp ..........................................................128
9.34 ssh ...........................................................130
9.35 ssl ...........................................................131
9.36 stream .........................................................132
9.37 stream_file .......................................................134
9.38 stream_icmp ......................................................134
9.39 stream_ip .......................................................134
9.40 stream_tcp .......................................................136
9.41 stream_udp ......................................................138
9.42 stream_user ......................................................139
9.43 telnet .........................................................139
9.44 wizard .........................................................139
10 IPS Action Modules 140
10.1 react ..........................................................140
10.2 reject .........................................................140
10.3 rewrite .........................................................141
11 IPS Option Modules 141
11.1 ack ...........................................................141
11.2 appids .........................................................141
11.3 asn1 ..........................................................141
11.4 base64_decode ....................................................142
11.5 bufferlen ........................................................142
11.6 byte_extract ......................................................142
11.7 byte_jump .......................................................143
11.8 byte_math .......................................................143
11.9 byte_test ........................................................144
11.10classtype ........................................................144
Snort 3 User Manual xi
11.11content .........................................................144
11.12cvs ...........................................................145
11.13dce_iface .......................................................145
11.14dce_opnum ......................................................145
11.15dce_stub_data .....................................................145
11.16detection_filter ....................................................146
11.17dnp3_data .......................................................146
11.18dnp3_func .......................................................146
11.19dnp3_ind .......................................................146
11.20dnp3_obj .......................................................146
11.21dsize ..........................................................147
11.22file_data ........................................................147
11.23file_type ........................................................147
11.24flags ..........................................................147
11.25flow ..........................................................147
11.26flowbits ........................................................148
11.27fragbits ........................................................148
11.28fragoffset .......................................................148
11.29gid ...........................................................148
11.30gtp_info ........................................................149
11.31gtp_type ........................................................149
11.32gtp_version ......................................................149
11.33http2_frame_data ...................................................149
11.34http2_frame_header ..................................................149
11.35http_client_body ...................................................149
11.36http_cookie ......................................................150
11.37http_header ......................................................150
11.38http_method ......................................................150
11.39http_raw_body ....................................................150
11.40http_raw_cookie ...................................................151
11.41http_raw_header ...................................................151
11.42http_raw_request ...................................................151
11.43http_raw_status ....................................................151
11.44http_raw_trailer ....................................................152
11.45http_raw_uri ......................................................152
11.46http_stat_code .....................................................152
11.47http_stat_msg .....................................................153
11.48http_trailer .......................................................153
11.49http_true_ip ......................................................153
Snort 3 User Manual xii
11.50http_uri ........................................................153
11.51http_version ......................................................154
11.52icmp_id ........................................................154
11.53icmp_seq .......................................................154
11.54icode ..........................................................154
11.55id ...........................................................155
11.56ip_proto ........................................................155
11.57ipopts .........................................................155
11.58isdataat ........................................................155
11.59itype ..........................................................155
11.60md5 ..........................................................156
11.61metadata ........................................................156
11.62modbus_data .....................................................156
11.63modbus_func .....................................................156
11.64modbus_unit .....................................................156
11.65msg ..........................................................157
11.66mss ..........................................................157
11.67pcre ..........................................................157
11.68pkt_data ........................................................157
11.69pkt_num ........................................................157
11.70priority ........................................................158
11.71raw_data ........................................................158
11.72reference .......................................................158
11.73regex ..........................................................158
11.74rem ..........................................................158
11.75replace .........................................................159
11.76rev ...........................................................159
11.77rpc ...........................................................159
11.78sd_pattern .......................................................159
11.79seq ...........................................................160
11.80service .........................................................160
11.81session .........................................................160
11.82sha256 .........................................................160
11.83sha512 .........................................................161
11.84sid ...........................................................161
11.85sip_body ........................................................161
11.86sip_header .......................................................161
11.87sip_method ......................................................161
11.88sip_stat_code .....................................................162
Snort 3 User Manual xiii
11.89so ...........................................................162
11.90soid ..........................................................162
11.91ssl_state ........................................................162
11.92ssl_version ......................................................163
11.93stream_reassemble ..................................................163
11.94stream_size ......................................................163
11.95tag ...........................................................164
11.96target .........................................................164
11.97tos ...........................................................164
11.98ttl ...........................................................164
11.99urg ...........................................................164
11.100window ........................................................165
11.101wscale .........................................................165
12 Search Engine Modules 165
13 SO Rule Modules 165
14 Logger Modules 165
14.1 alert_csv ........................................................165
14.2 alert_ex ........................................................166
14.3 alert_fast .......................................................166
14.4 alert_full ........................................................166
14.5 alert_json .......................................................166
14.6 alert_sfsocket .....................................................167
14.7 alert_syslog ......................................................167
14.8 alert_unixsock .....................................................167
14.9 log_codecs ......................................................167
14.10log_hext ........................................................168
14.11log_pcap ........................................................168
14.12unified2 ........................................................168
15 DAQ Configuration and Modules 168
15.1 Building the DAQ Library and Its Bundled DAQ Modules ..............................169
15.2 Configuration .....................................................169
15.2.1 Command Line Example ...........................................169
15.2.2 Configuration File Example .........................................169
15.2.3 Interaction With Multiple Packet Threads ..................................170
15.3 DAQ Modules Included With Snort 3 .........................................171
15.3.1 Socket Module ................................................171
15.3.2 File Module ..................................................172
15.3.3 Hext Module .................................................172
Snort 3 User Manual xiv
16 Snort 3 vs Snort 2 173
16.1 Features New to Snort 3 ................................................174
16.2 Features Improved over Snort 2 ............................................174
16.3 Build Options .....................................................175
16.4 Command Line ....................................................176
16.5 Conf File .......................................................176
16.6 Rules .........................................................177
16.7 Output .........................................................178
16.8 Sensitive Data .....................................................178
17 Snort2Lua 179
17.1 Snort2Lua Command Line ..............................................179
17.1.1 Usage: snort2lua [OPTIONS]. . . -c <snort_conf> . . . ............................179
Options: ....................................................180
Required option: ...............................................181
Default values: ................................................181
17.2 Known Problems ...................................................181
17.3 Usage .........................................................181
18 Extending Snort 182
18.1 Plugins ........................................................182
18.2 Modules ........................................................182
18.3 Inspectors .......................................................183
18.4 Codecs .........................................................183
18.5 IPS Actions ......................................................186
18.6 Developers Guide ...................................................186
18.7 Piglet Test Harness ..................................................186
18.8 Piglet Lua API ....................................................187
18.8.1 Plugin Instances ...............................................187
Interface Objects ...............................................188
19 Coding Style 193
19.1 General ........................................................193
19.2 C++ Specific .....................................................193
19.3 Naming ........................................................193
19.4 Comments .......................................................194
19.5 Logging ........................................................194
19.6 Types .........................................................194
19.7 Macros (aka defines) .................................................195
19.8 Formatting .......................................................195
19.9 Headers ........................................................196
19.10Warnings .......................................................197
19.11Uncrustify .......................................................197
Snort 3 User Manual xv
20 Reference 198
20.1 Build Options .....................................................198
20.2 Environment Variables ................................................198
20.3 Command Line Options ................................................199
20.4 Configuration .....................................................202
20.5 Counts .........................................................231
20.6 Generators .......................................................247
20.7 Builtin Rules .....................................................248
20.8 Command Set .....................................................262
20.9 Signals .........................................................263
20.10Configuration Changes ................................................263
20.11Module Listing ....................................................268
20.12Plugin Listing .....................................................274
20.13Bugs ..........................................................281
20.13.1 Build .....................................................281
20.13.2 Config .....................................................281
20.13.3 Rules .....................................................281
20.13.4 snort2lua ...................................................281
20.13.5 Runtime ....................................................282
20.14LibDAQ and DAQ Modules .............................................282
20.14.1 Building the DAQ Library and DAQ Modules ................................282
20.14.2 PCAP Module ................................................283
20.14.3 AFPACKET Module .............................................283
Fanout (Kernel Loadbalancing) .......................................284
20.14.4 NFQ Module .................................................284
20.14.5 IPQ Module ..................................................285
20.14.6 IPFW Module ................................................285
20.14.7 Dump Module ................................................285
20.14.8 Netmap Module ...............................................286
FreeBSD ...................................................286
Linux .....................................................286
20.14.9 Notes on iptables ...............................................287
20.14.10Notes on FreeBSD::IPFW ..........................................288
20.14.11Notes on OpenBSD::IPFW ..........................................289
Snort 3 User Manual 1 / 290
,,_ -*> Snort++ <*-
o" )~ Version 3.0.0 (Build 243) from 2.9.11
’’’’ By Martin Roesch & The Snort Team
http://snort.org/contact#team
Copyright (C) 2014-2018 Cisco and/or its affiliates. All rights reserved.
Copyright (C) 1998-2013 Sourcefire, Inc., et al.
1 Overview
Snort 3.0 is an updated version of the Snort Intrusion Prevention System (IPS) which features a new design that provides a
superset of Snort 2.X functionality with better throughput, detection, scalability, and usability. Some of the key features of Snort
3.0 are:
Support multiple packet processing threads
Use a shared configuration and attribute table
Autodetect services for portless configuration
Modular design
Plugin framework with over 200 plugins
More scalable memory profile
LuaJIT configuration, loggers, and rule options
Hyperscan support
Rewritten TCP handling
New rule parser and syntax
Service rules like alert http
Rule "sticky" buffers
Snort 3 User Manual 2 / 290
Way better SO rules
New HTTP inspector
New performance monitor
New time and space profiling
New latency monitoring and enforcement
Piglets to facilitate component testing
Inspection Events
Automake and Cmake
Autogenerate reference documentation
Additional features are on the road map:
Use a shared network map
Support hardware offload for fast pattern acceleration
Provide support for DPDK and ODP
Support pipelining of packet processing
Support proxy mode
Multi-tennant support
Incremental reload
New serialization of perf data and events
Enhanced rule processing
Windows support
Anomaly detection
and more!
The remainder of this section provides a high level survey of the inputs, processing, and outputs available with Snort 3.0.
Snort++ is the project that is creating Snort 3.0. In this manual "Snort" or "Snort 3" refers to the 3.0 version and earlier versions
will be referred to as "Snort 2" where the distinction is relevant.
1.1 First Steps
Snort can be configured to perform complex packet processing and deep packet inspection but it is best start simply and work up
to more interesting tasks. Snort won’t do anything you didn’t specifically ask it to do so it is safe to just try things out and see
what happens. Let’s start by just running Snort with no arguments:
$ snort
That will output usage information including some basic help commands. You should run all of these commands now to see what
is available:
$ snort -V
$ snort -?
$ snort --help
Snort 3 User Manual 3 / 290
Note that Snort has extensive command line help available so if anything below isn’t clear, there is probably a way to get the
exact information you need from the command line.
Now let’s examine the packets in a capture file (pcap):
$ snort -r a.pcap
Snort will decode and count the packets in the file and output some statistics. Note that the output excludes non-zero numbers so
it is easy to see what is there.
You may have noticed that there are command line options to limit the number of packets examined or set a filter to select
particular packets. Now is a good time to experiment with those options.
If you want to see details on each packet, you can dump the packets to console like this:
$ snort -r a.pcap -L dump
Add the -d option to see the TCP and UDP payload. Now let’s switch to live traffic. Replace eth0 in the below command with an
available network interface:
$ snort -i eth0 -L dump
Unless the interface is taken down, Snort will just keep running, so enter Control-C to terminate or use the -n option to limit the
number of packets.
Generally it is better to capture the packets for later analysis like this:
$ snort -i eth0 -L pcap -n 10
Snort will write 10 packets to log.pcap.# where # is a timestamp value. You can read these back with -r and dump to console or
pcap with -L. You get the idea.
Note that you can do similar things with other tools like tcpdump or Wireshark however these commands are very useful when
you want to check your Snort setup.
The examples above use the default pcap DAQ. Snort supports non-pcap interfaces as well via the DAQ (data acquisition) library.
Other DAQs provide additional functionality such as inline operation and/or higher performance. There are even DAQs that
support raw file processing (ie without packets), socket processing, and plain text packets. To load external DAQ libraries and
see available DAQs or select a particular DAQ use one of these commands:
$ snort --daq-dir <path> --daq-list
$ snort --daq-dir <path> --daq <type>
Be sure to put the --daq-dir option ahead of the --daq-list option or the external DAQs won’t appear in the list.
To leverage intrusion detection features of Snort you will need to provide some configuration details. The next section breaks
down what must be done.
1.2 Configuration
Effective configuration of Snort is done via the environment, command line, a Lua configuration file, and a set of rules.
Note that backwards compatibility with Snort 2 was sacrificed to obtain new and improved functionality. While Snort 3 leverages
some of the Snort 2 code base, a lot has changed. The configuration of Snort 3 is done with Lua, so your old conf won’t work as
is. Rules are still text based but with syntax tweaks, so your 2.X rules must be fixed up. However, snort2lua will help you convert
your conf and rules to the new format.
Snort 3 User Manual 4 / 290
1.2.1 Environment
LUA_PATH must be set based on your install:
LUA_PATH=$install_prefix/include/snort/lua/\?.lua\;\;
SNORT_LUA_PATH must be set to load auxiliary configuration files if you use the default snort.lua. For example:
export SNORT_LUA_PATH=$install_prefix/etc/snort
1.2.2 Command Line
A simple command line might look like this:
snort -c snort.lua -R cool.rules -r some.pcap -A cmg
To understand what that does, you can start by just running snort with no arguments by running snort --help. Help for all
configuration and rule options is available via a suitable command line. In this case:
-c snort.lua is the main configuration file. This is a Lua script that is executed when loaded.
-R cool.rules contains some detection rules. You can write your own or obtain them from Talos (native 3.0 rules are not yet
available from Talos so you must convert them with snort2lua). You can also put your rules directly in your configuration file.
-r some.pcap tells Snort to read network traffic from the given packet capture file. You could instead use -i eth0 to read from a
live interface. There many other options available too depending on the DAQ you use.
-A cmg says to output intrusion events in "cmg" format, which has basic header details followed by the payload in hex and text.
Note that you add to and/or override anything in your configuration file by using the --lua command line option. For example:
--lua ’ips = { enable_builtin_rules = true }’
will load the built-in decoder and inspector rules. In this case, ips is overwritten with the config you see above. If you just want
to change the config given in your configuration file you would do it like this:
--lua ’ips.enable_builtin_rules = true’
1.2.3 Configuration File
The configuration file gives you complete control over how Snort processes packets. Start with the default snort.lua included in
the distribution because that contains some key ingredients. Note that most of the configurations look like:
stream = { }
This means enable the stream module using internal defaults. To see what those are, you could run:
snort --help-config stream
Snort is organized into a collection of builtin and plugin modules. If a module has parameters, it is configured by a Lua table of
the same name. For example, we can see what the active module has to offer with this command:
$ snort --help-module active
What: configure responses
Type: basic
Snort 3 User Manual 5 / 290
Configuration:
int active.attempts = 0: number of TCP packets sent per response (with
varying sequence numbers) { 0:20 }
string active.device: use ’ip’ for network layer responses or ’eth0’ etc
for link layer
string active.dst_mac: use format ’01:23:45:67:89:ab’
int active.max_responses = 0: maximum number of responses { 0: }
int active.min_interval = 255: minimum number of seconds between
responses { 1: }
This says active is a basic module that has several parameters. For each, you will see:
type module.name = default: help { range }
For example, the active module has a max_responses parameter that takes non-negative integer values and defaults to zero. We
can change that in Lua as follows:
active = { max_responses = 1 }
or:
active = { }
active.max_responses = 1
If we also wanted to limit retries to at least 5 seconds, we could do:
active = { max_responses = 1, min_interval = 5 }
1.2.4 Rules
Rules determine what Snort is looking for. They can be put directly in your Lua configuration file with the ips module, on the
command line with --lua, or in external files. Generally you will have many rules obtained from various sources such as Talos
and loading external files is the way to go so we will summarize that here. Add this to your Lua configuration:
ips = { include = ’rules.txt’ }
to load the external rules file named rules.txt. You can only specify one file this way but rules files can include other rules files
with the include statement. In addition you can load rules like:
$ sort -c snort.lua -R rules.txt
You can use both approaches together.
1.2.5 Converting Your 2.X Configuration
If you have a working 2.X configuration snort2lua makes it easy to get up and running with Snort 3. This tool will convert your
configuration and/or rules files automatically. You will want to clean up the results and double check that it is doing exactly what
you need.
snort2lua -c snort.conf
The above command will generate snort.lua based on your 2.X configuration. For more information and options for more
sophisticated use cases, see the Snort2Lua section later in the manual.
Snort 3 User Manual 6 / 290
1.3 Output
Snort can produce quite a lot of data. In the following we will summarize the key aspects of the core output types. Additional
data such as from appid is covered later.
1.3.1 Basic Statistics
At shutdown, Snort will output various counts depending on configuration and the traffic processed. Generally, you may see:
Packet Statistics - this includes data from the DAQ and decoders such as the number of packets received and number of UDP
packets.
Module Statistics - each module tracks activity via a set of peg counts that indicate how many times something was observed
or performed. This might include the number of HTTP GET requests processed and the number of TCP reset packets trimmed.
File Statistics - look here for a breakdown of file type, bytes, signatures.
Summary Statistics - this includes total runtime for packet processing and the packets per second. Profiling data will appear
here as well if configured.
Note that only the non-zero counts are output. Run this to see the available counts:
$ snort --help-counts
1.3.2 Alerts
If you configured rules, you will need to configure alerts to see the details of detection events. Use the -A option like this:
$ snort -c snort.lua -r a.pcap -A cmg
There are many types of alert outputs possible. Here is a brief list:
-A cmg is the same as -A fast -d -e and will show information about the alert along with packet headers and payload.
-A u2 is the same as -A unified2 and will log events and triggering packets in a binary file that you can feed to other tools
for post processing. Note that Snort 3 does not provide the raw packets for alerts on PDUs; you will get the actual buffer that
alerted.
-A csv will output various fields in comma separated value format. This is entirely customizable and very useful for pcap
analysis.
To see the available alert types, you can run this command:
$ snort --list-plugins | grep logger
1.3.3 Files and Paths
Note that output is specific to each packet thread. If you run 4 packet threads with u2 output, you will get 4 different u2 files.
The basic structure is:
<logdir>/[<run_prefix>][<id#>][<X>]<name>
where:
logdir is set with -l and defaults to ./
Snort 3 User Manual 7 / 290
run_prefix is set with --run-prefix else not used
id# is the packet thread number that writes the file; with one packet thread, id# (zero) is omitted without --id-zero
X is / if you use --id-subdir, else _ if id# is used
name is based on module name that writes the file
Additional considerations:
There is no way to explicitly configure a full path to avoid issues with multiple packet threads.
All text mode outputs default to stdout
1.3.4 Performance Statistics
Still more data is available beyond the above.
By configuring the perf_monitor module you can capture a configurable set of peg counts during runtime. This is useful to
feed to an external program so you can see what is happening without stopping Snort.
The profiler module allows you to track time and space used by module and rules. Use this data to tune your system for best
performance. The output will show up under Summary Statistics at shutdown.
2 Concepts
This section provides background on essential aspects of Snort’s operation.
2.1 Terminology
basic module: a module integrated into Snort that does not come from a plugin.
binder: inspector that maps configuration to traffic
builtin rules: codec and inspector rules for anomalies detected internally.
codec: short for coder / decoder. These plugins are used for basic protocol decoding, anomaly detection, and construction of
active responses.
data module: an adjunct configuration plugin for use with certain inspectors.
dynamic rules: plugin rules loaded at runtime. See SO rules.
fast pattern: the content in an IPS rule that must be found by the search engine in order for a rule to be evaluated.
fast pattern matcher: see search engine.
hex: a type of protocol magic that the wizard uses to identify binary protocols.
inspector: plugin that processes packets (similar to the Snort 2 preprocessor)
IPS: intrusion prevention system, like Snort.
IPS action: plugin that allows you to perform custom actions when events are generated. Unlike loggers, these are invoked
before thresholding and can be used to control external agents or send active responses.
IPS option: this plugin is the building blocks of IPS rules.
logger: a plugin that performs output of events and packets. Events are thresholded before reaching loggers.
Snort 3 User Manual 8 / 290
module: the user facing portion of a Snort component. Modules chiefly provide configuration parameters, but may also provide
commands, builtin rules, profiling statistics, peg counts, etc. Note that not all modules are plugins and not all plugins have
modules.
peg count: the number of times a given event or condition occurs.
plugin: one of several types of software components that can be loaded from a dynamic library when Snort starts up. Some
plugins are coupled with the main engine in such a way that they must be built statically, but a newer version can be loaded
dynamically.
search engine: a plugin that performs multipattern searching of packets and payload to find rules that should be evaluated.
There are currently no specific modules, although there are several search engine plugins. Related configuration is done with
the basic detection module. Aka fast pattern matcher.
SO rule: a IPS rule plugin that performs custom detection that can’t be done by a text rule. These rules typically do not have
associated modules. SO comes from shared object, meaning dynamic library.
spell: a type of protocol magic that the wizard uses to identify ASCII protocols.
text rule: a rule loaded from the configuration that has a header and body. The header specifies action, protocol, source and
destination IP addresses and ports, and direction. The body specifies detection and non-detection options.
wizard: inspector that applies protocol magic to determine which inspectors should be bound to traffic absent a port specific
binding. See hex and spell.
2.2 Modules
Modules are the building blocks of Snort. They encapsulate the types of data that many components need including parameters,
peg counts, profiling, builtin rules, and commands. This allows Snort to handle them generically and consistently. You can learn
quite a lot about any given module from the command line. For example, to see what stream_tcp is all about, do this:
$ snort --help-config stream_tcp
Modules are configured using Lua tables with the same name. So the stream_tcp module is configured with defaults like this:
stream_tcp = { }
The earlier help output showed that the default session tracking timeout is 30 seconds. To change that to 60 seconds, you can
configure it this way:
stream_tcp = { session_timeout = 60 }
Or this way:
stream_tcp = { }
stream_tcp.session_timeout = 60
More on parameters is given in the next section.
Other things to note about modules:
Shutdown output will show the non-zero peg counts for all modules. For example, if stream_tcp did anything, you would see
the number of sessions processed among other things.
Providing the builtin rules allows the documentation to include them automatically and also allows for autogenerating the rules
at startup.
Only a few module provide commands at this point, most notably the snort module.
Snort 3 User Manual 9 / 290
2.3 Parameters
Parameters are given with this format:
type name = default: help { range }
The following types are used:
addr: any valid IP4 or IP6 address or CIDR
addr_list: a space separated list of addr values
bit_list: a list of consecutive integer values from 1 to the range maximum
bool: true or false
dynamic: a select type determined by loaded plugins
enum: a string selected from the given range
implied: an IPS rule option that takes no value but means true
int: a whole number in the given range
interval: a set of ints (see below)
ip4: an IP4 address or CIDR
mac: an ethernet address with the form 01:02:03:04:05:06
multi: one or more space separated strings from the given range
port: an int in the range 0:65535 indicating a TCP or UDP port number
real: a real number in the given range
select: a string selected from the given range
string: any string with no more than the given length, if any
The parameter name may be adorned in various ways to indicate additional information about the type and use of the parameter:
For Lua configuration (not IPS rules), if the name ends with [] it is a list item and can be repeated.
For IPS rules only, names starting with ~ indicate positional parameters. The names of such parameters do not appear in the
rule.
IPS rules may also have a wild card parameter, which is indicated by a *. Used for unquoted, comma-separated lists such as
service and metadata.
The snort module has command line options starting with a -.
Some additional details to note:
Table and variable names are case sensitive; use lower case only.
String values are case sensitive too; use lower case only.
Numeric ranges may be of the form low:high where low and high are bounds included in the range. If either is omitted, there
is no hard bound. E.g. 0: means any x where x >= 0.
Strings may have a numeric range indicating a length limit; otherwise there is no hard limit.
bit_list is typically used to store a set of byte, port, or VLAN ID values.
interval takes the form [operator]i, j<>k, or j<k where i,j,k are integers and operator is one of =, !, != (same as !), <, , >,
>=. j<>k means j < int < k and j<k means j int k.
Snort 3 User Manual 10 / 290
2.4 Plugins
Snort uses a variety of plugins to accomplish much of its processing objectives, including:
Codec - to decode and encode packets
Inspector - like Snort 2 preprocessors, for normalization, etc.
IpsOption - for detection in Snort rules
IpsAction - for custom actions
Logger - for handling events
Mpse - for fast pattern matching
So - for dynamic rules
The power of plugins is that they have a very focused purpose and can be created with relative ease. For example, you can extend
the rule language by writing your own IpsOption and it will plug in and function just like existing options. The extra directory
has examples of each type of plugin.
Most plugins can be built statically or dynamically. By default they are all static. There is no difference in functionality between
static or dynamic plugins but the dynamic build generates a slightly lighter weight binary. Either way you can add dynamic
plugins with --plugin-path and newer versions will replace older versions, even when built statically.
A single dynamic library may contain more than one plugin. For example, an inspector will typically be packaged together with
any associated rule options.
2.5 Operation
Snort is a signature-based IPS, which means that as it receives network packets it reassembles and normalizes the content so that
a set of rules can be evaluated to detect the presence of any significant conditions that merit further action. A rough processing
flow is as follows:
The steps are:
1. Decode each packet to determine the basic network characteristics such as source and destination addresses and ports.
A typical packet might have ethernet containing IP containing TCP containing HTTP (ie eth:ip:tcp:http). The various
encapsulating protocols are examined for sanity and anomalies as the packet is decoded. This is essentially a stateless
effort.
2. Preprocess each decoded packet using accumulated state to determine the purpose and content of the innermost message.
This step may involve reordering and reassembling IP fragments and TCP segments to produce the original application
protocol data unit (PDU). Such PDUs are analyzed and normalized as needed to support further processing.
3. Detection is a two step process. For efficiency, most rules contain a specific content pattern that can be searched for such
that if no match is found no further processing is necessary. Upon start up, the rules are compiled into pattern groups such
that a single, parallel search can be done for all patterns in the group. If any match is found, the full rule is examined
according to the specifics of the signature.
4. The logging step is where Snort saves any pertinent information resulting from the earlier steps. More generally, this is
where other actions can be taken as well such as blocking the packet.
Snort 3 User Manual 11 / 290
2.5.1 Snort 2 Processing
The preprocess step in Snort 2 is highly configurable. Arbitrary preprocessors can be loaded dynamically at startup, configured
in snort.conf, and then executed at runtime. Basically, the preprocessors are put into a list which is iterated for each packet.
Recent versions have tweaked the list handling some, but the same basic architecture has allowed Snort 2 to grow from a sniffer,
with no preprocessing, to a full-fledged IPS, with lots of preprocessing.
While this "list of plugins" approach has considerable flexibility, it hampers future development when the flow of data from one
preprocessor to the next depends on traffic conditions, a common situation with advanced features like application identification.
In this case, a preprocessor like HTTP may be extracting and normalizing data that ultimately is not used, or appID may be
repeatedly checking for data that is just not available.
Callbacks help break out of the preprocess straitjacket. This is where one preprocessor supplies another with a function to call
when certain data is available. Snort has started to take this approach to pass some HTTP and SIP preprocessor data to appID.
However, it remains a peripheral feature and still requires the production of data that may not be consumed.
2.5.2 Snort 3 Processing
One of the goals of Snort 3 is to provide a more flexible framework for packet processing by implementing an event-driven
approach. Another is to produce data only when needed to minimize expensive normalizations. However, the basic packet
processing provides very similar functionality.
The basic processing steps Snort 3 takes are similar to Snort 2 as seen in the following diagram. The preprocess step employs
specific inspector types instead of a generalized list, but the basic procedure includes stateless packet decoding, TCP stream
reassembly, and service specific analysis in both cases. (Snort 3 provides hooks for arbitrary inspectors, but they are not central
to basic flow processing and are not shown.)
However, Snort 3 also provides a more flexible mechanism than callback functions. By using inspection events, it is possible for
an inspector to supply data that other inspectors can process. This is known as the observer pattern or publish-subscribe pattern.
Note that the data is not actually published. Instead, access to the data is published, and that means that subscribers can access
the raw or normalized version(s) as needed. Normalizations are done only on the first access, and subsequent accesses get the
previously normalized data. This results in just in time (JIT) processing.
A basic example of this in action is provided by the extra data_log plugin. It is a passive inspector, ie it does nothing until it
receives the data it subscribed for (other in the above diagram). By adding the following to your snort.lua configuration, you will
get a simple URI logger.
data_log = { key = ’http_raw_uri’ }
Inspection events coupled with pluggable inspectors provide a very flexible framework for implementing new features. And JIT
buffer stuffers allow Snort to work smarter, not harder. These capabilities will be leveraged more and more as Snort development
continues.
2.6 Rules
Rules tell Snort how to detect interesting conditions, such as an attack, and what to do when the condition is detected. Here is an
example rule:
Snort 3 User Manual 12 / 290
alert tcp any any -> 192.168.1.1 80 ( msg:"A ha!"; content:"attack"; sid:1; )
The structure is:
action proto source dir dest ( body )
Where:
action - tells Snort what to do when a rule "fires", ie when the signature matches. In this case Snort will log the event. It can also
do thing like block the flow when running inline.
proto - tells Snort what protocol applies. This may be ip, icmp, tcp, udp, http, etc.
source - specifies the sending IP address and port, either of which can be the keyword any, which is a wildcard.
dir - must be either unidirectional as above or bidirectional indicated by <>.
dest - similar to source but indicates the receiving end.
body - detection and other information contained in parenthesis.
There are many rule options available to construct as sophisticated a signature as needed. In this case we are simply looking for
the "attack" in any TCP packet. A better rule might look like this:
alert http
(
msg:"Gotcha!";
flow:established, to_server;
http_uri:"attack";
sid:2;
)
Note that these examples have a sid option, which indicates the signature ID. In general rules are specified by gid:sid:rev notation,
where gid is the generator ID and rev is the revision of the rule. By default, text rules are gid 1 and shared-object (SO) rules are
gid 3. The various components within Snort that generate events have 1XX gids, for example the decoder is gid 116. You can
list the internal gids and sids with these commands:
$ snort --list-gids
$ snort --list-builtin
For details on these and other options, see the reference section.
2.7 Pattern Matching
Snort evaluates rules in a two-step process which includes a fast pattern search and full evaluation of the signature. More details
on this process follow.
2.7.1 Rule Groups
When Snort starts or reloads configuration, rules are grouped by protocol, port and service. For example, all TCP rules using
the HTTP_PORTS variable will go in one group and all service HTTP rules will go in another group. These rule groups are
compiled into multipattern search engines (MPSE) which are designed to search for all patterns with just a single pass through
a given packet or buffer. You can select the algorithm to use for fast pattern searches with search_engine.search_method which
defaults to ac_bnfa, which balances speed and memory. For a faster search at the expense of significantly more memory, use
ac_full. For best performance and reasonable memory, download the hyperscan source from Intel.
Snort 3 User Manual 13 / 290
2.7.2 Fast Patterns
Fast patterns are content strings that have the fast_pattern option or which have been selected by Snort automatically to be used
as a fast pattern. Snort will by default choose the longest pattern in the rule since that is likely to be most unique. That is not
always the case so add fast_pattern to the appropriate content option for best performance. The ideal fast pattern is one which,
if found, is very likely to result in a rule match. Fast patterns that match frequently for unrelated traffic will cause Snort to work
hard with little to show for it.
Certain contents are not eligible to be used as fast patterns. Specifically, if a content is negated, then if it is also relative to another
content, case sensitive, or has non-zero offset or depth, then it is not eligible to be used as a fast pattern.
2.7.3 Rule Evaluation
For each fast pattern match, the corresponding rule(s) are evaluated left-to-right. Rule evaluation requires checking each detection
option in a rule and is a fairly costly process which is why fast patterns are so important. Rule evaluation aborts on the first non-
matching option.
When rule evaluation takes place, the fast pattern match will automatically be skipped if possible. Note that this differs from
Snort 2 which provided the fast_pattern:only option to designate such cases. This is one less thing for the rule writer to worry
about.
3 Tutorial
The section will walk you through building and running Snort. It is not exhaustive but, once you master this material, you should
be able to figure out more advanced usage.
3.1 Dependencies
Required:
autotools or cmake to build from source
daq from http://www.snort.org for packet IO
g++ >= 4.8 or other recent C++11 compiler
dnet from https://github.com/dugsong/libdnet.git for network utility functions
hwloc from https://www.open-mpi.org/projects/hwloc/ for CPU affinity management
LuaJIT from http://luajit.org for configuration and scripting
OpenSSL from https://www.openssl.org/source/ for SHA and MD5 file signatures, the protected_content rule option, and SSL
service detection
pcap from http://www.tcpdump.org for tcpdump style logging
pcre from http://www.pcre.org for regular expression pattern matching
pkgconfig from https://www.freedesktop.org/wiki/Software/pkg-config/ to locate build dependencies
zlib from http://www.zlib.net for decompression (>= 1.2.8 recommended)
Optional:
asciidoc from http://www.methods.co.nz/asciidoc/ to build the HTML manual
cpputest from http://cpputest.github.io to run additional unit tests with make check
Snort 3 User Manual 14 / 290
dblatex from http://dblatex.sourceforge.net to build the pdf manual (in addition to asciidoc)
flatbuffers from https://google.github.io/flatbuffers/ for enabling the flatbuffers serialization format
hyperscan >= 4.4.0 from https://github.com/01org/hyperscan to build new the regex and sd_pattern rule options and hyperscan
search engine
iconv from https://ftp.gnu.org/pub/gnu/libiconv/ for converting UTF16-LE filenames to UTF8 (usually included in glibc)
lzma >= 5.1.2 from http://tukaani.org/xz/ for decompression of SWF and PDF files
safec from https://sourceforge.net/projects/safeclib/ for runtime bounds checks on certain legacy C-library calls
source-highlight from http://www.gnu.org/software/src-highlite/ to generate the dev guide
w3m from http://sourceforge.net/projects/w3m/ to build the plain text manual
uuid from uuid-dev package for unique identifiers
3.2 Building
Optionally built features are listed in the reference section.
Create an install path:
export my_path=/path/to/snorty
mkdir -p $my_path
If you are using a github clone with autotools, do this:
autoreconf -isvf
Now do one of the following:
a. To build with cmake and make, run configure_cmake.sh. It will automatically create and populate a new subdirectory
named build.
./configure_cmake.sh --prefix=$my_path
cd build
make -j 8
make install
ln -s $my_path/conf $my_path/etc
b. You can also specify a cmake project generator:
./configure_cmake.sh --generator=Xcode --prefix=$my_path
c. Or use ccmake directly to configure and generate from an arbitrary build directory like one of these:
ccmake -G Xcode /path/to/Snort++/tree
open snort.xcodeproj
ccmake -G "Eclipse CDT4 - Unix Makefiles" /path/to/Snort++/tree
run eclipse and do File > Import > Existing Eclipse Project
To build with g++ on OS X where clang is installed, do this first:
export CXX=g++
Snort 3 User Manual 15 / 290
3.3 Running
First set up the environment:
export LUA_PATH=$my_path/include/snort/lua/\?.lua\;\;
export SNORT_LUA_PATH=$my_path/etc/snort/
Then give it a go:
Get some help:
$my_path/bin/snort --help
$my_path/bin/snort --help-module suppress
$my_path/bin/snort --help-config | grep thread
Examine and dump a pcap:
$my_path/bin/snort -r <pcap>
$my_path/bin/snort -L dump -d -e -q -r <pcap>
Verify config, with or w/o rules:
$my_path/bin/snort -c $my_path/etc/snort/snort.lua
$my_path/bin/snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample. -
rules
Run IDS mode. To keep it brief, look at the first n packets in each file:
$my_path/bin/snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample. -
rules \
-r <pcap> -A alert_test -n 100000
Let’s suppress 1:2123. We could edit the conf or just do this:
$my_path/bin/snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample. -
rules \
-r <pcap> -A alert_test -n 100000 --lua "suppress = { { gid = 1, sid = 2123 } -
}"
Go whole hog on a directory with multiple packet threads:
$my_path/bin/snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample. -
rules \
--pcap-filter \*.pcap --pcap-dir <dir> -A alert_fast -n 1000 --max-packet- -
threads 8
For more examples, see the usage section.
3.4 Tips
One of the goals of Snort 3 is to make it easier to configure your sensor. Here is a summary of tips and tricks you may find useful.
General Use
Snort tries hard not to error out too quickly. It will report multiple semantic errors.
Snort 3 User Manual 16 / 290
Snort always assumes the simplest mode of operation. Eg, you can omit the -T option to validate the conf if you don’t provide
a packet source.
Warnings are not emitted unless --warn-* is specified. --warn-all enables all warnings, and --pedantic makes such warnings
fatal.
You can process multiple sources at one time by using the -z or --max-threads option.
To make it easy to find the important data, zero counts are not output at shutdown.
Load plugins from the command line with --plugin-path /path/to/install/lib.
You can process multiple sources at one time by using the -z or --max-threads option.
Unit tests are configured with --enable-unit-tests. They can then be run with snort --catch-test [tags]|all.
Lua Configuration
Configure the wizard and default bindings will be created based on configured inspectors. No need to explicitly bind ports in
this case.
You can override or add to your Lua conf with the --lua command line option.
The Lua conf is a live script that is executed when loaded. You can add functions, grab environment variables, compute values,
etc.
You can also rename symbols that you want to disable. For example, changing normalizer to Xnormalizer (an unknown
symbol) will disable the normalizer. This can be easier than commenting in some cases.
By default, symbols unknown to Snort are silently ignored. You can generate warnings for them with --warn-unknown. To
ignore such symbols, export them in the environment variable SNORT_IGNORE.
Writing and Loading Rules
Snort rules allow arbitrary whitespace. Multi-line rules make it easier to structure your rule for clarity. There are multiple ways
to add comments to your rules:
The # character starts a comment to end of line. In addition, all lines between #begin and #end are comments.
The rem option allows you to write a comment that is conveyed with the rule.
C style multi-line comments are allowed, which means you can comment out portions of a rule while testing it out by putting
the options between /* and */.
There are multiple ways to load rules too:
Set ips.rules or ips.include.
include statements can be used in rules files.
Use -R to load a rules file.
Use --stdin-rules with command line redirection.
Use --lua to specify one or more rules as a command line argument.
Output Files
To make it simple to configure outputs when you run with multiple packet threads, output files are not explicitly configured.
Instead, you can use the options below to format the paths:
<logdir>/[<run_prefix>][<id#>][<X>]<name>
Snort 3 User Manual 17 / 290
logdir is set with -l and defaults to ./
run_prefix is set with --run-prefix else not used
id# is the packet thread number that writes the file; with one packet thread, id# (zero) is omitted without --id-zero
X is / if you use --id-subdir, else _ if id# is used
name is based on module name that writes the file
all text mode outputs default to stdout
3.5 Help
Snort has several options to get more help:
-? list command line options (same as --help)
--help this overview of help
--help-commands [<module prefix>] output matching commands
--help-config [<module prefix>] output matching config options
--help-counts [<module prefix>] output matching peg counts
--help-module <module> output description of given module
--help-modules list all available modules with brief help
--help-plugins list all available plugins with brief help
--help-options [<option prefix>] output matching command line options
--help-signals dump available control signals
--list-buffers output available inspection buffers
--list-builtin [<module prefix>] output matching builtin rules
--list-gids [<module prefix>] output matching generators
--list-modules [<module type>] list all known modules
--list-plugins list all known modules
--show-plugins list module and plugin versions
--help*and --list*options preempt other processing so should be last on the
command line since any following options are ignored. To ensure options like
--markup and --plugin-path take effect, place them ahead of the help or list
options.
Options that filter output based on a matching prefix, such as --help-config
won’t output anything if there is no match. If no prefix is given, everything
matches.
Report bugs to bugs@snort.org.
3.6 Common Errors
FATAL: snort_config is required
add this line near top of file:
require(’snort_config’)
PANIC: unprotected error in call to Lua API (cannot open snort_defaults.lua: No such file or directory)
export SNORT_LUA_PATH to point to any dofiles
ERROR can’t find xyz
Snort 3 User Manual 18 / 290
if xyz is the name of a module, make sure you are not assigning a scalar where a table is required (e.g. xyz = 2 should be xyz
= { }).
ERROR can’t find x.y
module x does not have a parameter named y. check --help-module x for available parameters.
ERROR invalid x.y = z
the value z is out of range for x.y. check --help-config x.y for the range allowed.
ERROR: x = { y = z } is in conf but is not being applied
make sure that x = { } isn’t set later because it will override the earlier setting. same for x.y.
FATAL: can’t load lua/errors.lua: lua/errors.lua:68: =expected near ’;’
this is a syntax error reported by Lua to Snort on line 68 of errors.lua.
ERROR: rules(2) unknown rule keyword: find.
this was due to not including the --script-path.
WARNING: unknown symbol x
if you any variables, you can squelch such warnings by setting them in an environment variable SNORT_IGNORE. to ignore
x, y, and z:
export SNORT_IGNORE="x y z"
3.7 Gotchas
A nil key in a table will not caught. Neither will a nil value in a table. Neither of the following will cause errors, nor will they
actually set http_server.post_depth:
http_server = { post_depth }
http_server = { post_depth = undefined_symbol }
It is not an error to set a value multiple times. The actual value applied may not be the last in the table either. It is best to avoid
such cases.
http_server =
{
post_depth = 1234,
post_depth = 4321
}
Snort can’t tell you the exact filename or line number of a semantic error but it will tell you the fully qualified name.
The dump DAQ will not work with multiple threads unless you use --daq-var file=/dev/null. This will be fixed in at some point
to use the Snort log directory, etc.
configure will use clang by default if it is installed.To compile with g instead:
export CXX=g++
Snort 3 User Manual 19 / 290
If you build with hyperscan on OS X and see:
dyld: Library not loaded: @rpath/libhs.4.0.dylib
when you try to run src/snort, export DYLD_LIBRARY_PATH with the path to
libhs. You can also do:
install_name_tool -change @rpath/libhs.4.0.dylib \
/path-to/libhs.4.0.dylib src/snort
4 Usage
For the following examples "$my_path" is assumed to be the path to the Snort install directory. Additionally, it is assumed that
"$my_path/bin" is in your PATH.
4.1 Environment
LUA_PATH is used directly by Lua to load and run required libraries. SNORT_LUA_PATH is used by Snort to load supplemental
configuration files.
export LUA_PATH=$my_path/include/snort/lua/\?.lua\;\;
export SNORT_LUA_PATH=$my_path/etc/snort
4.2 Help
Print the help summary:
snort --help
Get help on a specific module ("stream", for example):
snort --help-module stream
Get help on the "-A" command line option:
snort --help-options A
Grep for help on threads:
snort --help-config | grep thread
Output help on "rule" options in AsciiDoc format:
snort --markup --help-options rule
Note
Snort stops reading command-line options after the "--help-" and "--list-" options, so any other options should be placed before
them.
Snort 3 User Manual 20 / 290
4.3 Sniffing and Logging
Read a pcap:
snort -r /path/to/my.pcap
Dump the packets to stdout:
snort -r /path/to/my.pcap -L dump
Dump packets with application data and layer 2 headers
snort -r /path/to/my.pcap -L dump -d -e
Note
Command line options must be specified separately. "snort -de" won’t work. You can still concatenate options and their
arguments, however, so "snort -Ldump" will work.
Dump packets from all pcaps in a directory:
snort --pcap-dir /path/to/pcap/dir --pcap-filter ’*.pcap’ -L dump -d -e
Log packets to a directory:
snort --pcap-dir /path/to/pcap/dir --pcap-filter ’*.pcap’ -L dump -l /path/to/log/ -
dir
4.4 Configuration
Validate a configuration file:
snort -c $my_path/etc/snort/snort.lua
Validate a configuration file and a separate rules file:
snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample.rules
Read rules from stdin and validate:
snort -c $my_path/etc/snort/snort.lua --stdin-rules < $my_path/etc/snort/sample. -
rules
Enable warnings for Lua configurations and make warnings fatal:
snort -c $my_path/etc/snort/snort.lua --warn-all --pedantic
Tell Snort where to look for additional Lua scripts:
snort --script-path /path/to/script/dir
Snort 3 User Manual 21 / 290
4.5 IDS mode
Run Snort in IDS mode, reading packets from a pcap:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap
Log any generated alerts to the console using the "-A" option:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A alert_full
Capture separate stdout, stderr, and stdlog files (out has startup and shutdown output, err has warnings and errors, and log has
alerts):
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A csv \
1>out 2>err 3>log
Add or modify a configuration from the command line using the "--lua" option:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A cmg \
--lua ’ips = { enable_builtin_rules = true }’
Note
The "--lua" option can be specified multiple times.
Run Snort in IDS mode on an entire directory of pcaps, processing each input source on a separate thread:
snort -c $my_path/etc/snort/snort.lua --pcap-dir /path/to/pcap/dir \
--pcap-filter ’*.pcap’ --max-packet-threads 8
Run Snort on 2 interfaces, eth0 and eth1:
snort -c $my_path/etc/snort/snort.lua -i "eth0 eth1" -z 2 -A cmg
Run Snort inline with the afpacket DAQ:
snort -c $my_path/etc/snort/snort.lua --daq afpacket -i "eth0:eth1" \
-A cmg
4.6 Plugins
Load external plugins and use the "ex" alert:
snort -c $my_path/etc/snort/snort.lua \
--plugin-path $my_path/lib/snort_extra \
-A alert_ex -r /path/to/my.pcap
Test the LuaJIT rule option find loaded from stdin:
snort -c $my_path/etc/snort/snort.lua \
--script-path $my_path/lib/snort_extra \
--stdin-rules -A cmg -r /path/to/my.pcap << END
alert tcp any any -> any 80 (
sid:3; msg:"found"; content:"GET";
find:"pat=’HTTP/1%.%d’" ; )
END
Snort 3 User Manual 22 / 290
4.7 Output Files
To make it simple to configure outputs when you run with multiple packet threads, output files are not explicitly configured.
Instead, you can use the options below to format the paths:
<logdir>/[<run_prefix>][<id#>][<X>]<name>
Log to unified in the current directory:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A unified2
Log to unified in the current directory with a different prefix:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A unified2 \
--run-prefix take2
Log to unified in /tmp:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A unified2 -l /tmp
Run 4 packet threads and log with thread number prefix (0-3):
snort -c $my_path/etc/snort/snort.lua --pcap-dir /path/to/pcap/dir \
--pcap-filter ’*.pcap’ -z 4 -A unified2
Run 4 packet threads and log in thread number subdirs (0-3):
snort -c $my_path/etc/snort/snort.lua --pcap-dir /path/to/pcap/dir \
--pcap-filter ’*.pcap’ -z 4 -A unified2 --id-subdir
Note
subdirectories are created automatically if required. Log filename is based on module name that writes the file. All text mode
outputs default to stdout. These options can be combined.
4.8 DAQ Alternatives
Process hext packets from stdin:
snort -c $my_path/etc/snort/snort.lua \
--daq-dir $my_path/lib/snort/daqs --daq hext -i tty << END
$packet 10.1.2.3 48620 -> 10.9.8.7 80
"GET / HTTP/1.1\r\n"
"Host: localhost\r\n"
"\r\n"
END
Process raw ethernet from hext file:
snort -c $my_path/etc/snort/snort.lua \
--daq-dir $my_path/lib/snort/daqs --daq hext \
--daq-var dlt=1 -r <hext-file>
Process a directory of plain files (ie non-pcap) with 4 threads with 8K buffers:
snort -c $my_path/etc/snort/snort.lua \
--daq-dir $my_path/lib/snort/daqs --daq file \
--pcap-dir path/to/files -z 4 -s 8192
Snort 3 User Manual 23 / 290
Bridge two TCP connections on port 8000 and inspect the traffic:
snort -c $my_path/etc/snort/snort.lua \
--daq-dir $my_path/lib/snort/daqs --daq socket
4.9 Logger Alternatives
Dump TCP stream payload in hext mode:
snort -c $my_path/etc/snort/snort.lua -L hext
Output timestamp, pkt_num, proto, pkt_gen, dgm_len, dir, src_ap, dst_ap, rule, action for each alert:
snort -c $my_path/etc/snort/snort.lua -A csv
Output the old test format alerts:
snort -c $my_path/etc/snort/snort.lua \
--lua "alert_csv = { fields = ’pkt_num gid sid rev’, separator = ’\t’ }"
4.10 Shell
You must build with --enable-shell to make the command line shell available.
Enable shell mode:
snort --shell <args>
You will see the shell mode command prompt, which looks like this:
o")~
(The prompt can be changed with the SNORT_PROMPT environment variable.)
You can pause immediately after loading the configuration and again before exiting with:
snort --shell --pause <args>
In that case you must issue the resume() command to continue. Enter quit() to terminate Snort or detach() to exit the shell. You
can list the available commands with help().
To enable local telnet access on port 12345:
snort --shell -j 12345 <args>
The command line interface is still under development. Suggestions are welcome.
4.11 Signals
Note
The following examples assume that Snort is currently running and has a process ID of <pid>.
Modify and Reload Configuration:
echo ’suppress = { { gid = 1, sid = 2215 } }’ >> $my_path/etc/snort/snort.lua
kill -hup <pid>
Snort 3 User Manual 24 / 290
Dump stats to stdout:
kill -usr1 <pid>
Shutdown normally:
kill -term <pid>
Exit without flushing packets:
kill -quit <pid>
List available signals:
snort --help-signals
Note
The available signals may vary from platform to platform.
5 Features
This section explains how to use key features of Snort.
5.1 AppId
Network administrators need application awareness in order to fine tune their management of the ever-growing number of appli-
cations passing traffic over the network. Application awareness allows an administrator to create rules for applications as needed
by the business. The rules can be used to take action based on the application, such as block, allow or alert.
5.1.1 Overview
The AppId inspector provides an application level view when managing networks by providing the following features:
Network control: The inspector works with Snort rules by providing a set of application identifiers (AppIds) to Snort rule
writers.
Application usage awareness: The inspector outputs statistics to show how many times applications are being used on the
network.
Custom applications: Administrators can create their own application detectors to detect new applications. The detectors are
written in Lua and interface with Snort using a well-defined C-Lua API.
Open Detector Package (ODP): A set of pre-defined application detectors are provided by the Snort team and can be down-
loaded from snort.org.
5.1.2 Dependency Requirements
For proper functioning of the AppId inspector, at a minimum stream flow tracking must be enabled. In addition, to identify
TCP-based or UDP-based applications then the appropriate stream inspector must be enabled, e.g. stream_tcp or stream_udp.
In addition, in order to identify HTTP-based applications, the HTTP inspector must be enabled. Otherwise, only non-HTTP
applications will be identified.
AppId subscribes to the inspection events published by other inspectors, such as the HTTP and SSL inspectors, to gain access to
the data needed. It uses that data to help determine the application ID.
Snort 3 User Manual 25 / 290
5.1.3 Configuration
The AppId feature can be enabled via configuration. To enable it with the default settings use:
appid = { }
To use an AppId as a matching parameter in an IPS rule, use the appids keyword. For example, to block HTTP traffic that
contains a specific header:
block tcp any any -> 192.168.0.1 any ( msg:"Block Malicious HTTP header";
appids:"HTTP"; content:"X-Header: malicious"; sid:18000; )
Alternatively, the HTTP application can be specified in place of tcp instead of using the appids keyword. The AppId inspector
will set the service when it is discovered so it can be used in IPS rules like this. Note that this rule also does not specify the IPs
or ports which default to any.
block http ( msg:"Block Malicious HTTP header";
content:"X-Header: malicious"; sid:18000; )
It’s possible to specify multiple applications (as many as desired) with the appids keyword. A rule is considered a match if any
of the applications on the rule match. Note that this rule does not match specific content which will reduce performance.
alert tcp any any -> 192.168.0.1 any ( msg:"Alert ";
appids:"telnet,ssh,smtp,http";
Below is a minimal Snort configuration that is sufficient to block flows based on a specific HTTP header:
require("snort_config")
dir = os.getenv(’SNORT_LUA_PATH’)
if ( not dir ) then
dir = ’.’
end
dofile(dir .. ’/snort_defaults.lua’)
local_rules =
[[
block http ( msg:"openAppId: test content match for app http";
content:"X-Header: malicious"; sid:18760; rev:4; )
]]
stream = { }
stream_tcp = { }
binder =
{
{
when =
{
proto = ’tcp’,
ports = [[ 80 8080 ]],
},
use =
Snort 3 User Manual 26 / 290
{
type = ’http_inspect’,
},
},
}
http_inspect = { }
appid = { }
ips =
{
rules = local_rules,
}
5.1.4 Session Application Identifiers
There are up to four AppIds stored in a session as defined below:
serviceAppId - An appId associated with server side of a session. Example: http server.
clientAppId - An appId associated with application on client side of a session. Example: Firefox.
payloadAppId - For services like http this appId is associated with a webserver host. Example: Facebook.
miscAppId - For some encapsulated protocols, this is the highest encapsulated application.
For packets originating from the client, a payloadAppid in a session is matched with all AppIds listed on a rule. Thereafter
miscAppId, clientAppId and serviceAppId are matched. Since Alert Events contain one AppId, only the first match is reported.
If a rule without an appids option matches, then the most specific appId (in order of payload, misc, client, server) is reported.
The same logic is followed for packets originating from the server with one exception. The order of matching is changed to make
serviceAppId come before clientAppId.
5.1.5 AppId Usage Statistics
The AppId inspector prints application network usage periodically in the snort log directory in unified2 format. File name, time
interval for statistic and file rollover are controlled by appId inspection configuration.
5.1.6 Open Detector Package (ODP) Installation
Application detectors from Snort team will be delivered in a separate package called the Open Detector Package (ODP) that can
be downloaded from snort.org. ODP is a package that contains the following artifacts:
Application detectors in the Lua language.
Port detectors, which are port only application detectors, in meta-data in YAML format.
appMapping.data file containing application metadata. This file should not be modified. The first column contains application
identifier and second column contains application name. Other columns contain internal information.
Lua library files DetectorCommon.lua, flowTrackerModule.lua and hostServiceTrackerModule.lua
A user can install the ODP package in any directory and configure this directory via the app_detector_dir option in the appid
preprocessor configuration. Installing ODP will not modify any subdirectory named custom, where user-created detectors are
located.
When installed, ODP will create following sub-directories:
Snort 3 User Manual 27 / 290
odp/port //Cisco port-only detectors
odp/lua //Cisco Lua detectors
odp/libs //Cisco Lua modules
5.1.7 User Created Application Detectors
Users can detect new applications by adding detectors in the Lua language. A document will be posted on the Snort Website
with details on API. Users can also copy over Snort team provided detectors and modify them. Users can also use the detector
creation tool described in the next section.
Users must organize their Lua detectors and libraries by creating the following directory structure, under the ODP installation
directory.
custom/port //port-only detectors
custom/lua //Lua detectors
custom/libs //Lua modules
The root path is specified by the "app_detector_dir" parameter of the appid section of snort.conf:
appid =
{
app_detector_dir = ’/usr/local/lib/openappid’,
}
So the path to the user-created lua files would be /usr/local/lib/openappid/custom/lua/
None of the directories below /usr/local/lib/openappid/ would be added for you.
5.1.8 Application Detector Creation Tool
For rudimentary Lua detectors, there is a tool provided called appid_detector_builder.sh. This is a simple, menu-driven bash
script which creates .lua files in your current directory, based on your choices and on patterns you supply.
When you launch the script, it will prompt for the Application Id that you are giving for your detector. This is free-form ASCII
with minor restrictions. The Lua detector file will be named based on your Application Id. If the file name already exists you
will be prompted to overwrite it.
You will also be prompted for a description of your detector to be placed in the comments of the Lua source code. This is
optional.
You will then be asked a series of questions designed to construct Lua code based on the kind of pattern data, protocol, port(s),
etc.
When complete, the Protocol menu will be changed to include the option, "Save Detector". Instead of saving the file and exiting
the script, you are allowed to give additional criteria for another pattern which may also be incorporated in the detection scheme.
Then either pattern, when matched, will be considered a valid detection.
For example, your first choices might create an HTTP detection pattern of "example.com", and the next set of choices would add
the HTTP detection pattern of "example.uk.co" (an equally fictional British counterpart). They would then co-exist in the Lua
detector, and either would cause a detection with the name you give for your Application Id.
The resulting .lua file will need to be placed in the directory, "custom/lua", described in the previous section of the README
above called "User Created Application Detectors"
Snort 3 User Manual 28 / 290
5.2 Binder
One of the fundamental differences between Snort 2 and Snort 3 concerns configuration related to networks and ports. Here is a
brief review of Snort 2 configuration for network and service related components:
Snort’s configuration has a default policy and optional policies selected by VLAN or network (with config binding).
Each policy contains a user defined set of preprocessor configurations.
Each preprocessor has a default configuration and some support non-default configurations selected by network.
Most preprocessors have port configurations.
The default policy may also contain a list of ports to ignore.
In Snort 3, the above configurations are done in a single module called the binder. Here is an example:
binder =
{
-- allow all tcp port 22:
-- (similar to Snort 2 config ignore_ports)
{ when = { proto = ’tcp’, ports = ’22’ }, use = { action = ’allow’ } },
-- select a config file by vlan
-- (similar to Snort 2 config binding by vlan)
{ when = { vlans = ’1024’ }, use = { file = ’vlan.lua’ } },
-- use a non-default HTTP inspector for port 8080:
-- (similar to a Snort 2 targeted preprocessor config)
{ when = { nets = ’192.168.0.0/16’, proto = ’tcp’, ports = ’8080’ },
use = { name = ’alt_http’, type = ’http_inspect’ } },
-- use the default inspectors:
-- (similar to a Snort 2 default preprocessor config)
{ when = { proto = ’tcp’ }, use = { type = ’stream_tcp’ } },
{ when = { service = ’http’ }, use = { type = ’http_inspect’ } },
-- figure out which inspector to run automatically:
{ use = { type = ’wizard’ } }
}
Bindings are evaluated when a session starts and again if and when service is identified on the session. Essentially, the bindings
are a list of when-use rules evaluated from top to bottom. The first matching network and service configurations are applied.
binder.when can contain any combination of criteria and binder.use can specify an action, config file, or inspector configuration.
5.3 Byte rule options
5.3.1 byte_test
This rule option tests a byte field against a specific value (with operator). Capable of testing binary values or converting repre-
sentative byte strings to their binary equivalent and testing them.
Snort uses the C operators for each of these operators. If the & operator is used, then it would be the same as using
if (data & value) { do_something(); }
Note: The bitmask option applies bitwise AND operator on the bytes converted. The result will be right-shifted by the number
of bits equal to the number of trailing zeros in the mask. This applies for the other rule options as well.
Snort 3 User Manual 29 / 290
Examples
alert tcp (byte_test:2, =, 568, 0, bitmask 0x3FF0;)
This example extracts 2 bytes at offset 0, performs bitwise and with bitmask 0x3FF0, shifts the result by 4 bits and compares to
568.
alert udp (byte_test:4, =, 1234, 0, string, dec;
msg:"got 1234!";)
alert udp (byte_test:8, =, 0xdeadbeef, 0, string, hex;
msg:"got DEADBEEF!";)
5.3.2 byte_jump
The byte_jump rule option allows rules to be written for length encoded protocols trivially. By having an option that reads the
length of a portion of data, then skips that far forward in the packet, rules can be written that skip over specific portions of
length-encoded protocols and perform detection in very specific locations.
Examples
alert tcp (content:"Begin";
byte_jump:0, 0, from_end, post_offset -6;
content:"end..", distance 0, within 5;
msg:"Content match from end of the payload";)
alert tcp (content:"catalog";
byte_jump:2, 1, relative, post_offset 2, bitmask 0x03f0;
byte_test:2, =, 968, 0, relative;
msg:"Bitmask applied on the 2 bytes extracted for byte_jump";)
5.3.3 byte_extract
The byte_extract keyword is another useful option for writing rules against length-encoded protocols. It reads in some number
of bytes from the packet payload and saves it to a variable. These variables can be referenced later in the rule, instead of using
hard-coded values.
Other options which use byte_extract variables
A byte_extract rule option detects nothing by itself. Its use is in extracting packet data for use in other rule options.
Here is a list of places where byte_extract variables can be used:
content/uricontent: offset, depth, distance, within
byte_test: offset, value
byte_jump: offset, post_offset
isdataat: offset
Snort 3 User Manual 30 / 290
Examples
alert tcp (byte_extract:1, 0, str_offset;
byte_extract:1, 1, str_depth;
content:"bad stuff", offset str_offset, depth str_depth;
msg:"Bad Stuff detected within field";)
alert tcp (content:"START"; byte_extract:1, 0, myvar, relative;
byte_jump:1, 3, relative, post_offset myvar;
content:"END", distance 6, within 3;
msg: "byte_jump - pass variable to post_offset";)
This example uses two variables.
The first variable keeps the offset of a string, read from a byte at offset 0. The second variable keeps the depth of a string, read
from a byte at offset 1. These values are used to constrain a pattern match to a smaller area.
alert tcp (content:"|04 63 34 35|", offset 4, depth 4;
byte_extract: 2, 0, var_match, relative, bitmask 0x03ff;
byte_test: 2, =, var_match, 2, relative;
msg:"Test value match, after applying bitmask on bytes extracted";)
5.3.4 byte_math
Perform a mathematical operation on an extracted value and a specified value or existing variable, and store the outcome in a
new resulting variable. These resulting variables can be referenced later in the rule, at the same places as byte_extract variables.
The syntax for this rule option is different. The order of the options is critical for the other rule options and can’t be changed. For
example, the first option is the number of bytes to extract. Here the name of the option is explicitly written, for example : bytes
2. The order is not important.
Note
Byte_math operations are performed on unsigned 32-bit values. When writing a rule it should be taken into consideration to
avoid wrap around.
Examples
alert tcp ( byte_math: bytes 2, offset 0, oper *, rvalue 10, result area;
byte_test:2,>,area,16;)
At the zero offset of the payload, extract 2 bytes and apply multiplication operation with value 10. Store result in variable area.
The area variable is given as input to byte_test value option.
Let’s consider 2 bytes of extracted data is 5. The rvalue is 10. Result variable area is 50 ( 5 * 10 ). Area variable can be used in
either byte_test offset/value options.
5.3.5 Testing Numerical Values
The rule options byte_test and byte_jump were written to support writing rules for protocols that have length encoded data. RPC
was the protocol that spawned the requirement for these two rule options, as RPC uses simple length based encoding for passing
data.
In order to understand why byte test and byte jump are useful, let’s go through an exploit attempt against the sadmind service.
This is the payload of the exploit:
Snort 3 User Manual 31 / 290
89 09 9c e2 00 00 00 00 00 00 00 02 00 01 87 88 ................
00 00 00 0a 00 00 00 01 00 00 00 01 00 00 00 20 ...............
40 28 3a 10 00 00 00 0a 4d 45 54 41 53 50 4c 4f @(:.....metasplo
49 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 it..............
00 00 00 00 00 00 00 00 40 28 3a 14 00 07 45 df ........@(:...e.
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 06 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 04 00 00 00 00 00 00 00 04 ................
7f 00 00 01 00 01 87 88 00 00 00 0a 00 00 00 04 ................
7f 00 00 01 00 01 87 88 00 00 00 0a 00 00 00 11 ................
00 00 00 1e 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 3b 4d 45 54 41 53 50 4c 4f .......;metasplo
49 54 00 00 00 00 00 00 00 00 00 00 00 00 00 00 it..............
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00 00 00 00 00 00 00 06 73 79 73 74 65 6d 00 00 ........system..
00 00 00 15 2e 2e 2f 2e 2e 2f 2e 2e 2f 2e 2e 2f ....../../../../
2e 2e 2f 62 69 6e 2f 73 68 00 00 00 00 00 04 1e ../bin/sh.......
Let’s break this up, describe each of the fields, and figure out how to write a rule to catch this exploit.
There are a few things to note with RPC:
Numbers are written as uint32s, taking four bytes. The number 26 would show up as 0x0000001a.
Strings are written as a uint32 specifying the length of the string, the string, and then null bytes to pad the length of the string to
end on a 4-byte boundary. The string bob would show up as 0x00000003626f6200.
89 09 9c e2 - the request id, a random uint32, unique to each request
00 00 00 00 - rpc type (call = 0, response = 1)
00 00 00 02 - rpc version (2)
00 01 87 88 - rpc program (0x00018788 = 100232 = sadmind)
00 00 00 0a - rpc program version (0x0000000a = 10)
00 00 00 01 - rpc procedure (0x00000001 = 1)
00 00 00 01 - credential flavor (1 = auth_unix)
00 00 00 20 - length of auth_unix data (0x20 = 32)
## the next 32 bytes are the auth_unix data
40 28 3a 10 - unix timestamp (0x40283a10 = 1076378128 = feb 10 01:55:28 2004 gmt)
00 00 00 0a - length of the client machine name (0x0a = 10)
4d 45 54 41 53 50 4c 4f 49 54 00 00 - metasploit
00 00 00 00 - uid of requesting user (0)
00 00 00 00 - gid of requesting user (0)
00 00 00 00 - extra group ids (0)
00 00 00 00 - verifier flavor (0 = auth_null, aka none)
00 00 00 00 - length of verifier (0, aka none)
The rest of the packet is the request that gets passed to procedure 1 of sadmind.
However, we know the vulnerability is that sadmind trusts the uid coming from the client. sadmind runs any request where the
client’s uid is 0 as root. As such, we have decoded enough of the request to write our rule.
First, we need to make sure that our packet is an RPC call.
content:"|00 00 00 00|", offset 4, depth 4;
Snort 3 User Manual 32 / 290
Then, we need to make sure that our packet is a call to sadmind.
content:"|00 01 87 88|", offset 12, depth 4;
Then, we need to make sure that our packet is a call to the procedure 1, the vulnerable procedure.
content:"|00 00 00 01|", offset 20, depth 4;
Then, we need to make sure that our packet has auth_unix credentials.
content:"|00 00 00 01|", offset 24, depth 4;
We don’t care about the hostname, but we want to skip over it and check a number value after the hostname. This is where
byte_test is useful. Starting at the length of the hostname, the data we have is:
00 00 00 0a 4d 45 54 41 53 50 4c 4f 49 54 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
We want to read 4 bytes, turn it into a number, and jump that many bytes forward, making sure to account for the padding that
RPC requires on strings. If we do that, we are now at:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00
which happens to be the exact location of the uid, the value we want to check.
In English, we want to read 4 bytes, 36 bytes from the beginning of the packet, and turn those 4 bytes into an integer and jump
that many bytes forward, aligning on the 4-byte boundary. To do that in a Snort rule, we use:
byte_jump:4,36,align;
then we want to look for the uid of 0.
content:"|00 00 00 00|", within 4;
Now that we have all the detection capabilities for our rule, let’s put them all together.
content:"|00 00 00 00|", offset 4, depth 4;
content:"|00 01 87 88|", offset 12, depth 4;
content:"|00 00 00 01|", offset 20, depth 4;
content:"|00 00 00 01|", offset 24, depth 4;
byte_jump:4,36,align;
content:"|00 00 00 00|", within 4;
The 3rd and fourth string match are right next to each other, so we should combine those patterns. We end up with:
content:"|00 00 00 00|", offset 4, depth 4;
content:"|00 01 87 88|", offset 12, depth 4;
content:"|00 00 00 01 00 00 00 01|", offset 20, depth 8;
byte_jump:4,36,align;
content:"|00 00 00 00|", within 4;
If the sadmind service was vulnerable to a buffer overflow when reading the client’s hostname, instead of reading the length of
the hostname and jumping that many bytes forward, we would check the length of the hostname to make sure it is not too large.
To do that, we would read 4 bytes, starting 36 bytes into the packet, turn it into a number, and then make sure it is not too large
(let’s say bigger than 200 bytes). In Snort, we do:
byte_test:4,>,200,36;
Snort 3 User Manual 33 / 290
Our full rule would be:
content:"|00 00 00 00|", offset 4, depth 4;
content:"|00 01 87 88|", offset 12, depth 4;
content:"|00 00 00 01 00 00 00 01|", offset 20, depth 8;
byte_test:4,>,200,36;
5.4 DCE Inspectors
The main purpose of these inspector are to perform SMB desegmentation and DCE/RPC defragmentation to avoid rule evasion
using these techniques.
5.4.1 Overview
The following transports are supported for DCE/RPC: SMB, TCP, and UDP. New rule options have been implemented to improve
performance, reduce false positives and reduce the count and complexity of DCE/RPC based rules.
Different from Snort 2, the DCE-RPC preprocessor is split into three inspectors - one for each transport: dce_smb, dce_tcp,
dce_udp. This includes the configuration as well as the inspector modules. The Snort 2 server configuration is now split between
the inspectors. Options that are meaningful to all inspectors, such as policy and defragmentation, are copied into each inspector
configuration. The address/port mapping is handled by the binder. Autodetect functionality is replaced by wizard curses.
5.4.2 Quick Guide
A typical dcerpce configuration looks like this:
binder =
{
{
when =
{
proto = ’tcp’,
ports = ’139 445 1025’,
},
use =
{
type = ’dce_smb’,
},
},
{
when =
{
proto = ’tcp’,
ports = ’135 2103’,
},
use =
{
type = ’dce_tcp’,
},
},
{
when =
{
proto = ’udp’,
ports = ’1030’,
Snort 3 User Manual 34 / 290
},
use =
{
type = ’dce_udp’,
},
}
}
dce_smb = { }
dce_tcp = { }
dce_udp = { }
In this example, it defines smb, tcp and udp inspectors based on port. All the configurations are default.
5.4.3 Target Based
There are enough important differences between Windows and Samba versions that a target based approach has been imple-
mented. Some important differences:
Named pipe instance tracking
Accepted SMB commands
AndX command chaining
Transaction tracking
Multiple Bind requests
DCE/RPC Fragmented requests - Context ID
DCE/RPC Fragmented requests - Operation number
DCE/RPC Stub data byte order
Because of those differences, each inspector can be configured to different policy. Here are the list of policies supported:
WinXP (default)
• Win2000
• WinVista
• Win2003
• Win2008
• Win7
• Samba
• Samba-3.0.37
• Samba-3.0.22
• Samba-3.0.20
Snort 3 User Manual 35 / 290
5.4.4 Reassembling
Both SMB inspector and TCP inspector support reassemble. Reassemble threshold specifies a minimum number of bytes in the
DCE/RPC desegmentation and defragmentation buffers before creating a reassembly packet to send to the detection engine. This
option is useful in inline mode so as to potentially catch an exploit early before full defragmentation is done. A value of 0 s
supplied as an argument to this option will, in effect, disable this option. Default is disabled.
5.4.5 SMB
SMB inspector is one of the most complex inspectors. In addition to supporting rule options and lots of inspector rule events, it
also supports file processing for both SMB version 1, 2, and 3.
Finger Print Policy
In the initial phase of an SMB session, the client needs to authenticate with a SessionSetupAndX. Both the request and response
to this command contain OS and version information that can allow the inspector to dynamically set the policy for a session
which allows for better protection against Windows and Samba specific evasions.
File Inspection
SMB inspector supports file inspection. A typical configuration looks like this:
binder =
{
{
when =
{
proto = ’tcp’,
ports = ’139 445’,
},
use =
{
type = ’dce_smb’,
},
},
}
dce_smb =
{
smb_file_inspection = ’on’,
smb_file_depth = 0,
}
file_id =
{
enable_type = true,
enable_signature = true,
enable_capture = true,
file_rules = magics,
}
First, define a binder to map tcp port 139 and 445 to smb. Then, enable file inspection in smb inspection and set the file depth as
unlimited. Lastly, enable file inspector to inspect file type, calculate file signature, and capture file. The details of file inspector
are explained in file processing section.
Snort 3 User Manual 36 / 290
SMB inspector does inspection of normal SMB file transfers. This includes doing file type and signature through the file pro-
cessing as well as setting a pointer for the "file_data" rule option. Note that the "file_depth" option only applies to the maximum
amount of file data for which it will set the pointer for the "file_data" rule option. For file type and signature it will use the
value configured for the file API. If "only" is specified, the inspector will only do SMB file inspection, i.e. it will not do any
DCE/RPC tracking or inspection. If "on" is specified with no arguments, the default file depth is 16384 bytes. An argument of
-1 to "file-depth" disables setting the pointer for "file_data", effectively disabling SMB file inspection in rules. An argument of 0
to "file_depth" means unlimited. Default is "off", i.e. no SMB file inspection is done in the inspector.
5.4.6 TCP
dce_tcp inspector supports defragmentation, reassembling, and policy that is similar to SMB.
5.4.7 UDP
dce_udp is a very simple inspector that only supports defragmentation
5.4.8 Rule Options
New rule options are supported by enabling the dcerpc2 inspectors:
• dce_iface
• dce_opnum
• dce_stub_data
New modifiers to existing byte_test and byte_jump rule options:
byte_test: dce
byte_jump: dce
dce_iface
For DCE/RPC based rules it has been necessary to set flow-bits based on a client bind to a service to avoid false positives. It is
necessary for a client to bind to a service before being able to make a call to it. When a client sends a bind request to the server,
it can, however, specify one or more service interfaces to bind to. Each interface is represented by a UUID. Each interface UUID
is paired with a unique index (or context id) that future requests can use to reference the service that the client is making a call to.
The server will respond with the interface UUIDs it accepts as valid and will allow the client to make requests to those services.
When a client makes a request, it will specify the context id so the server knows what service the client is making a request
to. Instead of using flow-bits, a rule can simply ask the inspector, using this rule option, whether or not the client has bound
to a specific interface UUID and whether or not this client request is making a request to it. This can eliminate false positives
where more than one service is bound to successfully since the inspector can correlate the bind UUID to the context id used in
the request. A DCE/RPC request can specify whether numbers are represented as big endian or little endian. The representation
of the interface UUID is different depending on the endianness specified in the DCE/RPC previously requiring two rules - one
for big endian and one for little endian. The inspector eliminates the need for two rules by normalizing the UUID. An interface
contains a version. Some versions of an interface may not be vulnerable to a certain exploit. Also, a DCE/RPC request can be
broken up into 1 or more fragments. Flags (and a field in the connectionless header) are set in the DCE/RPC header to indicate
whether the fragment is the first, a middle or the last fragment. Many checks for data in the DCE/RPC request are only relevant if
the DCE/RPC request is a first fragment (or full request), since subsequent fragments will contain data deeper into the DCE/RPC
request. A rule which is looking for data, say 5 bytes into the request (maybe it’s a length field), will be looking at the wrong data
on a fragment other than the first, since the beginning of subsequent fragments are already offset some length from the beginning
of the request. This can be a source of false positives in fragmented DCE/RPC traffic. By default it is reasonable to only evaluate
if the request is a first fragment (or full request). However, if the "any_frag" option is used to specify evaluating on all fragments.
Examples:
Snort 3 User Manual 37 / 290
dce_iface: 4b324fc8-1670-01d3-1278-5a47bf6ee188;
dce_iface: 4b324fc8-1670-01d3-1278-5a47bf6ee188,<2;
dce_iface: 4b324fc8-1670-01d3-1278-5a47bf6ee188,any_frag;
dce_iface: 4b324fc8-1670-01d3-1278-5a47bf6ee188,=1,any_frag;
This option is used to specify an interface UUID. Optional arguments are an interface version and operator to specify that the
version be less than (<), greater than (>), equal to (=) or not equal to (!) the version specified. Also, by default the rule will
only be evaluated for a first fragment (or full request, i.e. not a fragment) since most rules are written to start at the beginning of
a request. The "any_frag" argument says to evaluate for middle and last fragments as well. This option requires tracking client
Bind and Alter Context requests as well as server Bind Ack and Alter Context responses for connection-oriented DCE/RPC in
the inspector. For each Bind and Alter Context request, the client specifies a list of interface UUIDs along with a handle (or
context id) for each interface UUID that will be used during the DCE/RPC session to reference the interface. The server response
indicates which interfaces it will allow the client to make requests to - it either accepts or rejects the client’s wish to bind to a
certain interface. This tracking is required so that when a request is processed, the context id used in the request can be correlated
with the interface UUID it is a handle for.
hexlong and hexshort will be specified and interpreted to be in big endian order (this is usually the default way an interface UUID
will be seen and represented). As an example, the following Messenger interface UUID as taken off the wire from a little endian
Bind request:
|f8 91 7b 5a 00 ff d0 11 a9 b2 00 c0 4f b6 e6 fc|
must be written as:
5a7b91f8-ff00-11d0-a9b2-00c04fb6e6fc
The same UUID taken off the wire from a big endian Bind request:
|5a 7b 91 f8 ff 00 11 d0 a9 b2 00 c0 4f b6 e6 fc|
must be written the same way:
5a7b91f8-ff00-11d0-a9b2-00c04fb6e6fc
This option matches if the specified interface UUID matches the interface UUID (as referred to by the context id) of the DCE/RPC
request and if supplied, the version operation is true. This option will not match if the fragment is not a first fragment (or full
request) unless the "any_frag" option is supplied in which case only the interface UUID and version need match. Note that a
defragmented DCE/RPC request will be considered a full request.
Using this rule option will automatically insert fast pattern contents into the fast pattern matcher. For UDP rules, the inter-
face UUID, in both big and little endian format will be inserted into the fast pattern matcher. For TCP rules, (1) if the rule
option "flow:to_server|from_client" is used, |05 00 00| will be inserted into the fast pattern matcher, (2) if the rule option
"flow:from_server|to_client" is used, |05 00 02| will be inserted into the fast pattern matcher and (3) if the flow isn’t known,
|05 00| will be inserted into the fast pattern matcher. Note that if the rule already has content rule options in it, the best (meaning
longest) pattern will be used. If a content in the rule uses the fast_pattern rule option, it will unequivocally be used over the above
mentioned patterns.
dce_opnum
The opnum represents a specific function call to an interface. After is has been determined that a client has bound to a specific
interface and is making a request to it (see above - dce_iface) usually we want to know what function call it is making to that
service. It is likely that an exploit lies in the particular DCE/RPC function call.
Examples:
dce_opnum: 15;
dce_opnum: 15-18;
dce_opnum: 15,18-20;
dce_opnum: 15,17,20-22;
Snort 3 User Manual 38 / 290
This option is used to specify an opnum (or operation number), opnum range or list containing either or both opnum and/or
opnum-range. The opnum of a DCE/RPC request will be matched against the opnums specified with this option. This option
matches if any one of the opnums specified match the opnum of the DCE/RPC request.
dce_stub_data
Since most DCE/RPC based rules had to do protocol decoding only to get to the DCE/RPC stub data, i.e. the remote procedure
call or function call data, this option will alleviate this need and place the cursor at the beginning of the DCE/RPC stub data. This
reduces the number of rule option checks and the complexity of the rule.
This option takes no arguments.
Example:
dce_stub_data;
This option is used to place the cursor (used to walk the packet payload in rules processing) at the beginning of the DCE/RPC
stub data, regardless of preceding rule options. There are no arguments to this option. This option matches if there is DCE/RPC
stub data.
The cursor is moved to the beginning of the stub data. All ensuing rule options will be considered "sticky" to this buffer. The first
rule option following dce_stub_data should use absolute location modifiers if it is position-dependent. Subsequent rule options
should use a relative modifier if they are meant to be relative to a previous rule option match in the stub data buffer. Any rule
option that does not specify a relative modifier will be evaluated from the start of the stub data buffer. To leave the stub data
buffer and return to the main payload buffer, use the "pkt_data" rule option.
byte_test and byte_jump
A DCE/RPC request can specify whether numbers are represented in big or little endian. These rule options will take as a new
argument "dce" and will work basically the same as the normal byte_test/byte_jump, but since the DCE/RPC inspector will know
the endianness of the request, it will be able to do the correct conversion.
Examples:
byte_test: 4,>,35000,0,relative,dce;
byte_test: 2,!=,2280,-10,relative,dce;
When using the "dce" argument to a byte_test, the following normal byte_test arguments will not be allowed: "big", "little",
"string", "hex", "dec" and "oct".
Examples:
byte_jump:4,-4,relative,align,multiplier 2,post_offset -4,dce;
When using the dce argument to a byte_jump, the following normal byte_jump arguments will not be allowed: "big", "little",
"string", "hex", "dec", "oct" and "from_beginning"
5.5 File Processing
With the volume of malware transferred through network increasing, network file inspection becomes more and more important.
This feature will provide file type identification, file signature creation, and file capture capabilities to help users deal with those
challenges.
Snort 3 User Manual 39 / 290
5.5.1 Overview
There are two parts of file services: file APIs and file policy. File APIs provides all the file inspection functionalities, such as file
type identification, file signature calculation, and file capture. File policy provides users ability to control file services, such as
enable/disable/configure file type identification, file signature, or file capture.
In addition to all capabilities from Snort 2, we support customized file policy along with file event log.
Supported protocols: HTTP, SMTP, IMAP, POP3, FTP, and SMB.
Supported file signature calculation: SHA256
5.5.2 Quick Guide
A very simple configuration has been included in lua/snort.lua file. A typical file configuration looks like this:
dofile(’magic.lua’)
my_file_policy =
{
{ when = { file_type_id = 0 }, use = { verdict = ’log’, enable_file_signature -
= true, enable_file_capture = true } }
{ when = { file_type_id = 22 }, use = { verdict = ’log’, -
enable_file_signature = true } },
{ when = { sha256 = " -
F74DC976BC8387E7D4FC0716A069017A0C7ED13F309A523CC41A8739CCB7D4B6" }, use = -
{ verdict = ’block’} },
}
file_id =
{
enable_type = true,
enable_signature = true,
enable_capture = true,
file_rules = magics,
trace_type = true,
trace_signature = true,
trace_stream = true,
file_policy = my_file_policy,
}
file_log =
{
log_pkt_time = true,
log_sys_time = false,
}
There are 3 steps to enable file processing:
First, you need to include the file magic rules.
Then, define the file policy and configure the inspector
At last, enable file_log to get detailed information about file event
Snort 3 User Manual 40 / 290
5.5.3 Pre-packaged File Magic Rules
A set of file magic rules is packaged with Snort. They can be located at "lua/file_magic.lua". To use this feature, it is recom-
mended that these pre-packaged rules are used; doing so requires that you include the file in your Snort configuration as such
(already in snort.lua):
dofile(’magic.lua’)
Example:
{ type = "GIF", id = 62, category = "Graphics", rev = 1,
magic = { { content = "| 47 49 46 38 37 61 |",offset = 0 } } },
{ type = "GIF", id = 63, category = "Graphics", rev = 1,
magic = { { content = "| 47 49 46 38 39 61 |",offset = 0 } } },
The previous two rules define GIF format, because two file magics are different. File magics are specified by content and offset,
which look at content at particular file offset to identify the file type. In this case, two magics look at the beginning of the file.
You can use character if it is printable or hex value in between "|".
5.5.4 File Policy
You can enabled file type, file signature, or file capture by configuring file_id. In addition, you can enable trace to see file stream
data, file type, and file signature information.
Most importantly, you can configure a file policy that can block/alert some file type or an individual file based on SHA. This
allows you build a file blacklist or whitelist.
Example:
file_policy =
{
{ when = { file_type_id = 22 }, use = { verdict = ’log’, -
enable_file_signature = true } },
{ when = { sha256 = " -
F74DC976BC8387E7D4FC0716A069017A0C7ED13F309A523CC41A8739CCB7D4B6" }, use = -
{ verdict = ’block’} },
{ when = { file_type_id = 0 }, use = { verdict = ’log’, enable_file_signature -
= true, enable_file_capture = true } }
}
In this example, it enables this policy:
For PDF files, they will be logged with signatures.
For the file matching this SHA, it will be blocked
For all file types identified, they will be logged with signature, and also captured onto log folder.
5.5.5 File Capture
File can be captured and stored to log folder. We use SHA as file name instead of actual file name to avoid conflicts. You can
capture either all files, some file type, or a particular file based on SHA.
You can enable file capture through this config:
enable_capture = true,
or enable it for some file or file type in your file policy:
Snort 3 User Manual 41 / 290
{ when = { file_type_id = 22 }, use = { verdict = ’log’, enable_file_capture = -
true } },
The above rule will enable PDF file capture.
5.5.6 File Events
File inspect preprocessor also works as a dynamic output plugin for file events. It logs basic information about file. The log file
is in the same folder as other log files with name starting with "file.log".
Example:
file_log = { log_pkt_time = true, log_sys_time = false }
All file events will be logged in packet time, system time is not logged.
File event example:
08/14-19:14:19.100891 10.22.75.72:33734 -> 10.22.75.36:80,
[Name: "malware.exe"] [Verdict: Block] [Type: MSEXE]
[SHA: 6F26E721FDB1AAFD29B41BCF90196DEE3A5412550615A856DAE8E3634BCE9F7A]
[Size: 1039328]
5.6 High Availability
High Availability includes the HA flow synchronization and the SideChannel messaging subsystems.
5.6.1 HA
HighAvailability (or HA) is a Snort module that provides state coherency between two partner snort instances. It uses SideChan-
nel for messaging.
There can be multiple types of HA within Snort and Snort plugins. HA implements an extensible architecture to enable plugins
to subscribe to the base flow HA messaging. These plugins can then include their own messages along with the flow cache HA
messages.
HA produces and consumes two type of messages:
Update - Update flow status. Plugins may add their own data to the messages
Delete - A flow has been removed from the cache
The HA module is configured with these items:
high_availability =
{
ports = "1",
enable = true,
min_age = 0.0,
min_sync = 0.0
}
The ports item maps to the SideChannel port to use for the HA messaging.
The enabled item controls the overall HA operation.
Snort 3 User Manual 42 / 290
The items min_age and min_sync are used in the stream HA logic. min_age is the number of seconds that a flow must exist
in the flow cache before sending HA messages to the partner. min_sync is the minimum time between HA status updates. HA
messages for a particular flow will not be sent faster than min_sync. Both are expressed as a floating point number of seconds.
HA messages are composed of the base stream information plus any content from additional modules. Modules subscribe HA
in order to add message content. The stream HA content is always present in the messages while the ancillary module content is
only present when requested via a status change request.
5.6.2 Connector
Connectors are a set of modules that are used to exchange message-oriented data among Snort threads and the external world.
A typical use-case is HA (High Availability) message exchange. Connectors serve to decouple the message transport from the
message creation/consumption. Connectors expose a common API for several forms of message transport.
Connectors are a Snort plugin type.
Connector (parent plugin class)
Connectors may either be a simplex channel and perform unidirectional communications. Or may be duplex and perform bidi-
rectional communications. The TcpConnector is duplex while the FileConnector is simplex.
All subtypes of Connector have a direction configuration element and a connector element. The connector string is the key used to
identify the element for sidechannel configuration. The direction element may have a default value, for instance TcpConnector’s
are duplex.
There are currently two implementations of Connectors:
TcpConnector - Exchange messages over a tcp channel.
FileConnector - Write messages to files and read messages from files.
TcpConnector
TcpConnector is a subclass of Connector and implements a DUPLEX type Connector, able to send and receive messages over a
tcp session.
TcpConnector adds a few session setup configuration elements:
setup = call or answer -call is used to have TcpConnector initiate the connection. answer is used to have TcpConnector accept
incoming connections.
address = <addr> - used for call setup to specify the partner
base_port = port - used to contruct the actual port number for call and answer modes. Actual port used is (base_port +
instance_id).
An example segment of TcpConnector configuration:
tcp_connector =
{
{
connector = ’tcp_1’,
address = ’127.0.0.1’,
setup = ’call’,
base_port = 11000
},
}
Snort 3 User Manual 43 / 290
FileConnector
FileConnector implements a Connector that can either read from files or write to files. FileConnector’s are simplex and must be
configured to be CONN_TRANSMIT or CONN_RECEIVE.
FileConnector configuration adds two additional element:
name = string - used as part of the message file name
format = text or binary - FileConnector supports two file types
The configured name string is used to construct the actual names as in:
file_connector_NAME_transmit and file_connector_NAME_receive
All messages for one Snort invocation are read and written to one file.
In the case of a receive FileConnector, all messages are read from the file prior to the start of packet processing. This allows the
messages to establish state information for all processed packets.
Connectors are used solely by SideChannel
An example segment of FileConnector configuration:
file_connector =
{
{
connector = ’file_tx_1’,
direction = ’transmit’,
format = ’text’,
name = ’HA’
},
{
connector = ’file_rx_1’,
direction = ’receive’,
format = ’text’,
name = ’HA’
},
}
5.6.3 Side Channel
SideChannel is a Snort module that uses Connectors to implement a messaging infrastructure that is used to communicate between
Snort threads and the outside world.
SideChannel adds functionality onto the Connector as:
message multiplexing/demultiplexing - An additional protocol layer is added to the messages. This port number is used to
direct message to/from various SideClass instancs.
application receive processing - handler for received messages on a specific port.
SideChannel’s are always implement a duplex (bidirectional) messaging model and can map to separate transmit and receive
Connectors.
The message handling model leverages the underlying Connector handling. So please refer to the Connector documentation.
SideChannel’s are instantiated by various applications. The SideChannel port numbers are the configuration element used to map
SideChannel’s to applications.
Snort 3 User Manual 44 / 290
The SideChannel configuration mostly serves to map a port number to a Connector or set of connectors. Each port mapping can
have at most one transmit plus one receive connector or one duplex connector. Multiple SideChannel’s may be configured and
instantiated to support multiple applications.
An example SideChannel configuration along with the corresponding Connector configuration:
side_channel =
{
{
ports = ’1’,
connectors =
{
{
connector = ’file_rx_1’,
},
{
connector = ’file_tx_1’,
}
},
},
}
file_connector =
{
{
connector = ’file_tx_1’,
direction = ’transmit’,
format = ’text’,
name = ’HA’
},
{
connector = ’file_rx_1’,
direction = ’receive’,
format = ’text’,
name = ’HA’
},
}
5.7 FTP
Given an FTP command channel buffer, FTP will interpret the data, identifying FTP commands and parameters, as well as FTP
response codes and messages. It will enforce correctness of the parameters, determine when an FTP command connection is
encrypted, and determine when an FTP data channel is opened.
5.7.1 Configuring the inspector to block exploits and attacks
ftp_server configuration
• ftp_cmds
This specifies additional FTP commands outside of those checked by default within the inspector. The inspector may be config-
ured to generate an alert when it sees a command it does not recognize.
Aside from the default commands recognized, it may be necessary to allow the use of the "X" commands, specified in RFC 775.
To do so, use the following ftp_cmds option. Since these are rarely used by FTP client implementations, they are not included in
the defaults.
Snort 3 User Manual 45 / 290
ftp_cmds = [[ XPWD XCWD XCUP XMKD XRMD ]]
• def_max_param_len
This specifies the default maximum parameter length for all commands in bytes. If the parameter for an FTP command exceeds
that length, and the inspector is configured to do so, an alert will be generated. This is used to check for buffer overflow exploits
within FTP servers.
• cmd_validity
This specifies the valid format and length for parameters of a given command.
• cmd_validity[].len
This specifies the maximum parameter length for the specified command in bytes, overriding the default. If the parameter for that
FTP command exceeds that length, and the inspector is configured to do so, an alert will be generated. It can be used to restrict
specific commands to small parameter values. For example the USER command usernames may be no longer than 16 bytes,
so the appropriate configuration would be:
cmd_validity =
{
{
command = ’USER’,
length = 16,
}
}
• cmd_validity[].format
format is as follows:
int Param must be an integer
number Param must be an integer between 1 and 255
char <chars> Param must be a single char, and one of <chars>
date <datefmt> Param follows format specified where
# = Number, C=Char, []=optional, |=OR, {}=choice,
anything else=literal (i.e., .+- )
string Param is string (effectively unrestricted)
host_port Param must a host port specifier, per RFC 959.
long_host_port Parameter must be a long host port specified, per RFC 1639
extended_host_port Parameter must be an extended host port specified, per RFC -
2428
Examples of the cmd_validity option are shown below. These examples are the default checks (per RFC 959 and others) per-
formed by the inspector.
cmd_validity =
{
{
command = ’CWD’,
length = 200,
},
{
command = ’MODE’,
Snort 3 User Manual 46 / 290
format = ’< char SBC >’,
},
{
command = ’STRU’,
format = ’< char FRP >’,
},
{
command = ’ALLO’,
format = ’< int [ char R int ] >’,
},
{
command = ’TYPE’,
format = [[ < { char AE [ char NTC ] | char I | char L [ number ]
} > ]],
},
{
command = ’PORT’,
format = ’< host_port >’,
},
}
A cmd_validity entry in the configuration can be used to override these defaults and/or add a check for other commands. A few
examples follow.
This allows additional modes, including mode Z which allows for zip-style compression:
cmd_validity =
{
{
command = ’MODE’,
format = ’< char ASBCZ >’,
},
}
Allow for a date in the MDTM command:
cmd_validity =
{
{
command = ’MDTM’,
format = ’< [ date nnnnnnnnnnnnnn[.n[n[n]]] ] string >’,
},
}
MDTM is an odd case that is worth discussing. . .
While not part of an established standard, certain FTP servers accept MDTM commands that set the modification time on
a file. The most common among servers that do, accept a format using YYYYMMDDHHmmss[.uuu]. Some others accept
a format using YYYYMMDDHHmmss[+|-]TZ format. The example above is for the first case (time format as specified in
https://tools.ietf.org/html/draft-ietf-ftpext-mlst-16)
To check validity for a server that uses the TZ format, use the following:
cmd_validity =
{
{
command = ’MDTM’,
format = ’< [ date nnnnnnnnnnnnnn[{+|-}n[n]] ] string >’,
},
}
Snort 3 User Manual 47 / 290
• chk_str_fmt
This causes the inspector to check for string format attacks on the specified commands.
• telnet_cmds
Detect and alert when telnet cmds are seen on the FTP command channel.
• ignore_telnet_erase_cmds
This option allows Snort to ignore telnet escape sequences for erase character (TNC EAC) and erase line (TNC EAL) when
normalizing FTP command channel. Some FTP servers do not process those telnet escape sequences.
• ignore_data_chan
When set to true, causes the FTP inspector to force the rest of snort to ignore the FTP data channel connections. NO INSPEC-
TION other than state (inspector AND rules) will be performed on that data channel. It can be turned on to improve performance
especially with respect to large file transfers from a trusted source by ignoring traffic. If your rule set includes virus-type
rules, it is recommended that this option not be used.
ftp_client configuration
• max_resp_len
This specifies the maximum length for all response messages in bytes. If the message for an FTP response (everything after the
3 digit code) exceeds that length, and the inspector is configured to do so, an alert will be generated. This is used to check for
buffer overflow exploits within FTP clients.
• telnet_cmds
Detect and alert when telnet cmds are seen on the FTP command channel.
• ignore_telnet_erase_cmds
This option allows Snort to ignore telnet escape sequences for erase character (TNC EAC) and erase line (TNC EAL) when
normalizing FTP command channel. Some FTP clients do not process those telnet escape sequences.
ftp_data
In order to enable file inspection for ftp, the following should be added to the configuration:
ftp_data = {}
5.8 HTTP Inspector
One of the major undertakings for Snort 3 is developing a completely new HTTP inspector.
Snort 3 User Manual 48 / 290
5.8.1 Overview
You can configure it by adding:
http_inspect = {}
to your snort.lua configuration file. Or you can read about it in the source code under src/service_inspectors/http_inspect.
So why a new HTTP inspector?
For starters it is object-oriented. That’s good for us because we maintain this software. But it should also be really nice for
open-source developers. You can make meaningful changes and additions to HTTP processing without having to understand the
whole thing. In fact much of the new HTTP inspector’s knowledge of HTTP is centralized in a series of tables where it can be
easily reviewed and modified. Many significant changes can be made just by updating these tables.
http_inspect is the first inspector written specifically for the new Snort 3 architecture. This provides access to one of the very best
features of Snort 3: purely PDU-based inspection. The classic preprocessor processes HTTP messages, but even while doing so
it is constantly aware of IP packets and how they divide up the TCP data stream. The same HTTP message might be processed
differently depending on how the sender (bad guy) divided it up into IP packets.
http_inspect is free of this burden and can focus exclusively on HTTP. This makes it much simpler, easier to test, and less prone
to false positives. It also greatly reduces the opportunity for adversaries to probe the inspector for weak spots by adjusting packet
boundaries to disguise bad behavior.
Dealing solely with HTTP messages also opens the door for developing major new features. The http_inspect design supports
true stateful processing. Want to ask questions that involve both the client request and the server response? Or different requests
in the same session? These things are possible.
Another new feature on the horizon is HTTP/2 analysis. HTTP/2 derives from Google’s SPDY project and is in the process of
being standardized. Despite the name, it is better to think of HTTP/2 not as a newer version of HTTP/1.1, but rather a separate
protocol layer that runs under HTTP/1.1 and on top of TLS or TCP. It’s a perfect fit for the new Snort 3 architecture because a
new HTTP/2 inspector would naturally output HTTP/1.1 messages but not any underlying packets. Exactly what http_inspect
wants to input.
http_inspect is taking a very different approach to HTTP header fields. The classic preprocessor divides all the HTTP headers
following the start line into cookies and everything else. It normalizes the two pieces using a generic process and puts them in
buffers that one can write rules against. There is some limited support for examining individual headers within the inspector but
it is very specific.
The new concept is that every header should be normalized in an appropriate and specific way and individually made available
for the user to write rules against it. If for example a header is supposed to be a date then normalization means put that date in a
standard format.
5.8.2 Configuration
Configuration can be as simple as adding:
http_inspect = {}
to your snort.lua file. The default configuration provides a thorough inspection and may be all that you need. But there are some
options that provide extra features, tweak how things are done, or conserve resources by doing less.
request_depth and response_depth
These replace the flow depth parameters used by the old HTTP inspector but they work differently.
The default is to inspect the entire HTTP message body. That’s a very sound approach but if your HTTP traffic includes many very
large files such as videos the load on Snort can become burdensome. Setting the request_depth and response_depth parameters
will limit the amount of body data that is sent to the rule engine. For example:
request_depth = 10000,
response_depth = 80000,
Snort 3 User Manual 49 / 290
would examine only the first 10000 bytes of POST, PUT, and other message bodies sent by the client. Responses from the server
would be limited to 80000 bytes.
These limits apply only to the message bodies. HTTP headers are always completely inspected.
If you want to only inspect headers and no body, set the depth to 0. If you want to inspect the entire body set the depth to -1 or
simply omit the depth parameter entirely because that is the default.
These limits have no effect on how much data is forwarded to file processing.
gzip
http_inspect by default decompresses deflate and gzip message bodies before inspecting them. This feature can be turned off by
unzip = false. Turning off decompression provides a substantial performance improvement but at a very high price. It is unlikely
that any meaningful inspection of message bodies will be possible. Effectively HTTP processing would be limited to the headers.
normalize_utf
http_inspect will decode utf-8, utf-7, utf-16le, utf-16be, utf-32le, and utf-32be in response message bodies based on the Content-
Type header. This feature is on by default: normalize_utf = false will deactivate it.
decompress_pdf
decompress_pdf = true will enable decompression of compressed portions of PDF files encountered in a response body. http_inspect
will examine the response body for PDF files that are then parsed to locate PDF streams with a single /FlateDecode filter. The
compressed content is decompressed and made available through the file data rule option.
decompress_swf
decompress_swf = true will enable decompression of compressed SWF (Adobe Flash content) files encountered in a response
body. The available decompression modes are ’deflate’ and ’lzma’. http_inspect will search for the file signatures CWS for
Deflate/ZLIB and ZWS for LZMA. The compressed content is decompressed and made available through the file data rule
option. The compressed SWF file signature is converted to FWS to indicate an uncompressed file.
normalize_javascript
normalize_javascript = true will enable normalization of JavaScript within the HTTP response body. http_inspect looks for
JavaScript by searching for the <script> tag without a type. Obfuscated data within the JavaScript functions such as unescape,
String.fromCharCode, decodeURI, and decodeURIComponent are normalized. The different encodings handled within the un-
escape, decodeURI, or decodeURIComponent are %XX, %uXXXX, XX and uXXXXi. http_inspect also replaces consecutive
whitespaces with a single space and normalizes the plus by concatenating the strings.
URI processing
Normalization and inspection of the URI in the HTTP request message is a key aspect of what http_inspect does. The best way
to normalize a URI is very dependent on the idiosyncrasies of the HTTP server being accessed. The goal is to interpret the URI
the same way as the server will so that nothing the server will see can be hidden from the rule engine.
The default URI inspection parameters are oriented toward following the HTTP RFCs—reading the URI the way the standards
say it should be read. Most servers deviate from this ideal in various ways that can be exploited by an attacker. The options
provide tools for the user to cope with that.
utf8 = true
plus_to_space = true
percent_u = false
utf8_bare_byte = false
iis_unicode = false
iis_double_decode = false
Snort 3 User Manual 50 / 290
The HTTP inspector normalizes percent encodings found in URIs. For instance it will convert "%48%69%64%64%65%6e" to
"Hidden". All the options listed above control how this is done. The options listed as true are fairly standard features that are
decoded by default. You don’t need to list them in snort.lua unless you want to turn them off by setting them to false. But that is
not recommended unless you know what you are doing and have a definite reason.
The other options are primarily for the protection of servers that support irregular forms of decoding. These features are off by
default but you can activate them if you need to by setting them to true in snort.lua.
bad_characters = "0x25 0x7e 0x6b 0x80 0x81 0x82 0x83 0x84"
That’s a list of 8-bit Ascii characters that you don’t want present in any normalized URI after the percent decoding is done. For
example 0x25 is a hexadecimal number (37 in decimal) which stands for the %character. The % character is legitimately used
for encoding special characters in a URI. But if there is still a percent after normalization one might conclude that something is
wrong. If you choose to configure 0x25 as a bad character there will be an alert whenever this happens.
Another example is 0x00 which signifies the null character zero. Null characters in a URI are generally wrong and very suspi-
cious.
The default is not to alert on any of the 256 8-bit Ascii characters. Add this option to your configuration if you want to define
some bad characters.
ignore_unreserved = "abc123"
Percent encoding common characters such as letters and numbers that have no special meaning in HTTP is suspicious. It’s legal
but why would you do it unless you have something to hide? http_inspect will alert whenever an upper-case or lower-case letter,
a digit, period, underscore, tilde, or minus is percent-encoded. But if a legitimate application in your environment encodes some
of these characters for some reason this allows you to create exemptions for those characters.
In the example, the lower-case letters a, b, and c and the digits 1, 2, and 3 are exempted. These may be percent-encoded without
generating an alert.
simplify_path = true
backslash_to_slash = false
HTTP inspector simplifies directory paths in URIs by eliminating extra traversals using ., .., and /.
For example I can take a simple URI such as
/very/easy/example
and complicate it like this:
/very/../very/././././easy//////detour/to/nowhere/../.././../example
which may be very difficult to match with a detection rule. simplify_path is on by default and you should not turn it off unless
you have no interest in URI paths.
backslash_to_slash is a tweak to path simplification for servers that allow directories to be separated by backslashes:
/this/is/the/normal/way/to/write/a/path
\this\is\the\other\way\to\write\a\path
backslash_to_slash is turned off by default. If you are protecting such a server then set backslash_to_slash = true and all the
backslashes will be replaced with slashes during normalization.
Snort 3 User Manual 51 / 290
5.8.3 Detection rules
http_inspect parses HTTP messages into their components and makes them available to the detection engine through rule options.
Let’s start with an example:
alert tcp any any -> any any ( msg:"URI example"; flow:established,
to_server; http_uri; content:"chocolate"; sid:1; rev:1; )
This rule looks for chocolate in the URI portion of the request message. Specifically, the http_uri rule option is the normalized
URI with all the percent encodings removed. It will find chocolate in both:
GET /chocolate/cake HTTP/1.1
and
GET /%63%68$6F%63%6F%6C%61%74%65/%63%61%6B%65 HTTP/1.1
It is also possible to search the unnormalized URI
alert tcp any any -> any any ( msg:"Raw URI example"; flow:established,
to_server; http_raw_uri; content:"chocolate"; sid:2; rev:1; )
will match the first message but not the second. If you want to detect someone who is trying to hide his request for chocolate
then
alert tcp any any -> any any ( msg:"Raw URI example"; flow:established,
to_server; http_raw_uri; content:"%63%68$6F%63%6F%6C%61%74%65";
sid:3; rev:1; )
will do the trick.
Let’s look at possible ways of writing a rule to match HTTP response messages with the Content-Language header set to "da"
(Danish). You could write:
alert tcp any any -> any any ( msg:"whole header search";
flow:established, to_client; http_header; content:
"Content-Language: da", nocase; sid:4; rev:1; )
This rule leaves much to be desired. Modern headers are often thousands of bytes and seem to get longer every year. Searching
all of the headers consumes a lot of resources. Furthermore this rule is easily evaded:
HTTP/1.1 ... Content-Language: da ...
the extra space before the "da" throws the rule off. Or how about:
HTTP/1.1 ... Content-Language: xx,da ...
By adding a made up second language the attacker has once again thwarted the match.
A better way to write this rule is:
alert tcp any any -> any any ( msg:"individual header search";
flow:established, to_client; http_header: field content-language;
content:"da", nocase; sid:4; rev:2; )
The field option improves performance by narrowing the search to the Content-Language field of the header. Because it uses the
header parsing abilities of http_inspect to find the field of interest it will not be thrown off by extra spaces or other languages in
the list.
In addition to the headers there are rule options for virtually every part of the HTTP message.
Snort 3 User Manual 52 / 290
http_uri and http_raw_uri
These provide the URI of the request message. The raw form is exactly as it appeared in the message and the normalized form is
determined by the URI normalization options you selected. In addition to searching the entire URI there are six components that
can be searched individually:
alert tcp any any -> any any ( msg:"URI path"; flow:established,
to_server; http_uri: path; content:"chocolate"; sid:1; rev:2; )
By specifying "path" the search is limited to the path portion of the URI. Informally this is the part consisting of the directory
path and file name. Thus it will match:
GET /chocolate/cake HTTP/1.1
but not:
GET /book/recipes?chocolate+cake HTTP/1.1
The question mark ends the path and begins the query portion of the URI. Informally the query is where parameter values are set
and often contains a search to be performed.
The six components are:
1. path: directory and file
2. query: user parameters
3. fragment: part of the file requested, normally found only inside a browser and not transmitted over the network
4. host: domain name of the server being addressed
5. port: TCP port number being addressed
6. scheme: normally "http" or "https" but others are possible such as "ftp"
Here is an example with all six:
GET https://www.samplehost.com:287/basic/example/of/path?with-query
#and-fragment HTTP/1.1\r\n
The URI is everything between the first space and the last space. "https" is the scheme, "www.samplehost.com" is the host, "287"
is the port, "/basic/example/of/path" is the path, "with-query" is the query, and "and-fragment" is the fragment.
Note: this section uses informal language to explain some things. Nothing here is intended to conflict with the technical language
of the HTTP RFCs and the implementation follows the RFCs.
http_header and http_raw_header
These cover all the header lines except the first one. You may specify an individual header by name using the field option as
shown in this earlier example:
alert tcp any any -> any any ( msg:"individual header search";
flow:established, to_client; http_header: field content-language;
content:"da", nocase; sid:4; rev:2; )
This rule searches the value of the Content-Language header. Header names are not case sensitive and may be written in the rule
in any mixture of upper and lower case.
With http_header the individual header value is normalized in a way that is appropriate for that header.
Specifying an individual header is not available for http_raw_header.
Snort 3 User Manual 53 / 290
If you don’t specify a header you get all of the headers except for the cookie headers Cookie and Set-Cookie. http_raw_header
includes the unmodified header names and values as they appeared in the original message. http_header is the same except
percent encodings are removed and paths are simplified exactly as if the headers were a URI.
In most cases specifying individual headers creates a more efficient and accurate rule. It is recommended that new rules be
written using individual headers whenever possible.
http_trailer and http_raw_trailer
HTTP permits header lines to appear after a chunked body ends. Typically they contain information about the message content
that was not available when the headers were created. For convenience we call them trailers.
http_trailer and http_raw_trailer are identical to their header counterparts except they apply to these end headers. If you want a
rule to inspect both kinds of headers you need to write two rules, one using header and one using trailer.
http_cookie and http_raw_cookie
These provide the value of the Cookie header for a request message and the Set-Cookie for a response message. If multiple
cookies are present they will be concatenated into a comma-separated list.
Normalization for http_cookie is the same URI-style normalization applied to http_header when no specific header is specified.
http_true_ip
This provides the original IP address of the client sending the request as it was stored by a proxy in the request message headers.
Specifically it is the last IP address listed in the X-Forwarded-For or True-Client-IP header. If both headers are present the former
is used.
http_client_body
This is the body of a request message such as POST or PUT. Normalization for http_client_body is the same URI-like normal-
ization applied to http_header when no specific header is specified.
http_raw_body
This is the body of a request or response message. It will be dechunked and unzipped if applicable but will not be normalized in
any other way. The difference between http_raw_body and packet data is a rule that uses packet data will search and may match
an HTTP header, but http_raw_body is limited to the message body. Thus the latter is more efficient and more accurate for most
uses.
http_method
The method field of a request message. Common values are "GET", "POST", "OPTIONS", "HEAD", "DELETE", "PUT",
"TRACE", and "CONNECT".
http_stat_code
The status code field of a response message. This is normally a 3-digit number between 100 and 599. In this example it is 200.
HTTP/1.1 200 OK
http_stat_msg
The reason phrase field of a response message. This is the human-readable text following the status code. "OK" in the previous
example.
Snort 3 User Manual 54 / 290
http_version
The protocol version information that appears on the first line of an HTTP message. This is usually "HTTP/1.0" or "HTTP/1.1".
http_raw_request and http_raw_status
These are the unmodified first header line of the HTTP request and response messages respectively. These rule options are a
safety valve in case you need to do something you cannot otherwise do. In most cases it is better to use a rule option for a
specific part of the first header line. For a request message those are http_method, http_raw_uri, and http_version. For a response
message those are http_version, http_stat_code, and http_stat_msg.
file_data and packet data
file_data contains the normalized message body. This is the normalization described above under gzip, normalize_utf, decom-
press_pdf, decompress_swf, and normalize_javascript.
The unnormalized message content is available in the packet data. If gzip is configured the packet data will be unzipped.
5.8.4 Timing issues and combining rule options
HTTP inspector is stateful. That means it is aware of a bigger picture than the packet in front of it. It knows what all the pieces of
a message are, the dividing lines between one message and the next, which request message triggered which response message,
pipelines, and how many messages have been sent over the current connection.
Some rules use a single rule option:
alert tcp any any -> any any ( msg:"URI example"; flow:established,
to_server; http_uri; content:"chocolate"; sid:1; rev:1; )
Whenever a new URI is available this rule will be evaluated. Nothing complicated about that, but suppose we use more than one
rule option:
alert tcp any any -> any any ( msg:"combined example"; flow:established,
to_server; http_uri; content:"chocolate"; file_data;
content:"sinister POST data"; sid:5; rev:1; )
This rule requires both the URI and the request message body. That sounds simple until one considers that the message body
may be millions of bytes long. The headers with the URI may be long gone by that time.
Is this rule going to work or do we need to do something different?
It is helpful to understand when things happen. All the message headers and the first few thousand bytes of the body go through
detection at the same time. Commonly this is about 16K bytes but there are several exceptions and there is no guaranteed
minimum amount.
That may be all you need. In many cases that will be the entire message. Or it may be more than your request_depth/response_depth.
Or this rule may simply not care what happens after that in a very long message body.
Beyond that the message body will continue to be subdivided into roughly 16K-byte sections and inspected. But the previous
rule will not be able to see the URI and hence will not work unless we rewrite it:
alert tcp any any -> any any ( msg:"URI with_body"; flow:established,
to_server; http_uri: with_body; content:"chocolate"; file_data;
content:"sinister POST data"; sid:5; rev:2; )
The with_body option to http_uri causes the URI to be made available with every body section, not just the first one. These extra
inspections have a performance cost which is why they are not done automatically. with_body is an option to be used when you
actually need it.
The with_trailer option is analogous and causes an earlier message element to be made available at the end of the message when
the trailers following a chunked body arrive.
Snort 3 User Manual 55 / 290
alert tcp any any -> any any ( msg:"double content-language";
flow:established, to_client; http_header: with_trailer, field
content-language; content:"da", nocase; http_trailer: field
content-language; content:"en", nocase; sid:6; rev:1; )
This rule will alert if the Content-Language changes from Danish in the headers to English in the trailers. The with_trailer option
is essential to make this rule work.
It is also possible to write rules that examine both the client request and the server response to it.
alert tcp any any -> any any ( msg:"request and response example";
flow:established, to_client; http_uri: with_body; content:"chocolate";
file_data; content:"white chocolate"; sid:7; rev:1; )
This rule looks for white chocolate in a response message body where the URI of the request contained chocolate. Note that this
is a "to_client" rule that will alert on and potentially block a server response containing white chocolate, but only if the client
URI requested chocolate. If the rule were rewritten "to_server" it would be nonsense and not work. Snort cannot block a client
request based on what the server response will be because that has not happened yet.
Another point is "with_body" for http_uri. This ensures the rule works on the entire response body. If we were looking for white
chocolate in the response headers this would not be necessary.
Response messages do not have a URI so there was only one thing http_uri could have meant in the previous rule. It had to be
referring to the request message. Sometimes that is not so clear.
alert tcp any any -> any any ( msg:"header ambiguity example 1";
flow:established, to_client; http_header: with_body; content:
"chocolate"; file_data; content:"white chocolate"; sid:8; rev:1; )
alert tcp any any -> any any ( msg:"header ambiguity example 2";
flow:established, to_client; http_header: with_body, request; content:
"chocolate"; file_data; content:"white chocolate"; sid:8; rev:2; )
Our search for chocolate has moved from the URI to the message headers. Both the request and response messages have
headers—which one are we asking about? Ambiguity is always resolved in favor of looking in the current message which is the
response. The first rule is looking for a server response containing chocolate in the headers and white chocolate in the body.
The second rule uses the "request" option to explicitly say that the http_header to be searched is the request header.
Let’s put all of this together. There are six opportunities to do detection:
1. When the first part of the request message body arrives. The request line, all of the headers, and the first part of the body
all go through detection at the same time. Of course most requests don’t have a body. In that case the request line and the
headers are the whole message and get done at the same time.
2. When subsequent sections of the request message body arrive. If you want to combine this with something from the request
line or headers you must use the with_body option.
3. When the request trailers arrive. If you want to combine this with something from the request line or headers you must use
the with_trailer option.
4. When the first part of the response message body arrives. The status line, all of the headers, and the first part of the body
all go through detection at the same time. These may be combined with elements from the request line, request headers,
or request trailers. Where ambiguity arises use the request option.
5. When subsequent sections of the response message body arrive. These may be combined with the status line, response
headers, request line, request headers, or request trailers as described above.
6. When the response trailers arrive. Again these may be combined as described above.
Message body data can only go through detection at the time it is received. Headers may be combined with later items but the
body cannot.
Snort 3 User Manual 56 / 290
5.9 HTTP/2 Inspector
Snort 3 is developing an inspector for HTTP/2.
You can configure it by adding:
http2_inspect = {}
to your snort.lua configuration file.
Everything has a beginning and for http2_inspect this is the beginning of the beginning. Most of the protocol including HPACK
decompression is not implemented yet.
Currently http2_inspect will divide an HTTP/2 connection into individual frames and make them available for detection. Two
new rule options are available for looking at HTTP/2 frames: http2_frame_header provides the 9-octet frame header and
http2_frame_data provides the frame content.
alert tcp any any -> any any (msg:"Frame type"; flow:established,
to_client; http2_frame_header; content:"|06|", offset 3, depth 1;
sid:1; rev:1; )
This will match if the Type byte of the frame header is 6 (PING).
alert tcp any any -> any any ( msg:"Content of HTTP/2 frame";
flow:established, to_client; http2_frame_data; content:"peppermint";
sid:2; rev:1; )
This will look for peppermint in the frame data but not the frame header.
These can be combined:
alert tcp any any -> any any ( msg:"Search in message bodies";
flow:established, to_client;
http2_frame_header; content:"|00|", offset 3, depth 1;
http2_frame_data; content:"MaLwArE"; sid:3; rev:1; )
Frame type 0 is DATA which carries the HTTP message body. This rule will search for MaLwArE inside an HTTP message
body.
In the future, http2_inspect will support HPACK header decompression and be fully integrated with http_inspect to provide full
inspection of the individual HTTP/1.1 streams.
5.10 Performance Monitor
The new and improved performance monitor! Is your sensor being bogged down by too many flows? perf_monitor! Why are
certain TCP segments being dropped without hitting a rule? perf_monitor! Why is a sensor leaking water? Not perf_monitor,
check with stream. . .
5.10.1 Overview
The Snort performance monitor is the built-in utility for monitoring system and traffic statistics. All statistics are separated by
processing thread. perf_monitor supports several trackers for monitoring such data:
Snort 3 User Manual 57 / 290
5.10.2 Base Tracker
The base tracker is used to gather running statistics about Snort and its running modules. All Snort modules gather, at the very
least, counters for the number of packets reaching it. Most supplement these counts with those for domain specific functions,
such as http_inspect’s number of GET requests seen.
Statistics are gathered live and can be reported at regular intervals. The stats reported correspond only to the interval in question
and are reset at the beginning of each interval.
These are the same counts displayed when Snort shuts down, only sorted amongst the discrete intervals in which they occurred.
Base differs from prior implementations in Snort in that all stats gathered are only raw counts, allowing the data to be evaluated
as needed. Additionally, base is entirely pluggable. Data from new Snort plugins can be added to the existing stats either
automatically or, if specified, by name and function.
All plugins and counters can be enabled or disabled individually, allowing for only the data that is actually desired instead of
overly verbose performance logs.
To enable everything:
perf_monitor = { modules = {} }
To enable everything within a module:
perf_monitor =
{
modules =
{
{
name = ’stream_tcp’,
pegs = [[ ]]
},
}
}
To enable specific counts within modules:
perf_monitor =
{
modules =
{
{
name = ’stream_tcp’,
pegs = [[ overlaps gaps ]]
},
}
Note: Event stats from prior Snorts are now located within base statistics.
5.10.3 Flow Tracker
Flow tracks statistics regarding traffic and L3/L4 protocol distributions. This data can be used to build a profile of traffic for
inspector tuning and for identifying where Snort may be stressed.
To enable:
perf_monitor = { flow = true }
Snort 3 User Manual 58 / 290
5.10.4 FlowIP Tracker
FlowIP provides statistics for individual hosts within a network. This data can be used for identifying communication habits,
such as generating large or small amounts of data, opening a small or large number of sessions, and tendency to send smaller or
larger IP packets.
To enable:
perf_monitor = { flow_ip = true }
5.10.5 CPU Tracker
This tracker monitors the CPU and wall time spent by a given processing thread.
To enable:
perf_monitor = { cpu = true }
5.10.6 Formatters
Performance monitor allows statistics to be output in a few formats. Along with human readable text (as seen at shutdown) and
csv formats, a Flatbuffers binary format is also available if Flatbuffers is present at build. A utility for accessing the statistics
generated in this format has been included for convenience (see fbstreamer in tools). This tool generates a YAML array of records
found, allowing the data to be read by humans or passed into other analysis tools. For information on working directly with the
Flatbuffers file format used by Performance monitor, see the developer notes for Performance monitor or the code provided for
fbstreamer.
5.11 POP and IMAP
POP inspector is a service inspector for POP3 protocol and IMAP inspector is for IMAP4 protocol.
5.11.1 Overview
POP and IMAP inspectors examine data traffic and find POP and IMAP commands and responses. The inspectors also identify
the command, header, body sections and extract the MIME attachments and decode it appropriately. The pop and imap also
identify and whitelist the pop and imap traffic.
5.11.2 Configuration
POP inspector and IMAP inspector offer same set of configuration options for MIME decoding depth:
b64_decode_depth
This config option is used to turn off/on or set the base64 decoding depth used to decode the base64 encoded MIME attachments.
The value ranges from -1 to 65535. A value of -1 turns off the base64 decoding of MIME attachments. The value of 0 sets the
decoding of base64 encoded MIME attachments to unlimited. A value other than 0 or -1 restricts the decoding of base64 MIME
attachments, and applies per attachment. The default value is 1460.
qp_decode_depth
This config option is used to turn off/on or set the Quoted-Printable decoding depth used to decode the Quoted-Printable(QP)
encoded MIME attachments. The value ranges from -1 to 65535. A value of -1 turns off the QP decoding of MIME attachments.
The value of 0 sets the decoding of QP encoded MIME attachments to unlimited. A value other than 0 or -1 restricts the decoding
of QP MIME attachments, and applies per attachment.
Snort 3 User Manual 59 / 290
bitenc_decode_depth
This config option is used to turn off/on or set the non-encoded MIME extraction depth used to extract the non-encoded MIME
attachments. The value ranges from -1 to 65535. A value of -1 turns off the extraction of these MIME attachments. The value of
0 sets the extraction of these MIME attachments to unlimited. A value other than 0 or -1 restricts the extraction of these MIME
attachments, and applies per attachment.
uu_decode_depth
This config option is used to turn off/on or set the Unix-to-Unix decoding depth used to decode the Unix-to-Unix(UU) encoded
attachments. The value ranges from -1 to 65535. A value of -1 turns off the UU decoding of POP attachments. The value of 0
sets the decoding of UU encoded POP attachments to unlimited. A value other than 0 or -1 restricts the decoding of UU POP
attachments, and applies per attachment.
Examples
stream = { }
stream_tcp = { }
stream_ip = { }
binder =
{
{
{
when = { proto = ’tcp’, ports = ’110’, },
use = { type = ’pop’, },
},
{
when = { proto = ’tcp’, ports = ’143’, },
use = { type = ’imap’, },
},
},
}
imap =
{
qp_decode_depth = 15,
}
pop =
{
qp_decode_depth = 0,
b64_decode_depth = 10,
}
5.12 Port Scan
A module to detect port scanning
Snort 3 User Manual 60 / 290
5.12.1 Overview
This module is designed to detect the first phase in a network attack: Reconnaissance. In the Reconnaissance phase, an attacker
determines what types of network protocols or services a host supports. This is the traditional place where a portscan takes place.
This phase assumes the attacking host has no prior knowledge of what protocols or services are supported by the target, otherwise
this phase would not be necessary.
As the attacker has no beforehand knowledge of its intended target, most queries sent by the attacker will be negative (meaning
that the services are closed). In the nature of legitimate network communications, negative responses from hosts are rare, and
rarer still are multiple negative responses within a given amount of time. Our primary objective in detecting portscans is to detect
and track these negative responses.
One of the most common portscanning tools in use today is Nmap. Nmap encompasses many, if not all, of the current portscan-
ning techniques. Portscan was designed to be able to detect the different types of scans Nmap can produce.
The following are a list of the types of Nmap scans Portscan will currently alert for.
TCP Portscan
UDP Portscan
IP Portscan
These alerts are for one to one portscans, which are the traditional types of scans; one host scans multiple ports on another host.
Most of the port queries will be negative, since most hosts have relatively few services available.
TCP Decoy Portscan
UDP Decoy Portscan
IP Decoy Portscan
Decoy portscans are much like regular, only the attacker has spoofed source address inter-mixed with the real scanning address.
This tactic helps hide the true identity of the attacker.
TCP Distributed Portscan
UDP Distributed Portscan
IP Distributed Portscan
These are many to one portscans. Distributed portscans occur when multiple hosts query one host for open services. This is used
to evade an IDS and obfuscate command and control hosts.
Note
Negative queries will be distributed among scanning hosts, so we track this type of scan through the scanned host.
TCP Portsweep
UDP Portsweep
IP Portsweep
ICMP Portsweep
These alerts are for one to many portsweeps. One host scans a single port on multiple hosts. This usually occurs when a new
exploit comes out and the attacker is looking for a specific service.
Snort 3 User Manual 61 / 290
Note
The characteristics of a portsweep scan may not result in many negative responses. For example, if an attacker portsweeps a
web farm for port 80, we will most likely not see many negative responses.
TCP Filtered Portscan
UDP Filtered Portscan
IP Filtered Portscan
TCP Filtered Decoy Portscan
UDP Filtered Decoy Portscan
IP Filtered Decoy Portscan
TCP Filtered Portsweep
UDP Filtered Portsweep
IP Filtered Portsweep
ICMP Filtered Portsweep
TCP Filtered Distributed Portscan
UDP Filtered Distributed Portscan
IP Filtered Distributed Portscan
"Filtered" alerts indicate that there were no network errors (ICMP unreachables or TCP RSTs) or responses on closed ports have
been suppressed. It’s also a good indicator on whether the alert is just a very active legitimate host. Active hosts, such as NATs,
can trigger these alerts because they can send out many connection attempts within a very small amount of time. A filtered alert
may go off before responses from the remote hosts are received.
Portscan only generates one alert for each host pair in question during the time window. On TCP scan alerts, Portscan will also
display any open ports that were scanned. On TCP sweep alerts however, Portscan will only track open ports after the alert has
been triggered. Open port events are not individual alerts, but tags based off the original scan alert.
5.12.2 Scan levels
There are 3 default scan levels that can be set.
1) default_hi_port_scan
2) default_med_port_scan
3) default_low_port_scan
Each of these default levels have separate options that can be edited to alter the scan sensitivity levels (scans, rejects, nets or
ports)
Example:
port_scan = default_low_port_scan
port_scan.tcp_decoy.ports = 1
port_scan.tcp_decoy.scans = 1
port_scan.tcp_decoy.rejects = 1
port_scan.tcp_ports.nets = 1
Snort 3 User Manual 62 / 290
The example above would change each of the individual settings to 1.
NOTE:The default levels for scans, rejects, nets and ports can be seen in the snort_defaults.lua file.
The counts can be seen in the alert outputs (-Acmg shown below):
50 72 69 6F 72 69 74 79 20 43 6F 75 6E 74 3A 20 Priority Count:
30 0A 43 6F 6E 6E 65 63 74 69 6F 6E 20 43 6F 75 0.Connec tion Cou
6E 74 3A 20 34 35 0A 49 50 20 43 6F 75 6E 74 3A nt: 45.I P Count:
20 31 0A 53 63 61 6E 6E 65 72 20 49 50 20 52 61 1.Scann er IP Ra
6E 67 65 3A 20 31 2E 32 2E 33 2E 34 3A 31 2E 32 nge: 1.2 .3.4:1.2
2E 33 2E 34 0A 50 6F 72 74 2F 50 72 6F 74 6F 20 .3.4.Por t/Proto
43 6F 75 6E 74 3A 20 33 37 0A 50 6F 72 74 2F 50 Count: 3 7.Port/P
72 6F 74 6F 20 52 61 6E 67 65 3A 20 31 3A 39 0A roto Ran ge: 1:9.
"Low" alerts are only generated on error packets sent from the target host, and because of the nature of error responses, this
setting should see very few false positives. However, this setting will never trigger a Filtered Scan alert because of a lack of error
responses. This setting is based on a static time window of 60 seconds, after which this window is reset.
"Medium" alerts track Connection Counts, and so will generate Filtered Scan alerts. This setting may false positive on active
hosts (NATs, proxies, DNS caches, etc), so the user may need to deploy the use of Ignore directives to properly tune this directive.
"High" alerts continuously track hosts on a network using a time window to evaluate portscan statistics for that host. A "High"
setting will catch some slow scans because of the continuous monitoring, but is very sensitive to active hosts. This most definitely
will require the user to tune Portscan.
5.12.3 Tuning Portscan
The most important aspect in detecting portscans is tuning the detection engine for your network(s). Here are some tuning tips:
Use the watch_ip, ignore_scanners, and ignore_scanned options. It’s important to correctly set these options. The watch_ip
option is easy to understand. The analyst should set this option to the list of CIDR blocks and IPs that they want to watch. If no
watch_ip is defined, Portscan will watch all network traffic. The ignore_scanners and ignore_scanned options come into play in
weeding out legitimate hosts that are very active on your network. Some of the most common examples are NAT IPs, DNS cache
servers, syslog servers, and nfs servers. Portscan may not generate false positives for these types of hosts, but be aware when first
tuning Portscan for these IPs. Depending on the type of alert that the host generates, the analyst will know which to ignore it as.
If the host is generating portsweep events, then add it to the ignore_scanners option. If the host is generating portscan alerts (and
is the host that is being scanned), add it to the ignore_scanned option.
Filtered scan alerts are much more prone to false positives. When determining false positives, the alert type is very important.
Most of the false positives that Portscan may generate are of the filtered scan alert type. So be much more suspicious of filtered
portscans. Many times this just indicates that a host was very active during the time period in question. If the host continually
generates these types of alerts, add it to the ignore_scanners list or use a lower sensitivity level.
Make use of the Priority Count, Connection Count, IP Count, Port Count, IP range, and Port range to determine false positives.
The portscan alert details are vital in determining the scope of a portscan and also the confidence of the portscan. In the future,
we hope to automate much of this analysis in assigning a scope level and confidence level, but for now the user must manually do
this. The easiest way to determine false positives is through simple ratio estimations. The following is a list of ratios to estimate
and the associated values that indicate a legitimate scan and not a false positive.
Connection Count / IP Count: This ratio indicates an estimated average of connections per IP. For portscans, this ratio should be
high, the higher the better. For portsweeps, this ratio should be low.
Port Count / IP Count: This ratio indicates an estimated average of ports connected to per IP. For portscans, this ratio should
be high and indicates that the scanned host’s ports were connected to by fewer IPs. For portsweeps, this ratio should be low,
indicating that the scanning host connected to few ports but on many hosts.
Connection Count / Port Count: This ratio indicates an estimated average of connections per port. For portscans, this ratio should
be low. This indicates that each connection was to a different port. For portsweeps, this ratio should be high. This indicates that
there were many connections to the same port.
Snort 3 User Manual 63 / 290
The
reason
that
Priority
Count
is
not
included,
is
because
the
priority
count
is
included
in
the
connection
count
and
the
above
comparisons
take
that
into
consideration.
The
Priority
Count
play
an
important
role
in
tuning
because
the
higher
the
priority
count
the
more
likely
it
is
a
real
portscan
or
portsweep
(unless
the
host
is
firewalled).
If
all
else
fails,
lower
the
sensitivity
level.
If
none
of
these
other
tuning
techniques
work
or
the
analyst
doesn’t
have
the
time
for
tuning,
lower
the
sensitivity
level.
You
get
the
best
protection
the
higher
the
sensitivity
level,
but
it’s
also
important
that
the
portscan
detection
engine
generates
alerts
that
the
analyst
will
find
informative.
The
low
sensitivity
level
only
generates
alerts
based
on
error
responses.
These
responses
indicate
a
portscan
and
the
alerts
generated
by
the
low
sensitivity
level
are
highly
accurate
and
require
the
least
tuning.
The
low
sensitivity
level
does
not
catch
filtered
scans,
since
these
are
more
prone
to
false
positives.
5.13
Sensitive
Data
Filtering
The
sd_pattern
IPS
option
provides
detection
and
filtering
of
Personally
Identifiable
Information
(PII).
This
information
includes
credit
card
numbers,
U.S.
Social
Security
numbers,
and
email
addresses.
A
rich
regular
expression
syntax
is
available
for
defining
your
own
PII.
5.13.1
Hyperscan
The
sd_pattern
rule
option
is
powered
by
the
open
source
Hyperscan
library
from
Intel.
It
provides
a
regex
grammar
which
is
mostly
PCRE
compatible.
To
learn
more
about
Hyperscan
see
https://intel.github.io/hyperscan/dev-reference/
5.13.2
Syntax
Snort
provides
sd_pattern
as
IPS
rule
option
with
no
additional
inspector
overhead.
The
Rule
option
takes
the
following
syntax.
sd_pattern:
"<pattern>"[,
threshold
<count>];
Pattern
Pattern
is
the
most
important
and
is
the
only
required
parameter
to
sd_pattern.
It
supports
3
built
in
patterns
which
are
configured
by
name:
"credit_card",
"us_social"
and
"us_social_nodashes",
as
well
as
user
defined
regular
expressions
of
the
Hyperscan
dialect
(see
https://intel.github.io/hyperscan/dev-reference/compilation.html#pattern-support).
sd_pattern:"credit_card";
When
configured,
Snort
will
replace
the
pattern
credit_card
with
the
built
in
pattern.
In
addition
to
pattern
matching,
Snort
will
validate
that
the
matched
digits
will
pass
the
Luhn-check
algorithm.
Currently
the
only
pattern
that
performs
extra
verification.
sd_pattern:"us_social";
sd_pattern:"us_social_nodashes";
These
special
patterns
will
also
be
replaced
with
a
built
in
pattern.
Naturally,
"us_social"
is
a
pattern
of
9
digits
separated
by
-s
in
the
canonical
form.
sd_pattern:"\b\w+@ourdomain\.com\b"
This
is
a
user
defined
pattern
which
matches
what
is
most
likely
email
addresses
for
the
site
"ourdomain.com".
The
pattern
is
a
PCRE
compatible
regex,
\b
matches
a
word
boundary
(whitespace,
end
of
line,
non-word
characters)
and
\w+
matches
one
or
more
word
characters.
\.
matches
a
literal ..
The
above
pattern
would
match
"a@ourdomain.com",
"aa@ourdomain.com"
but
would
not
match
1@ourdomain.com
ab12@
ourdomain.com
or
@ourdomain.com.
Note:
This
is
just
an
example,
this
pattern
is
not
suitable
to
detect
many
correctly
formatted
emails.
Snort 3 User Manual 64 / 290
Threshold
Threshold is an optional parameter allowing you to change built in default value (default value is 1). The following two instances
are identical. The first will assume the default value of 1the second declaration explicitly sets the threshold to 1.
sd_pattern:"This rule requires 1 match";
sd_pattern:"This rule requires 1 match", threshold 1;
That’s pretty easy, but here is one more example anyway.
sd_pattern:"This is a string literal", threshold 300;
This example requires 300 matches of the pattern "This is a string literal" to qualify as a positive match. That is, if the string only
occurred 299 times in a packet, you will not see an event.
Obfuscating Credit Cards and Social Security Numbers
Snort provides discreet logging for the built in patterns "credit_card", "us_social" and "us_social_nodashes". Enabling output.
obfuscate_pii makes Snort obfuscate the suspect packet payload which was matched by the patterns. This configuration is
disabled by default.
output =
{
obfuscate_pii = true
}
5.13.3 Example
A complete Snort IPS rule
alert tcp ( sid:1; msg:"Credit Card"; sd_pattern:"credit_card"; )
Logged output when running Snort in "cmg" alert format.
02/25-21:19:05.125553 [**] [1:1:0] "Credit Card" [**] [Priority: 0] {TCP} -
10.1.2.3:48620 -> 10.9.8.7:8
02:01:02:03:04:05 -> 02:09:08:07:06:05 type:0x800 len:0x46
10.1.2.3:48620 -> 10.9.8.7:8 TCP TTL:64 TOS:0x0 ID:14 IpLen:20 DgmLen:56
***A**** Seq: 0xB2 Ack: 0x2 Win: 0x2000 TcpLen: 20
---raw[16]----------------------------------
58 58 58 58 58 58 58 58 58 58 58 58 39 32 39 34 XXXXXXXXXXXX9294
-----------------------------------------
5.13.4 Caveats
1. Snort currently requires setting the fast pattern engine to use "hyperscan" in order for sd_pattern ips option to function
correctly.
search_engine = { search_method = ’hyperscan’ }
2. Log obfuscation is only applicable to CMG and Unified2 logging formats.
3. Log obfuscation doesn’t support user defined PII patterns. It is currently only supported for the built in patterns for Credit
Cards and US Social Security numbers.
4. Log obfuscation doesn’t work with stream rebuilt packet payloads. (This is a known bug).
Snort 3 User Manual 65 / 290
5.14 SMTP
SMTP inspector is a service inspector for SMTP protocol.
5.14.1 Overview
The SMTP inspector examines SMTP connections looking for commands and responses. It also identifies the command, header
and body sections, TLS data and extracts the MIME attachments. This inspector also identifies and whitelists the SMTP traffic.
SMTP inspector logs the filename, email addresses, attachment names when configured.
5.14.2 Configuration
SMTP command lines can be normalized to remove extraneous spaces. TLS-encrypted traffic can be ignored, which improves
performance. In addition, plain-text mail data can be ignored for an additional performance boost.
The configuration options are described below:
normalize and normalize_cmds
Normalization checks for more than one space character after a command. Space characters are defined as space (ASCII 0x20)
or tab (ASCII 0x09). "normalize" provides options all|none|cmds, all checks all commands, none turns off normalization for all
commands. cmds just checks commands listed with the "normalize_cmds" parameter. For example:
smtp = { normalize = ’cmds’, normalize_cmds = ’RCPT VRFY EXPN’ }
ignore_data
Set it to true to ignore data section of mail (except for mail headers) when processing rules.
ignore_tls_data
Set it to true to ignore TLS-encrypted data when processing rules.
max_command_line_len
Alert if an SMTP command line is longer than this value. Absence of this option or a "0" means never alert on command line
length. RFC 2821 recommends 512 as a maximum command line length.
max_header_line_len
Alert if an SMTP DATA header line is longer than this value. Absence of this option or a "0" means never alert on data header
line length. RFC 2821 recommends 1024 as a maximum data header line length.
max_response_line_len
Alert if an SMTP response line is longer than this value. Absence of this option or a "0" means never alert on response line
length. RFC 2821 recommends 512 as a maximum response line length.
Snort 3 User Manual 66 / 290
alt_max_command_line_len
Overrides max_command_line_len for specific commands For example:
alt_max_command_line_len =
{
{
command = ’MAIL’,
length = 260,
},
{
command = ’RCPT’,
length = 300,
},
}
invalid_cmds
Alert if this command is sent from client side.
valid_cmds
List of valid commands. We do not alert on commands in this list.
DEFAULT empty list, but SMTP inspector has this list hard-coded: [[ ATRN AUTH BDAT DATA DEBUG EHLO EMAL ESAM
ESND ESOM ETRN EVFY EXPN HELO HELP IDENT MAIL NOOP ONEX QUEU QUIT RCPT RSET SAML SEND SIZE
STARTTLS SOML TICK TIME TURN TURNME VERB VRFY X-EXPS X-LINK2STATE XADR XAUTH XCIR XEXCH50
XGEN XLICENSE XQUE XSTA XTRN XUSR ]]
data_cmds
List of commands that initiate sending of data with an end of data delimiter the same as that of the DATA command per RFC
5321 - "<CRLF>.<CRLF>".
binary_data_cmds
List of commands that initiate sending of data and use a length value after the command to indicate the amount of data to be sent,
similar to that of the BDAT command per RFC 3030.
auth_cmds
List of commands that initiate an authentication exchange between client and server.
xlink2state
Enable/disable xlink2state alert, options are {disable | alert | drop}. See CVE-2005-0560 for a description of the vulnerability.
b64_decode_depth
This config option is used to turn off/on or set the base64 decoding depth used to decode the base64 encoded MIME attachments.
The value ranges from -1 to 65535. A value of -1 turns off the base64 decoding of MIME attachments. The value of 0 sets the
decoding of base64 encoded MIME attachments to unlimited. A value other than 0 or -1 restricts the decoding of base64 MIME
attachments, and applies per attachment.
Snort 3 User Manual 67 / 290
qp_decode_depth
This config option is used to turn off/on or set the Quoted-Printable decoding depth used to decode the Quoted-Printable(QP)
encoded MIME attachments. The value ranges from -1 to 65535. A value of -1 turns off the QP decoding of MIME attachments.
The value of 0 sets the decoding of QP encoded MIME attachments to unlimited. A value other than 0 or -1 restricts the decoding
of QP MIME attachments, and applies per attachment.
bitenc_decode_depth * default to 25
This config option is used to turn off/on or set the non-encoded MIME extraction depth used to extract the non-encoded MIME
attachments. The value ranges from -1 to 65535. A value of -1 turns off the extraction of these MIME attachments. The value of
0 sets the extraction of these MIME attachments to unlimited. A value other than 0 or -1 restricts the extraction of these MIME
attachments, and applies per attachment.
uu_decode_depth
This config option is used to turn off/on or set the Unix-to-Unix decoding depth used to decode the Unix-to-Unix(UU) encoded
attachments. The value ranges from -1 to 65535. A value of -1 turns off the UU decoding of SMTP attachments. The value of 0
sets the decoding of UU encoded SMTP attachments to unlimited. A value other than 0 or -1 restricts the decoding of UU SMTP
attachments, and applies per attachment.
Log Options
Following log options allow SMTP inspector to log email addresses and filenames. Please note, this is logged only with the
unified2 output and is not logged with the console output (-A cmg). u2spewfoo can be used to read this data from the unified2.
log_mailfrom
This option enables SMTP inspector to parse and log the sender’s email address extracted from the "MAIL FROM" command
along with all the generated events for that session. The maximum number of bytes logged for this option is 1024.
log_rcptto
This option enables SMTP inspector to parse and log the recipient email addresses extracted from the "RCPT TO" command
along with all the generated events for that session. Multiple recipients are appended with commas. The maximum number of
bytes logged for this option is 1024.
log_filename
This option enables SMTP inspector to parse and log the MIME attachment filenames extracted from the Content-Disposition
header within the MIME body along with all the generated events for that session. Multiple filenames are appended with commas.
The maximum number of bytes logged for this option is 1024.
log_email_hdrs
This option enables SMTP inspector to parse and log the SMTP email headers extracted from SMTP data along with all generated
events for that session. The number of bytes extracted and logged depends upon the email_hdrs_log_depth.
email_hdrs_log_depth
This option specifies the depth for logging email headers. The allowed range for this option is 0 - 20480. A value of 0 will
disable email headers logging. The default value for this option is 1464.
5.14.3 Example
smtp =
{
normalize = ’cmds’,
normalize_cmds = ’EXPN VRFY RCPT’,
b64_decode_depth = 0,
Snort 3 User Manual 68 / 290
qp_decode_depth = 0,
bitenc_decode_depth = 0,
uu_decode_depth = 0,
log_mailfrom = true,
log_rcptto = true,
log_filename = true,
log_email_hdrs = true,
max_command_line_len = 512,
max_header_line_len = 1000,
max_response_line_len = 512,
max_auth_command_line_len = 50,
xlink2state = ’alert’,
alt_max_command_line_len =
{
{
command = ’MAIL’,
length = 260,
},
{
command = ’RCPT’,
length = 300,
},
{
command = ’HELP’,
length = 500,
},
{
command = ’HELO’,
length = 500,
},
{
command = ’ETRN’,
length = 500,
},
{
command = ’EXPN’,
length = 255,
},
{
command = ’VRFY’,
length = 255,
},
},
}
5.15 Telnet
Given a telnet data buffer, Telnet will normalize the buffer with respect to telnet commands and option negotiation, eliminating
telnet command sequences per RFC 854. It will also determine when a telnet connection is encrypted, per the use of the telnet
encryption option per RFC 2946.
5.15.1 Configuring the inspector to block exploits and attacks
ayt_attack_thresh number
Snort 3 User Manual 69 / 290
Detect and alert on consecutive are you there [AYT] commands beyond the threshold number specified. This addresses a few
specific vulnerabilities relating to bsd-based implementations of telnet.
5.16 Wizard
Using the wizard enables port-independent configuration and the detection of malware command and control channels. If the
wizard is bound to a session, it peeks at the initial payload to determine the service. For example, GET would indicate HTTP
and HELO would indicate SMTP. Upon finding a match, the service bindings are reevaluated so the session can be handed off to
the appropriate inspector. The wizard is still under development; if you find you need to tweak the defaults please let us know.
Additional Details:
If the wizard and one or more service inspectors are configured w/o explicitly configuring the binder, default bindings will be
generated which should work for most common cases.
Also note that while Snort 2 bindings can only be configured in the default policy, each Snort 3 policy can contain a binder
leading to an arbitrary hierarchy.
The entire configuration can be reloaded and hot-swapped during run-time via signal or command in both Snort 2 and Snort
3. Ultimately, Snort 3 will support commands to update the binder on the fly, thus enabling incremental reloads of individual
inspectors.
Both Snort 2 and Snort 3 support server specific configurations via a hosts table (XML in Snort 2 and Lua in Snort 3). The table
allows you to map network, protocol, and port to a service and policy. This table can be reloaded and hot-swapped separately
from the config file.
You can find the specifics on the binder, wizard, and hosts tables in the manual or command line like this: snort --help-module
binder, etc.
6 Basic Modules
Internal modules which are not plugins are termed "basic". These include configuration for core processing.
6.1 active
What: configure responses
Type: basic
Usage: global
Configuration:
int active.attempts = 0: number of TCP packets sent per response (with varying sequence numbers) { 0:20 }
string active.device: use ip for network layer responses or eth0 etc for link layer
string active.dst_mac: use format 01:23:45:67:89:ab
int active.max_responses = 0: maximum number of responses { 0: }
int active.min_interval = 255: minimum number of seconds between responses { 1: }
Snort 3 User Manual 70 / 290
6.2 alerts
What: configure alerts
Type: basic
Usage: global
Configuration:
bool alerts.alert_with_interface_name = false: include interface in alert info (fast, full, or syslog only)
bool alerts.default_rule_state = true: enable or disable ips rules
int alerts.detection_filter_memcap = 1048576: set available bytes of memory for detection_filters { 0: }
int alerts.event_filter_memcap = 1048576: set available bytes of memory for event_filters { 0: }
bool alerts.log_references = false: include rule references in alert info (full only)
string alerts.order = pass drop alert log: change the order of rule action application
int alerts.rate_filter_memcap = 1048576: set available bytes of memory for rate_filters { 0: }
string alerts.reference_net: set the CIDR for homenet (for use with -l or -B, does NOT change $HOME_NET in IDS mode)
bool alerts.stateful = false: don’t alert w/o established session (note: rule action still taken)
string alerts.tunnel_verdicts: let DAQ handle non-allow verdicts for gtp|teredo|6in4|4in6|4in4|6in6|gre|mpls traffic
6.3 attribute_table
What: configure hosts loading
Type: basic
Usage: global
Configuration:
int attribute_table.max_hosts = 1024: maximum number of hosts in attribute table { 32:207551 }
int attribute_table.max_services_per_host = 8: maximum number of services per host entry in attribute table { 1:65535 }
int attribute_table.max_metadata_services = 8: maximum number of services in rule metadata { 1:256 }
6.4 classifications
What: define rule categories with priority
Type: basic
Usage: global
Configuration:
string classifications[].name: name used with classtype rule option
int classifications[].priority = 1: default priority for class { 0: }
string classifications[].text: description of class
Snort 3 User Manual 71 / 290
6.5 daq
What: configure packet acquisition interface
Type: basic
Usage: global
Configuration:
string daq.module_dirs[].str: string parameter
string daq.input_spec: input specification
string daq.module: DAQ module to use
string daq.variables[].str: string parameter
int daq.instances[].id: instance ID (required) { 0: }
string daq.instances[].input_spec: input specification
string daq.instances[].variables[].str: string parameter
int daq.snaplen: set snap length (same as -s) { 0:65535 }
bool daq.no_promisc = false: whether to put DAQ device into promiscuous mode
Peg counts:
daq.pcaps: total files and interfaces processed (sum)
daq.received: total packets received from DAQ (sum)
daq.analyzed: total packets analyzed from DAQ (sum)
daq.dropped: packets dropped (sum)
daq.filtered: packets filtered out (sum)
daq.outstanding: packets unprocessed (sum)
daq.injected: active responses or replacements (sum)
daq.allow: total allow verdicts (sum)
daq.block: total block verdicts (sum)
daq.replace: total replace verdicts (sum)
daq.whitelist: total whitelist verdicts (sum)
daq.blacklist: total blacklist verdicts (sum)
daq.ignore: total ignore verdicts (sum)
daq.retry: total retry verdicts (sum)
daq.internal_blacklist: packets blacklisted internally due to lack of DAQ support (sum)
daq.internal_whitelist: packets whitelisted internally due to lack of DAQ support (sum)
daq.skipped: packets skipped at startup (sum)
daq.idle: attempts to acquire from DAQ without available packets (sum)
daq.rx_bytes: total bytes received (sum)
Snort 3 User Manual 72 / 290
6.6 decode
What: general decoder rules
Type: basic
Usage: context
Rules:
116:450 (decode) bad IP protocol
116:293 (decode) two or more IP (v4 and/or v6) encapsulation layers present
116:459 (decode) fragment with zero length
116:150 (decode) loopback IP
116:151 (decode) same src/dst IP
116:449 (decode) unassigned/reserved IP protocol
116:472 (decode) too many protocols present
116:473 (decode) ether type out of range
6.7 detection
What: configure general IPS rule processing parameters
Type: basic
Usage: global
Configuration:
int detection.asn1 = 256: maximum decode nodes { 1: }
int detection.offload_limit = 99999: minimum sizeof PDU to offload fast pattern search (defaults to disabled) { 0: }
int detection.offload_threads = 0: maximum number of simultaneous offloads (defaults to disabled) { 0: }
bool detection.pcre_enable = true: disable pcre pattern matching
int detection.pcre_match_limit = 1500: limit pcre backtracking, -1 = max, 0 = off { -1:1000000 }
int detection.pcre_match_limit_recursion = 1500: limit pcre stack consumption, -1 = max, 0 = off { -1:10000 }
int detection.trace: mask for enabling debug traces in module
Peg counts:
detection.analyzed: packets sent to detection (sum)
detection.hard_evals: non-fast pattern rule evaluations (sum)
detection.raw_searches: fast pattern searches in raw packet data (sum)
detection.cooked_searches: fast pattern searches in cooked packet data (sum)
detection.pkt_searches: fast pattern searches in packet data (sum)
detection.alt_searches: alt fast pattern searches in packet data (sum)
detection.key_searches: fast pattern searches in key buffer (sum)
Snort 3 User Manual 73 / 290
detection.header_searches: fast pattern searches in header buffer (sum)
detection.body_searches: fast pattern searches in body buffer (sum)
detection.file_searches: fast pattern searches in file buffer (sum)
detection.offloads: fast pattern searches that were offloaded (sum)
detection.alerts: alerts not including IP reputation (sum)
detection.total_alerts: alerts including IP reputation (sum)
detection.logged: logged packets (sum)
detection.passed: passed packets (sum)
detection.match_limit: fast pattern matches not processed (sum)
detection.queue_limit: events not queued because queue full (sum)
detection.log_limit: events queued but not logged (sum)
detection.event_limit: events filtered (sum)
detection.alert_limit: events previously triggered on same PDU (sum)
6.8 event_filter
What: configure thresholding of events
Type: basic
Usage: context
Configuration:
int event_filter[].gid = 1: rule generator ID { 0: }
int event_filter[].sid = 1: rule signature ID { 0: }
enum event_filter[].type: 1st count events | every count events | once after count events { limit | threshold | both }
enum event_filter[].track: filter only matching source or destination addresses { by_src | by_dst }
int event_filter[].count = 0: number of events in interval before tripping; -1 to disable { -1: }
int event_filter[].seconds = 0: count interval { 0: }
string event_filter[].ip: restrict filter to these addresses according to track
6.9 event_queue
What: configure event queue parameters
Type: basic
Usage: context
Configuration:
int event_queue.max_queue = 8: maximum events to queue { 1: }
int event_queue.log = 3: maximum events to log { 1: }
enum event_queue.order_events = content_length: criteria for ordering incoming events { priority|content_length }
bool event_queue.process_all_events = false: process just first action group or all action groups
Snort 3 User Manual 74 / 290
6.10 high_availability
What: implement flow tracking high availability
Type: basic
Usage: global
Configuration:
bool high_availability.enable = false: enable high availability
bool high_availability.daq_channel = false: enable use of daq data plane channel
bit_list high_availability.ports: side channel message port list { 65535 }
real high_availability.min_age = 1.0: minimum session life before HA updates { 0.0:100.0 }
real high_availability.min_sync = 1.0: minimum interval between HA updates { 0.0:100.0 }
Peg counts:
high_availability.packets: total packets (sum)
6.11 host_cache
What: configure hosts
Type: basic
Usage: global
Configuration:
int host_cache[].size: size of host cache
Peg counts:
host_cache.lru_cache_adds: lru cache added new entry (sum)
host_cache.lru_cache_replaces: lru cache replaced existing entry (sum)
host_cache.lru_cache_prunes: lru cache pruned entry to make space for new entry (sum)
host_cache.lru_cache_find_hits: lru cache found entry in cache (sum)
host_cache.lru_cache_find_misses: lru cache did not find entry in cache (sum)
host_cache.lru_cache_removes: lru cache found entry and removed it (sum)
host_cache.lru_cache_clears: lru cache clear API calls (sum)
6.12 host_tracker
What: configure hosts
Type: basic
Usage: global
Configuration:
addr host_tracker[].IP = 0.0.0.0/32: hosts address / cidr
Snort 3 User Manual 75 / 290
enum host_tracker[].frag_policy: defragmentation policy { first | linux | bsd | bsd_right | last | windows | solaris }
enum host_tracker[].tcp_policy: TCP reassembly policy { first | last | linux | old_linux | bsd | macos | solaris | irix | hpux11 |
hpux10 | windows | win_2003 | vista | proxy }
string host_tracker[].services[].name: service identifier
enum host_tracker[].services[].proto = tcp: IP protocol { tcp | udp }
port host_tracker[].services[].port: port number
Peg counts:
host_tracker.service_adds: host service adds (sum)
host_tracker.service_finds: host service finds (sum)
host_tracker.service_removes: host service removes (sum)
6.13 hosts
What: configure hosts
Type: basic
Usage: global
Configuration:
addr hosts[].ip = 0.0.0.0/32: hosts address / CIDR
enum hosts[].frag_policy: defragmentation policy { first | linux | bsd | bsd_right | last | windows | solaris }
enum hosts[].tcp_policy: TCP reassembly policy { first | last | linux | old_linux | bsd | macos | solaris | irix | hpux11 | hpux10 |
windows | win_2003 | vista | proxy }
string hosts[].services[].name: service identifier
enum hosts[].services[].proto = tcp: IP protocol { tcp | udp }
port hosts[].services[].port: port number
6.14 inspection
What: configure basic inspection policy parameters
Type: basic
Usage: inspect
Configuration:
int inspection.id = 0: correlate policy and events with other items in configuration { 0:65535 }
string inspection.uuid: correlate events by uuid
enum inspection.mode = inline-test: set policy mode { inline | inline-test }
Snort 3 User Manual 76 / 290
6.15 ips
What: configure IPS rule processing
Type: basic
Usage: detect
Configuration:
bool ips.enable_builtin_rules = false: enable events from builtin rules w/o stubs
int ips.id = 0: correlate unified2 events with configuration { 0:65535 }
string ips.include: legacy snort rules and includes
enum ips.mode: set policy mode { tap | inline | inline-test }
string ips.rules: snort rules and includes
string ips.uuid = 00000000-0000-0000-0000-000000000000: IPS policy uuid
Peg counts:
ips.invalid_policy_ids: Number of times an invalid policy ID was provided (sum)
6.16 latency
What: packet and rule latency monitoring and control
Type: basic
Usage: context
Configuration:
int latency.packet.max_time = 500: set timeout for packet latency thresholding (usec) { 0: }
bool latency.packet.fastpath = false: fastpath expensive packets (max_time exceeded)
enum latency.packet.action = none: event action if packet times out and is fastpathed { none | alert | log | alert_and_log }
int latency.rule.max_time = 500: set timeout for rule evaluation (usec) { 0: }
bool latency.rule.suspend = false: temporarily suspend expensive rules
int latency.rule.suspend_threshold = 5: set threshold for number of timeouts before suspending a rule { 1: }
int latency.rule.max_suspend_time = 30000: set max time for suspending a rule (ms, 0 means permanently disable rule) { 0:
}
enum latency.rule.action = none: event action for rule latency enable and suspend events { none | alert | log | alert_and_log }
Rules:
134:1 (latency) rule tree suspended due to latency
134:2 (latency) rule tree re-enabled after suspend timeout
134:3 (latency) packet fastpathed due to latency
Peg counts:
Snort 3 User Manual 77 / 290
latency.total_packets: total packets monitored (sum)
latency.total_usecs: total usecs elapsed (sum)
latency.max_usecs: maximum usecs elapsed (sum)
latency.packet_timeouts: packets that timed out (sum)
latency.total_rule_evals: total rule evals monitored (sum)
latency.rule_eval_timeouts: rule evals that timed out (sum)
latency.rule_tree_enables: rule tree re-enables (sum)
6.17 memory
What: memory management configuration
Type: basic
Usage: global
Configuration:
int memory.cap = 0: set the per-packet-thread cap on memory (bytes, 0 to disable) { 0: }
bool memory.soft = false: always succeed in allocating memory, even if above the cap
int memory.threshold = 0: set the per-packet-thread threshold for preemptive cleanup actions (percent, 0 to disable) { 0: }
6.18 network
What: configure basic network parameters
Type: basic
Usage: context
Configuration:
multi network.checksum_drop = none: drop if checksum is bad { all | ip | noip | tcp | notcp | udp | noudp | icmp | noicmp |
none }
multi network.checksum_eval = none: checksums to verify { all | ip | noip | tcp | notcp | udp | noudp | icmp | noicmp | none }
bool network.decode_drops = false: enable dropping of packets by the decoder
int network.id = 0: correlate unified2 events with configuration { 0:65535 }
int network.min_ttl = 1: alert / normalize packets with lower TTL / hop limit (you must enable rules and / or normalization
also) { 1:255 }
int network.new_ttl = 1: use this value for responses and when normalizing { 1:255 }
int network.layers = 40: the maximum number of protocols that Snort can correctly decode { 3:255 }
int network.max_ip6_extensions = 0: the maximum number of IP6 options Snort will process for a given IPv6 layer before
raising 116:456 (0 = unlimited) { 0:255 }
int network.max_ip_layers = 0: the maximum number of IP layers Snort will process for a given packet before raising 116:293
(0 = unlimited) { 0:255 }
Snort 3 User Manual 78 / 290
6.19 output
What: configure general output parameters
Type: basic
Usage: global
Configuration:
bool output.dump_chars_only = false: turns on character dumps (same as -C)
bool output.dump_payload = false: dumps application layer (same as -d)
bool output.dump_payload_verbose = false: dumps raw packet starting at link layer (same as -X)
int output.event_trace.max_data = 0: maximum amount of packet data to capture { 0:65535 }
bool output.quiet = false: suppress non-fatal information (still show alerts, same as -q)
string output.logdir = .: where to put log files (same as -l)
bool output.obfuscate = false: obfuscate the logged IP addresses (same as -O)
bool output.obfuscate_pii = false: mask all but the last 4 characters of credit card and social security numbers
bool output.show_year = false: include year in timestamp in the alert and log files (same as -y)
int output.tagged_packet_limit = 256: maximum number of packets tagged for non-packet metrics { 0: }
bool output.verbose = false: be verbose (same as -v)
bool output.wide_hex_dump = true: output 20 bytes per lines instead of 16 when dumping buffers
bool output.enable_packet_trace = false: enable summary output of state that determined packet verdict
enum output.packet_trace_output = console: select where to send packet trace { console | file }
6.20 packets
What: configure basic packet handling
Type: basic
Usage: global
Configuration:
bool packets.address_space_agnostic = false: determines whether DAQ address space info is used to track fragments and
connections
string packets.bpf_file: file with BPF to select traffic for Snort
int packets.limit = 0: maximum number of packets to process before stopping (0 is unlimited) { 0: }
int packets.skip = 0: number of packets to skip before before processing { 0: }
bool packets.vlan_agnostic = false: determines whether VLAN info is used to track fragments and connections
Snort 3 User Manual 79 / 290
6.21 process
What: configure basic process setup
Type: basic
Usage: global
Configuration:
string process.chroot: set chroot directory (same as -t)
string process.threads[].cpuset: pin the associated thread to this cpuset
int process.threads[].thread = 0: set cpu affinity for the <cur_thread_num> thread that runs { 0: }
bool process.daemon = false: fork as a daemon (same as -D)
bool process.dirty_pig = false: shutdown without internal cleanup
string process.set_gid: set group ID (same as -g)
string process.set_uid: set user ID (same as -u)
string process.umask: set process umask (same as -m)
bool process.utc = false: use UTC instead of local time for timestamps
6.22 profiler
What: configure profiling of rules and/or modules
Type: basic
Usage: global
Configuration:
bool profiler.modules.show = true: show module time profile stats
int profiler.modules.count = 0: limit results to count items per level (0 = no limit) { 0: }
enum profiler.modules.sort = total_time: sort by given field { none | checks | avg_check | total_time }
int profiler.modules.max_depth = -1: limit depth to max_depth (-1 = no limit) { -1: }
bool profiler.memory.show = true: show module memory profile stats
int profiler.memory.count = 0: limit results to count items per level (0 = no limit) { 0: }
enum profiler.memory.sort = total_used: sort by given field { none | allocations | total_used | avg_allocation }
int profiler.memory.max_depth = -1: limit depth to max_depth (-1 = no limit) { -1: }
bool profiler.rules.show = true: show rule time profile stats
int profiler.rules.count = 0: print results to given level (0 = all) { 0: }
enum profiler.rules.sort = total_time: sort by given field { none | checks | avg_check | total_time | matches | no_matches |
avg_match | avg_no_match }
Snort 3 User Manual 80 / 290
6.23 rate_filter
What: configure rate filters (which change rule actions)
Type: basic
Usage: detect
Configuration:
int rate_filter[].gid = 1: rule generator ID { 0: }
int rate_filter[].sid = 1: rule signature ID { 0: }
enum rate_filter[].track = by_src: filter only matching source or destination addresses { by_src | by_dst | by_rule }
int rate_filter[].count = 1: number of events in interval before tripping { 0: }
int rate_filter[].seconds = 1: count interval { 0: }
enum rate_filter[].new_action = alert: take this action on future hits until timeout { log | pass | alert | drop | block | reset }
int rate_filter[].timeout = 1: count interval { 0: }
string rate_filter[].apply_to: restrict filter to these addresses according to track
6.24 references
What: define reference systems used in rules
Type: basic
Usage: global
Configuration:
string references[].name: name used with reference rule option
string references[].url: where this reference is defined
6.25 rule_state
What: enable/disable specific IPS rules
Type: basic
Usage: detect
Configuration:
int rule_state.gid = 0: rule generator ID { 0: }
int rule_state.sid = 0: rule signature ID { 0: }
bool rule_state.enable = true: enable or disable rule in all policies
Snort 3 User Manual 81 / 290
6.26 search_engine
What: configure fast pattern matcher
Type: basic
Usage: global
Configuration:
int search_engine.bleedover_port_limit = 1024: maximum ports in rule before demotion to any-any port group { 1: }
bool search_engine.bleedover_warnings_enabled = false: print warning if a rule is demoted to any-any port group
bool search_engine.enable_single_rule_group = false: put all rules into one group
bool search_engine.debug = false: print verbose fast pattern info
bool search_engine.debug_print_nocontent_rule_tests = false: print rule group info during packet evaluation
bool search_engine.debug_print_rule_group_build_details = false: print rule group info during compilation
bool search_engine.debug_print_rule_groups_uncompiled = false: prints uncompiled rule group information
bool search_engine.debug_print_rule_groups_compiled = false: prints compiled rule group information
int search_engine.max_pattern_len = 0: truncate patterns when compiling into state machine (0 means no maximum) { 0: }
int search_engine.max_queue_events = 5: maximum number of matching fast pattern states to queue per packet { 2:100 }
bool search_engine.detect_raw_tcp = true: detect on TCP payload before reassembly
dynamic search_engine.search_method = ac_bnfa: set fast pattern algorithm - choose available search engine { ac_banded |
ac_bnfa | ac_full | ac_sparse | ac_sparse_bands | ac_std | hyperscan | lowmem }
bool search_engine.search_optimize = true: tweak state machine construction for better performance
bool search_engine.show_fast_patterns = false: print fast pattern info for each rule
bool search_engine.split_any_any = true: evaluate any-any rules separately to save memory
Peg counts:
search_engine.max_queued: maximum fast pattern matches queued for further evaluation (sum)
search_engine.total_flushed: fast pattern matches discarded due to overflow (sum)
search_engine.total_inserts: total fast pattern hits (sum)
search_engine.total_unique: total unique fast pattern hits (sum)
search_engine.non_qualified_events: total non-qualified events (sum)
search_engine.qualified_events: total qualified events (sum)
search_engine.searched_bytes: total bytes searched (sum)
Snort 3 User Manual 82 / 290
6.27 side_channel
What: implement the side-channel asynchronous messaging subsystem
Type: basic
Usage: global
Configuration:
bit_list side_channel.ports: side channel message port list { 65535 }
string side_channel.connectors[].connector: connector handle
string side_channel.connector: connector handle
Peg counts:
side_channel.packets: total packets (sum)
6.28 snort
What: command line configuration and shell commands
Type: basic
Usage: global
Configuration:
string snort.-?: <option prefix> output matching command line option quick help (same as --help-options) { (optional) }
string snort.-A: <mode> set alert mode: none, cmg, or alert_*
addr snort.-B = 255.255.255.255/32: <mask> obfuscated IP addresses in alerts and packet dumps using CIDR mask
implied snort.-C: print out payloads with character data only (no hex)
string snort.-c: <conf> use this configuration
implied snort.-D: run Snort in background (daemon) mode
implied snort.-d: dump the Application Layer
implied snort.-e: display the second layer header info
implied snort.-f: turn off fflush() calls after binary log writes
int snort.-G: <0xid> (same as --logid) { 0:65535 }
string snort.-g: <gname> run snort gid as <gname> group (or gid) after initialization
implied snort.-H: make hash tables deterministic
string snort.-i: <iface>. . . list of interfaces
port snort.-j: <port> to listen for Telnet connections
enum snort.-k = all: <mode> checksum mode; default is all { all|noip|notcp|noudp|noicmp|none }
string snort.-L: <mode> logging mode (none, dump, pcap, or log_*)
string snort.-l: <logdir> log to this directory instead of current directory
implied snort.-M: log messages to syslog (not alerts)
Snort 3 User Manual 83 / 290
int snort.-m: <umask> set umask = <umask> { 0: }
int snort.-n: <count> stop after count packets { 0: }
implied snort.-O: obfuscate the logged IP addresses
implied snort.-Q: enable inline mode operation
implied snort.-q: quiet mode - Don’t show banner and status report
string snort.-R: <rules> include this rules file in the default policy
string snort.-r: <pcap>. . . (same as --pcap-list)
string snort.-S: <x=v> set config variable x equal to value v
int snort.-s = 1514: <snap> (same as --snaplen); default is 1514 { 68:65535 }
implied snort.-T: test and report on the current Snort configuration
string snort.-t: <dir> chroots process to <dir> after initialization
implied snort.-U: use UTC for timestamps
string snort.-u: <uname> run snort as <uname> or <uid> after initialization
implied snort.-V: (same as --version)
implied snort.-v: be verbose
implied snort.-W: lists available interfaces
implied snort.-X: dump the raw packet data starting at the link layer
implied snort.-x: same as --pedantic
implied snort.-y: include year in timestamp in the alert and log files
int snort.-z = 1: <count> maximum number of packet threads (same as --max-packet-threads); 0 gets the number of CPU cores
reported by the system; default is 1 { 0: }
implied snort.--alert-before-pass: process alert, drop, sdrop, or reject before pass; default is pass before alert, drop,. . .
string snort.--bpf: <filter options> are standard BPF options, as seen in TCPDump
string snort.--c2x: output hex for given char (see also --x2c)
string snort.--control-socket: <file> to create unix socket
implied snort.--create-pidfile: create PID file, even when not in Daemon mode
string snort.--daq: <type> select packet acquisition module (default is pcap)
string snort.--daq-dir: <dir> tell snort where to find desired DAQ
implied snort.--daq-list: list packet acquisition modules available in optional dir, default is static modules only
string snort.--daq-var: <name=value> specify extra DAQ configuration variable
implied snort.--dirty-pig: don’t flush packets on shutdown
string snort.--dump-builtin-rules: [<module prefix>] output stub rules for selected modules { (optional) }
implied snort.--dump-dynamic-rules: output stub rules for all loaded rules libraries
string snort.--dump-defaults: [<module prefix>] output module defaults in Lua format { (optional) }
implied snort.--dump-version: output the version, the whole version, and only the version
Snort 3 User Manual 84 / 290
implied snort.--enable-inline-test: enable Inline-Test Mode Operation
implied snort.--gen-msg-map: dump builtin rules in gen-msg.map format for use by other tools
implied snort.--help: list command line options
string snort.--help-commands: [<module prefix>] output matching commands { (optional) }
string snort.--help-config: [<module prefix>] output matching config options { (optional) }
string snort.--help-counts: [<module prefix>] output matching peg counts { (optional) }
string snort.--help-module: <module> output description of given module
implied snort.--help-modules: list all available modules with brief help
string snort.--help-options: [<option prefix>] output matching command line option quick help (same as -?) { (optional) }
implied snort.--help-plugins: list all available plugins with brief help
implied snort.--help-signals: dump available control signals
int snort.--id-offset = 0: offset to add to instance IDs when logging to files { 0:65535 }
implied snort.--id-subdir: create/use instance subdirectories in logdir instead of instance filename prefix
implied snort.--id-zero: use id prefix / subdirectory even with one packet thread
implied snort.--list-buffers: output available inspection buffers
string snort.--list-builtin: [<module prefix>] output matching builtin rules { (optional) }
string snort.--list-gids: [<module prefix>] output matching generators { (optional) }
string snort.--list-modules: [<module type>] list all known modules of given type { (optional) }
implied snort.--list-plugins: list all known plugins
string snort.--lua: <chunk> extend/override conf with chunk; may be repeated
int snort.--logid: <0xid> log Identifier to uniquely id events for multiple snorts (same as -G) { 0:65535 }
implied snort.--markup: output help in asciidoc compatible format
int snort.--max-packet-threads = 1: <count> configure maximum number of packet threads (same as -z) { 0: }
implied snort.--mem-check: like -T but also compile search engines
implied snort.--nostamps: don’t include timestamps in log file names
implied snort.--nolock-pidfile: do not try to lock Snort PID file
implied snort.--pause: wait for resume/quit command before processing packets/terminating
implied snort.--parsing-follows-files: parse relative paths from the perspective of the current configuration file
string snort.--pcap-file: <file> file that contains a list of pcaps to read - read mode is implied
string snort.--pcap-list: <list> a space separated list of pcaps to read - read mode is implied
string snort.--pcap-dir: <dir> a directory to recurse to look for pcaps - read mode is implied
string snort.--pcap-filter: <filter> filter to apply when getting pcaps from file or directory
int snort.--pcap-loop: <count> read all pcaps <count> times; 0 will read until Snort is terminated { -1: }
implied snort.--pcap-no-filter: reset to use no filter when getting pcaps from file or directory
implied snort.--pcap-reload: if reading multiple pcaps, reload snort config between pcaps
Snort 3 User Manual 85 / 290
implied snort.--pcap-show: print a line saying what pcap is currently being read
implied snort.--pedantic: warnings are fatal
string snort.--plugin-path: <path> where to find plugins
implied snort.--process-all-events: process all action groups
string snort.--rule: <rules> to be added to configuration; may be repeated
implied snort.--rule-to-hex: output so rule header to stdout for text rule on stdin
string snort.--rule-to-text = [SnortFoo]: output plain so rule header to stdout for text rule on stdin { 16 }
string snort.--run-prefix: <pfx> prepend this to each output file
string snort.--script-path: <path> to a luajit script or directory containing luajit scripts
implied snort.--shell: enable the interactive command line
implied snort.--piglet: enable piglet test harness mode
implied snort.--show-plugins: list module and plugin versions
int snort.--skip: <n> skip 1st n packets { 0: }
int snort.--snaplen = 1514: <snap> set snaplen of packet (same as -s) { 68:65535 }
implied snort.--stdin-rules: read rules from stdin until EOF or a line starting with END is read
implied snort.--treat-drop-as-alert: converts drop, sdrop, and reject rules into alert rules during startup
implied snort.--treat-drop-as-ignore: use drop, sdrop, and reject rules to ignore session traffic when not inline
string snort.--catch-test: comma separated list of cat unit test tags or all
implied snort.--version: show version number (same as -V)
implied snort.--warn-all: enable all warnings
implied snort.--warn-conf: warn about configuration issues
implied snort.--warn-daq: warn about DAQ issues, usually related to mode
implied snort.--warn-flowbits: warn about flowbits that are checked but not set and vice-versa
implied snort.--warn-hosts: warn about host table issues
implied snort.--warn-plugins: warn about issues that prevent plugins from loading
implied snort.--warn-rules: warn about duplicate rules and rule parsing issues
implied snort.--warn-scripts: warn about issues discovered while processing Lua scripts
implied snort.--warn-symbols: warn about unknown symbols in your Lua config
implied snort.--warn-vars: warn about variable definition and usage issues
int snort.--x2c: output ASCII char for given hex (see also --c2x)
string snort.--x2s: output ASCII string for given byte code (see also --x2c)
Commands:
snort.show_plugins(): show available plugins
snort.delete_inspector(inspector): delete an inspector from the default policy
Snort 3 User Manual 86 / 290
snort.dump_stats(): show summary statistics
snort.rotate_stats(): roll perfmonitor log files
snort.reload_config(filename): load new configuration
snort.reload_policy(filename): reload part or all of the default policy
snort.reload_daq(): reload daq module
snort.reload_hosts(filename): load a new hosts table
snort.pause(): suspend packet processing
snort.resume(): continue packet processing
snort.detach(): exit shell w/o shutdown
snort.quit(): shutdown and dump-stats
snort.help(): this output
Peg counts:
snort.local_commands: total local commands processed (sum)
snort.remote_commands: total remote commands processed (sum)
snort.signals: total signals processed (sum)
snort.conf_reloads: number of times configuration was reloaded (sum)
snort.policy_reloads: number of times policies were reloaded (sum)
snort.inspector_deletions: number of times inspectors were deleted (sum)
snort.daq_reloads: number of times daq configuration was reloaded (sum)
snort.attribute_table_reloads: number of times hosts table was reloaded (sum)
snort.attribute_table_hosts: total number of hosts in table (sum)
6.29 suppress
What: configure event suppressions
Type: basic
Usage: detect
Configuration:
int suppress[].gid = 0: rule generator ID { 0: }
int suppress[].sid = 0: rule signature ID { 0: }
enum suppress[].track: suppress only matching source or destination addresses { by_src | by_dst }
string suppress[].ip: restrict suppression to these addresses according to track
7 Codec Modules
Codec is short for coder / decoder. These modules are used for basic protocol decoding, anomaly detection, and construction of
active responses.
Snort 3 User Manual 87 / 290
7.1 arp
What: support for address resolution protocol
Type: codec
Usage: context
Rules:
116:109 (arp) truncated ARP
7.2 auth
What: support for IP authentication header
Type: codec
Usage: context
Rules:
116:465 (auth) truncated authentication header
116:466 (auth) bad authentication header length
7.3 ciscometadata
What: support for cisco metadata
Type: codec
Usage: context
Rules:
116:468 (ciscometadata) truncated Cisco Metadata header
116:469 (ciscometadata) invalid Cisco Metadata option length
116:470 (ciscometadata) invalid Cisco Metadata option type
116:471 (ciscometadata) invalid Cisco Metadata SGT
7.4 eapol
What: support for extensible authentication protocol over LAN
Type: codec
Usage: context
Rules:
116:110 (eapol) truncated EAP header
116:111 (eapol) EAP key truncated
116:112 (eapol) EAP header truncated
Snort 3 User Manual 88 / 290
7.5 erspan2
What: support for encapsulated remote switched port analyzer - type 2
Type: codec
Usage: context
Rules:
116:462 (erspan2) ERSpan header version mismatch
116:463 (erspan2) captured length < ERSpan type2 header length
7.6 erspan3
What: support for encapsulated remote switched port analyzer - type 3
Type: codec
Usage: context
Rules:
116:464 (erspan3) captured < ERSpan type3 header length
7.7 esp
What: support for encapsulating security payload
Type: codec
Usage: context
Configuration:
bool esp.decode_esp = false: enable for inspection of esp traffic that has authentication but not encryption
Rules:
116:294 (esp) truncated encapsulated security payload header
7.8 eth
What: support for ethernet protocol (DLT 1) (DLT 51)
Type: codec
Usage: context
Rules:
116:424 (eth) truncated ethernet header
7.9 fabricpath
What: support for fabricpath
Type: codec
Usage: context
Rules:
116:467 (fabricpath) truncated FabricPath header
Snort 3 User Manual 89 / 290
7.10 gre
What: support for generic routing encapsulation
Type: codec
Usage: context
Rules:
116:160 (gre) GRE header length > payload length
116:161 (gre) multiple encapsulations in packet
116:162 (gre) invalid GRE version
116:163 (gre) invalid GRE header
116:164 (gre) invalid GRE v.1 PPTP header
116:165 (gre) GRE trans header length > payload length
7.11 gtp
What: support for general-packet-radio-service tunneling protocol
Type: codec
Usage: context
Rules:
116:297 (gtp) two or more GTP encapsulation layers present
116:298 (gtp) GTP header length is invalid
7.12 icmp4
What: support for Internet control message protocol v4
Type: codec
Usage: context
Rules:
116:105 (icmp4) ICMP header truncated
116:106 (icmp4) ICMP timestamp header truncated
116:107 (icmp4) ICMP address header truncated
116:250 (icmp4) ICMP original IP header truncated
116:251 (icmp4) ICMP version and original IP header versions differ
116:252 (icmp4) ICMP original datagram length < original IP header length
116:253 (icmp4) ICMP original IP payload < 64 bits
116:254 (icmp4) ICMP original IP payload > 576 bytes
116:255 (icmp4) ICMP original IP fragmented and offset not 0
116:415 (icmp4) ICMP4 packet to multicast dest address
Snort 3 User Manual 90 / 290
116:416 (icmp4) ICMP4 packet to broadcast dest address
116:418 (icmp4) ICMP4 type other
116:434 (icmp4) ICMP ping Nmap
116:435 (icmp4) ICMP icmpenum v1.1.1
116:436 (icmp4) ICMP redirect host
116:437 (icmp4) ICMP redirect net
116:438 (icmp4) ICMP traceroute ipopts
116:439 (icmp4) ICMP source quench
116:440 (icmp4) broadscan smurf scanner
116:441 (icmp4) ICMP destination unreachable communication administratively prohibited
116:442 (icmp4) ICMP destination unreachable communication with destination host is administratively prohibited
116:443 (icmp4) ICMP destination unreachable communication with destination network is administratively prohibited
116:451 (icmp4) ICMP path MTU denial of service attempt
116:452 (icmp4) Linux ICMP header DOS attempt
116:426 (icmp4) truncated ICMP4 header
Peg counts:
icmp4.bad_checksum: non-zero icmp checksums (sum)
7.13 icmp6
What: support for Internet control message protocol v6
Type: codec
Usage: context
Rules:
116:427 (icmp6) truncated ICMPv6 header
116:431 (icmp6) ICMPv6 type not decoded
116:432 (icmp6) ICMPv6 packet to multicast address
116:285 (icmp6) ICMPv6 packet of type 2 (message too big) with MTU field < 1280
116:286 (icmp6) ICMPv6 packet of type 1 (destination unreachable) with non-RFC 2463 code
116:287 (icmp6) ICMPv6 router solicitation packet with a code not equal to 0
116:288 (icmp6) ICMPv6 router advertisement packet with a code not equal to 0
116:289 (icmp6) ICMPv6 router solicitation packet with the reserved field not equal to 0
116:290 (icmp6) ICMPv6 router advertisement packet with the reachable time field set > 1 hour
116:457 (icmp6) ICMPv6 packet of type 1 (destination unreachable) with non-RFC 4443 code
116:460 (icmp6) ICMPv6 node info query/response packet with a code greater than 2
116:474 (icmp6) ICMPv6 not encapsulated in IPv6
Peg counts:
icmp6.bad_icmp6_checksum: nonzero icmp6 checksums (sum)
Snort 3 User Manual 91 / 290
7.14 igmp
What: support for Internet group management protocol
Type: codec
Usage: context
Rules:
116:455 (igmp) DOS IGMP IP options validation attempt
7.15 ipv4
What: support for Internet protocol v4
Type: codec
Usage: context
Rules:
116:1 (ipv4) not IPv4 datagram
116:2 (ipv4) IPv4 header length < minimum
116:3 (ipv4) IPv4 datagram length < header field
116:4 (ipv4) IPv4 options found with bad lengths
116:5 (ipv4) truncated IPv4 options
116:6 (ipv4) IPv4 datagram length > captured length
116:404 (ipv4) IPv4 packet with zero TTL
116:405 (ipv4) IPv4 packet with bad frag bits (both MF and DF set)
116:407 (ipv4) IPv4 packet frag offset + length exceed maximum
116:408 (ipv4) IPv4 packet from current net source address
116:409 (ipv4) IPv4 packet to current net dest address
116:410 (ipv4) IPv4 packet from multicast source address
116:411 (ipv4) IPv4 packet from reserved source address
116:412 (ipv4) IPv4 packet to reserved dest address
116:413 (ipv4) IPv4 packet from broadcast source address
116:414 (ipv4) IPv4 packet to broadcast dest address
116:428 (ipv4) IPv4 packet below TTL limit
116:430 (ipv4) IPv4 packet both DF and offset set
116:448 (ipv4) IPv4 reserved bit set
116:444 (ipv4) IPv4 option set
116:425 (ipv4) truncated IPv4 header
Peg counts:
ipv4.bad_checksum: nonzero ip checksums (sum)
Snort 3 User Manual 92 / 290
7.16 ipv6
What: support for Internet protocol v6
Type: codec
Usage: context
Rules:
116:270 (ipv6) IPv6 packet below TTL limit
116:271 (ipv6) IPv6 header claims to not be IPv6
116:272 (ipv6) IPv6 truncated extension header
116:273 (ipv6) IPv6 truncated header
116:274 (ipv6) IPv6 datagram length < header field
116:275 (ipv6) IPv6 datagram length > captured length
116:276 (ipv6) IPv6 packet with destination address ::0
116:277 (ipv6) IPv6 packet with multicast source address
116:278 (ipv6) IPv6 packet with reserved multicast destination address
116:279 (ipv6) IPv6 header includes an undefined option type
116:280 (ipv6) IPv6 address includes an unassigned multicast scope value
116:281 (ipv6) IPv6 header includes an invalid value for the next header field
116:282 (ipv6) IPv6 header includes a routing extension header followed by a hop-by-hop header
116:283 (ipv6) IPv6 header includes two routing extension headers
116:292 (ipv6) IPv6 header has destination options followed by a routing header
116:291 (ipv6) IPV6 tunneled over IPv4, IPv6 header truncated, possible Linux kernel attack
116:295 (ipv6) IPv6 header includes an option which is too big for the containing header
116:296 (ipv6) IPv6 packet includes out-of-order extension headers
116:429 (ipv6) IPv6 packet has zero hop limit
116:453 (ipv6) ISATAP-addressed IPv6 traffic spoofing attempt
116:458 (ipv6) bogus fragmentation packet, possible BSD attack
116:461 (ipv6) IPv6 routing type 0 extension header
116:456 (ipv6) too many IPv6 extension headers
116:475 (ipv6) IPv6 mobility header includes an invalid value for the payload protocol field
7.17 llc
What: support for logical link control
Type: codec
Usage: context
Rules:
116:131 (llc) bad LLC header
116:132 (llc) bad extra LLC info
Snort 3 User Manual 93 / 290
7.18 mpls
What: support for multiprotocol label switching
Type: codec
Usage: context
Configuration:
bool mpls.enable_mpls_multicast = false: enables support for MPLS multicast
bool mpls.enable_mpls_overlapping_ip = false: enable if private network addresses overlap and must be differentiated by
MPLS label(s)
int mpls.max_mpls_stack_depth = -1: set MPLS stack depth { -1: }
enum mpls.mpls_payload_type = ip4: set encapsulated payload type { eth | ip4 | ip6 }
Rules:
116:170 (mpls) bad MPLS frame
116:171 (mpls) MPLS label 0 appears in non-bottom header
116:172 (mpls) MPLS label 1 appears in bottom header
116:173 (mpls) MPLS label 2 appears in non-bottom header
116:174 (mpls) MPLS label 3 appears in header
116:175 (mpls) MPLS label 4, 5,.. or 15 appears in header
116:176 (mpls) too many MPLS headers
Peg counts:
mpls.total_packets: total mpls labeled packets processed (sum)
mpls.total_bytes: total mpls labeled bytes processed (sum)
7.19 pbb
What: support for 802.1ah protocol
Type: codec
Usage: context
Rules:
116:424 (pbb) truncated ethernet header
7.20 pgm
What: support for pragmatic general multicast
Type: codec
Usage: context
Rules:
116:454 (pgm) PGM nak list overflow attempt
Snort 3 User Manual 94 / 290
7.21 pppoe
What: support for point-to-point protocol over ethernet
Type: codec
Usage: context
Rules:
116:120 (pppoe) bad PPPOE frame detected
7.22 tcp
What: support for transmission control protocol
Type: codec
Usage: context
Rules:
116:45 (tcp) TCP packet length is smaller than 20 bytes
116:46 (tcp) TCP data offset is less than 5
116:47 (tcp) TCP header length exceeds packet length
116:54 (tcp) TCP options found with bad lengths
116:55 (tcp) truncated TCP options
116:56 (tcp) T/TCP detected
116:57 (tcp) obsolete TCP options found
116:58 (tcp) experimental TCP options found
116:59 (tcp) TCP window scale option found with length > 14
116:400 (tcp) XMAS attack detected
116:401 (tcp) Nmap XMAS attack detected
116:419 (tcp) TCP urgent pointer exceeds payload length or no payload
116:420 (tcp) TCP SYN with FIN
116:421 (tcp) TCP SYN with RST
116:422 (tcp) TCP PDU missing ack for established session
116:423 (tcp) TCP has no SYN, ACK, or RST
116:433 (tcp) DDOS shaft SYN flood
116:446 (tcp) TCP port 0 traffic
116:402 (tcp) DOS NAPTHA vulnerability detected
116:403 (tcp) SYN to multicast address
Peg counts:
tcp.bad_tcp4_checksum: nonzero tcp over ip checksums (sum)
tcp.bad_tcp6_checksum: nonzero tcp over ipv6 checksums (sum)
Snort 3 User Manual 95 / 290
7.23 token_ring
What: support for token ring decoding
Type: codec
Usage: context
Rules:
116:140 (token_ring) bad Token Ring header
116:141 (token_ring) bad Token Ring ETHLLC header
116:142 (token_ring) bad Token Ring MRLEN header
116:143 (token_ring) bad Token Ring MR header
7.24 udp
What: support for user datagram protocol
Type: codec
Usage: context
Configuration:
bool udp.deep_teredo_inspection = false: look for Teredo on all UDP ports (default is only 3544)
bool udp.enable_gtp = false: decode GTP encapsulations
bit_list udp.gtp_ports = 2152 3386: set GTP ports { 65535 }
Rules:
116:95 (udp) truncated UDP header
116:96 (udp) invalid UDP header, length field < 8
116:97 (udp) short UDP packet, length field > payload length
116:98 (udp) long UDP packet, length field < payload length
116:406 (udp) invalid IPv6 UDP packet, checksum zero
116:445 (udp) large UDP packet (> 4000 bytes)
116:447 (udp) UDP port 0 traffic
Peg counts:
udp.bad_udp4_checksum: nonzero udp over ipv4 checksums (sum)
udp.bad_udp6_checksum: nonzero udp over ipv6 checksums (sum)
7.25 vlan
What: support for local area network
Type: codec
Usage: context
Rules:
116:130 (vlan) bad VLAN frame
Snort 3 User Manual 96 / 290
7.26 wlan
What: support for wireless local area network protocol (DLT 105)
Type: codec
Usage: context
Rules:
116:133 (wlan) bad 802.11 LLC header
116:134 (wlan) bad 802.11 extra LLC info
8 Connector Modules
Connectors support High Availability communication links.
8.1 file_connector
What: implement the file based connector
Type: connector
Usage: global
Configuration:
string file_connector.connector: connector name
string file_connector.name: channel name
enum file_connector.format: file format { binary | text }
enum file_connector.direction: usage { receive | transmit | duplex }
Peg counts:
file_connector.messages: total messages (sum)
8.2 tcp_connector
What: implement the tcp stream connector
Type: connector
Usage: global
Configuration:
string tcp_connector.connector: connector name
string tcp_connector.address: address
port tcp_connector.base_port: base port number
enum tcp_connector.setup: stream establishment { call | answer }
Peg counts:
tcp_connector.messages: total messages (sum)
Snort 3 User Manual 97 / 290
9 Inspector Modules
These modules perform a variety of functions, including analysis of protocols beyond basic decoding.
9.1 appid
What: application and service identification
Type: inspector
Usage: context
Configuration:
int appid.memcap = 0: disregard - not implemented { 0: }
bool appid.log_stats = false: enable logging of appid statistics
int appid.app_stats_period = 300: time period for collecting and logging appid statistics { 0: }
int appid.app_stats_rollover_size = 20971520: max file size for appid stats before rolling over the log file { 0: }
int appid.app_stats_rollover_time = 86400: max time period for collection appid stats before rolling over the log file { 0: }
string appid.app_detector_dir: directory to load appid detectors from
int appid.instance_id = 0: instance id - ignored { 0: }
bool appid.debug = false: enable appid debug logging
bool appid.dump_ports = false: enable dump of appid port information
addr appid.session_log_filter.src_ip = 0.0.0.0/32: source IP address in CIDR format
addr appid.session_log_filter.dst_ip = 0.0.0.0/32: destination IP address in CIDR format
port appid.session_log_filter.src_port: source port { 1: }
port appid.session_log_filter.dst_port: destination port { 1: }
string appid.session_log_filter.protocol: IP protocol
bool appid.session_log_filter.log_all_sessions = false: enable logging for all appid sessions
bool appid.log_all_sessions = false: enable logging of all appid sessions
9.2 arp_spoof
What: detect ARP attacks and anomalies
Type: inspector
Usage: inspect
Configuration:
ip4 arp_spoof.hosts[].ip: host ip address
mac arp_spoof.hosts[].mac: host mac address
Rules:
112:1 (arp_spoof) unicast ARP request
Snort 3 User Manual 98 / 290
112:2 (arp_spoof) ethernet/ARP mismatch request for source
112:3 (arp_spoof) ethernet/ARP mismatch request for destination
112:4 (arp_spoof) attempted ARP cache overwrite attack
Peg counts:
arp_spoof.packets: total packets (sum)
9.3 back_orifice
What: back orifice detection
Type: inspector
Usage: inspect
Rules:
105:1 (back_orifice) BO traffic detected
105:2 (back_orifice) BO client traffic detected
105:3 (back_orifice) BO server traffic detected
105:4 (back_orifice) BO Snort buffer attack
Peg counts:
back_orifice.packets: total packets (sum)
9.4 binder
What: configure processing based on CIDRs, ports, services, etc.
Type: inspector
Usage: inspect
Configuration:
int binder[].when.ips_policy_id = 0: unique ID for selection of this config by external logic { 0: }
bit_list binder[].when.ifaces: list of interface indices { 255 }
bit_list binder[].when.vlans: list of VLAN IDs { 4095 }
addr_list binder[].when.nets: list of networks
addr_list binder[].when.src_nets: list of source networks
addr_list binder[].when.dst_nets: list of destination networks
enum binder[].when.proto: protocol { any | ip | icmp | tcp | udp | user | file }
bit_list binder[].when.ports: list of ports { 65535 }
bit_list binder[].when.src_ports: list of source ports { 65535 }
bit_list binder[].when.dst_ports: list of destination ports { 65535 }
int binder[].when.src_zone: source zone { 0:2147483647 }