@jeffschips
Mod-security is an efficient HTTP request parser.
It is designed to run in the Apache process of a single request, block or allow the request, then log what happened then exit as the process ends.
Configserver LFD is an efficient log file parser.
It is designed to search for and count patterns in log files, then respond by sending the IP address of a pattern match to CSF which manages adding IP entries to iptables.
LFD (login failure daemon) while its original purpose was to find login failure patterns in log files it is just as good finding other patterns in log files.
You seem to misunderstand the
LF_MODSEC settings.
Its comment says this...
[*]Enable failure detection of repeated Apache mod_security rule triggers
To get a permanent block in CSF the CSF settings should be...
MODSEC_LOG = /usr/local/apache/logs/error_log
LF_INTERVAL = 86400 ( No. of seconds over which to count. Default is 3600)
LF_MODSEC = 5 (Count of string "Modsecurity: Access denied" per ip for block action)
LF_MODSEC_PERM = 1 (0 = No blocking, 1 = Block Permanently, x = Block for x seconds except 1 or 0)
With these settings LFD searches /usr/local/apache/logs/error_log for log lines with the fragment "ModSecurity: Access denied". If 5 istances are found within the LF_INTERVAL for the same IP then that IP is sent to CSF to be added to the iptables firewall.
A modsecurity rule to make this work for a specific URL is as follows...
Code:
# Deny requests to this url
SecRule REQUEST_FILENAME "@contains my-funky-url" \
"msg:'Deny this funky URL',\
id:19000002,\
phase:1,\
t:none,\
log,\
auditlog,\
deny,\
status:403"
Or more compact...
Code:
SecRule REQUEST_FILENAME "@contains my-funky-url" "msg:'Deny this funky URL',id:19000002,phase:1,t:none,log,auditlog,deny,status:403"