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
Help
Print the help summary:
snort --helpGet help on a specific module ("stream", for example):
snort --help-module streamGet help on the "-A" command line option:
snort --help-options AGrep for help on threads:
snort --help-config | grep threadOutput help on "rule" options in AsciiDoc format:
snort --markup --help-options ruleNote: Snort++ stops reading command-line options after the "--help-*" and "--list-*" options, so any other options should be placed before them.
Sniffing and Logging
Read a pcap:
snort -r /path/to/my.pcapDump the packets to STDOUT:
snort -r /path/to/my.pcap -K textDump packets with application data and layer 2 headers
snort -r /path/to/my.pcap -K text -d -eNote: Command line options must be specified separately. "snort -de" won't work. You can still concatenate options and their arguments, however, so "snort -Ktext" will work.
Dump packets from all pcaps in a directory:
snort --pcap-dir /path/to/pcap/dir --pcap-filter '*.pcap' -K text -d -eLog packets to a directory:
snort --pcap-dir /path/to/pcap/dir --pcap-filter '*.pcap' -K pcap \ -l /path/to/log/dir
Configuration
Validate a configuration file:
snort -c $my_path/etc/snort/snort.luaValidate a rules file and a configuration file:
snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample.rulesRead rules from stdin and validate:
snort -c $my_path/etc/snort/snort.lua --stdin-rules < \ $my_path/etc/snort/sample.rulesEnable warnings for Lua configurations and make warnings fatal:
snort -c $my_path/etc/snort/snort.lua --warn-all --pedanticTell Snort++ where to look for additional Lua scripts:
snort --script-path /path/to/script/dir
IDS Mode
Run Snort++ in IDS mode, reading packets from a pcap:
snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample.rules \ -r /path/to/my.pcapLog any generated alerts to the console using the "-A" option:
snort -c $my_path/etc/snort/snort.lua -R $my_path/etc/snort/sample.rules \ -r /path/to/my.pcap -A alert_fullAdd 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 \ --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
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:
Log to unified in the current directory:/[ ][ ][ ]
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A unified2Log 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 take2Log to unified in /tmp:
snort -c $my_path/etc/snort/snort.lua -r /path/to/my.pcap -A unified2 \ -l /tmpRun 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 unified2Run 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-subdirNOTE: 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.
Shell
You must build with --enable-shell to make the command line shell available.
Enable shell mode:
snort --shellYou 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 --pauseIn 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 12345The command line interface is still under development. Suggestions are welcome.
Signals
The following examples assume that Snort++ is currently running and has a process ID of
Modify and Reload Configuration:
echo 'suppress = { { gid = 1, sid = 2215 } }' >> $my_path/etc/snort/snort.lua kill -hupDump stats to stdout:
kill -usr1Shutdown normally:
kill -termExit without flushing packets:
kill -quitList available signals:
snort --help-signalsNote: The available signals may vary from platform to platform.