14 Commits

Author SHA1 Message Date
John Audia
69117bf2d5 snort3: run as regular user rather than as root
Running as a dedicated user is better from both a security and an
isolation perspective than running as root.

Signed-off-by: John Audia <therealgraysky@proton.me>
2025-10-17 22:31:54 +03:00
Eric Fahlgren
a636371c5e snort3: improve date filtering in report
- Take advantage of bug fix in jsonfilter to get rid of array hack, should
   improve memory footprint quite a bit

 - Implement substring matching in dates so you can collect data for a specific
   day, hour or run bin reports for histograms

 - Report title now contains specified date range, footer percentages

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-06-25 10:03:07 -07:00
Eric Fahlgren
c8b13adaa0 snort3: fix bug with unset variable
- Parameter not set in two places:
    /usr/bin/snort-mgr: eval: line 125: options: parameter not set

Reported-by: @klingon888
Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-04-27 12:28:14 +02:00
Eric Fahlgren
4ce2d741c6 snort3: fix issue caused by ucode semantics change
A recent change in the ucode interpeter caused a failure when using
the 'in' operator.
be767ae197

Reported in a forum post by @graysky2.
https://forum.openwrt.org/t/194218/28

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-04-13 13:22:40 +08:00
Eric Fahlgren
db58c9cd81 snort3: clean up ucode usage
- Add missing 'ucode' package dependency
 - Proto-ify the ConfigItem objects
 - Fix indentation and tab usage

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-02-14 12:53:28 +08:00
Eric Fahlgren
b94c6dd37d snort3: improve script reliability
- Enable missing variable checking by default
 - Explicitly check variables are defined in all 'rm' commands

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-02-07 14:01:11 -08:00
Eric Fahlgren
203e9413e2 snort3: finish up several incomplete capabilities
Reporting
 - Use json alert data for 10x speed improvement in report generation
 - Include both gid and sid, plus packet direction in report output
 - Add by-date incident filtering
 - Add verbose mode which displays actual rules triggered and their source
 - Attempt to look up host names from IPs in verbose mode
 - Clean up display of port number involved in incidents

Rules
 - Complete downloader for subscription rules using oinkcode (only tested
   with snort.org's "free" tier subscription)
 - Auto-detect multiple rules files and include them in lua 'ips.rules'
 - Add '--backup' option to copy out current rules before installing new
 - Add '--persistent' option to 'snort-rules', storing in persistent location

CLI interface
 - Completely rework command line option parsing in all user scripts
 - Allow options and commands to be in any order on command line
 - Add long-form names for all options ('--help' for '-h' and so on)
 - Detect errors properly in options, enhance help pages

Bug fixes
 - Use 'mkdir -p' on all directory creation
 - Use proper tmp directory from 'snort.snort.temp_dir' everywhere

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-02-04 16:21:11 -08:00
Eric Fahlgren
e05835deac snort3: add missing action-override option
Allow use of rules as-defined, and don't override their actions.  This
is generally the best way to use the ruleset, and overriding their
actions should only be undertaken when you fully understand how it
affects their use.

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2024-01-02 15:29:50 -08:00
Eric Fahlgren
0d2dac8792 snort3: add missing config include and general cleanup
- Delete legacy configuration files homenet.lua and local.lua
- Add snort config 'include' to allow user customizations in the lua
- Enhance 'check' to test generated nftables file
- Suppress inclusion of rules file when doing silent config check
- Suppress warnings on configuration check unless '-v'erbose
- Replace text logging with json logging to reduce footprint and make reports easier
- Fix some typos in the snort.uc template
- Fix up some error messages suggesting solutions

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2023-12-16 22:08:49 +08:00
Eric Fahlgren
f21dffc2a3 snort3: complete rework
- Add many options to config file.
  - Move rules and generated snort.lua to /tmp.
  - Add script for downloading rules.
  - Add preliminary reporting capabilites.

Signed-off-by: Eric Fahlgren <ericfahlgren@gmail.com>
2023-12-03 13:53:58 -08:00
John Audia
0c1425f8fe snort3: minor tweaks to local.lua
* Use Boolean true for enable inline mode which is more intuitive that older ''
* Add skeleton section for openappid since it has been merged[1]

1. 2d4e7d5fd3

Signed-off-by: John Audia <therealgraysky@proton.me>
2022-12-22 16:27:40 -08:00
John Audia
d6b712cde6 snort3: unified configs: local.lua and homenet.lua
This commit adds /etc/snort/local.lua and /etc/snort/homenet.lua for user
defined config options which is more simplistic than modifying upstream
files directly. That can be tedious and decisive to maintain in sync with
upstream changes.  The init script has been adjusted accordingly.

Acknowledgment to amish who maintains the Arch Linux snort-nfqueue package[1]
for these ideas and initial code.

Another modification is dropping the following args in the call to
/usr/bin/snort by the init system as these options are provided in
/etc/snort/local.lua:

 * --daq-dir /usr/lib/daq/
 * -A "$alert_module"

Instructions to configure snort3:
1. Edit /etc/snort/homenet.lua and redefine HOME_NET and EXTERNAL_NET, for example:

   HOME_NET = [[ 10.9.8.0/24 192.168.1.0/24 ]]
   EXTERNAL_NET = "!$HOME_NET"

2. Edit /etc/snort/local.lua to setup options unique to your use case of snort.
   The default ones I included should be sane for the role of IDS (alert only),
   but users may easily uncomment some options therein to use IPS (drop) mode.

3. Install or symlink rules to /etc/snort/rules/snort.rules and optionally
   edit /etc/snort/local.lua to define extra rules files if not using a unified
   'snort.rules'

References:
1. https://aur.archlinux.org/packages/snort-nfqueue

Signed-off-by: John Audia <therealgraysky@proton.me>
2022-12-08 04:47:38 +08:00
Michal Hrusecky
2fe854ebd6 net/snort3: Include default configs and snort2lua
Include default configuration files to have something to start from.
Also include snort2lua to help convert snort2 rules to snort3 to also
help with bootstrapping the configuration.

Signed-off-by: Michal Hrusecky <michal.hrusecky@turris.com>
2021-07-22 13:55:38 +02:00
W. Michael Petullo
53df351850 snort3: new package
Signed-off-by: W. Michael Petullo <mike@flyn.org>
2019-03-30 14:10:20 -04:00