Here is v2 of the script
scfanalyzerv2.sh — Changelog
v3.04-py36
- Major performance improvement: scan time reduced from ~3 seconds to ~0.10 seconds for ~1,000 entries.
- Reworked subnet/IP detection to avoid repeated full-file scans.
- Added proper IPv4 and IPv6 subnet handling, including compressed IPv6 addresses.
- Detects IPs already covered by existing subnet blocks.
- Keeps automatic /24 and /64 blocks temporary by adding timestamps instead of # do not delete.
- Manual # do not delete entries remain protected.
- Added atomic csf.deny rewrite for safer FIX operations.
- Backup must succeed before FIX continues.
- Keeps only the 10 newest csf.deny backups.
- Added protection against csf.deny changing during processing.
- Preserves comments, blank lines, and special CSF entries.
- Improved duplicate and redundant-entry handling.
- Added Python 3.6 compatibility for older CWP systems.
- Quiet CSF reload: hides normal firewall reload spam.
- CSF reload output is shown automatically only if reload fails.
- Improved help/version output and general error handling.
- Tested successfully with ANALYZE → FIX → ANALYZE on a live CWP/CSF deny list.
DOWNLOAD v2