Skip to content

Instantly share code, notes, and snippets.

@da667
Created March 27, 2025 17:17
Show Gist options
  • Save da667/541a81db7c02ba971945c0fd5c647ee9 to your computer and use it in GitHub Desktop.
Save da667/541a81db7c02ba971945c0fd5c647ee9 to your computer and use it in GitHub Desktop.
runs suricata-update, and provides ETOPEN rules to /opt/dalton/rulesets/suricata, and renames the .rules file to make it more descriptive
#!/usr/bin/env bash
#rule updater script
#runs suricata-update, drops a rule file in
#/opt/dalton/rulesets/suricata
#Then renames the rule file to reflect
#that it's the full ETOPEN ruleset, the date the
#rules were updated, and that its suricata 7.0.3
#drop this file into /etc/cron.daily|weekly|monthly
#as desired, and run chmod u+x rule-updater
#or cron (or the systemd equivlent) won't run it.
suricata-update --suricata-version 7.0.3 -f -o /opt/dalton/rulesets/suricata/
mv /opt/dalton/rulesets/suricata/suricata.rules /opt/dalton/rulesets/suricata/ETOPEN-`date +"%Y%m%d"`-all-Suricata-7.0.3.rules
logger suricata rule update completed
exit 0
@da667
Copy link
Author

da667 commented Mar 27, 2025

Hey folks, this is a small shell script that goes with my book suricata: an operator's guide that is a work in progress. Specifically, its an automation script for chapter 2, intended to provide new ETOPEN rules, by being dropped into /etc/cron.daily, /etc/cron.weekly, or /etc/cron.monthly as desired.

This script dumps a copy of the suricata 7.0.3 ETOPEN ruleset into a single .rules file in /opt/dalton/rulesets/suricata, then renames it to reflect its the ETOPEN ruleset, the day it was downloaded, and the version of suricata the syntax is based on. This script can also be called by /etc/crontab, or if you're using chrony, whatever methods it uses for executing scripts on a given interval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment