Couple of things comes to my mind:
- You could use string-match with iptables:
iptables -A INPUT -m string --algo bm --string "GET /foro" -j DROP
or if possible in your system, with TARPIT
iptables -A INPUT -m string --algo bm --string "GET /foro" -j TARPIT
- Instead of using fail2ban, make your own script which scans for logs last 1000 lines for example and blocks matches with ipsets.
Add this to your iptables script:
- ipset destroy toilet
- ipset -N toilet iphash
- ipset flush toilet
Then use your script to add ip addresses which you want to block to text file. Eventually you just need to loop all the ip addresses to that toilet-list.
- ipset -A toilet "$ipaddress"
Using ipset and especially masks are much more efficient way than blocking ip addresses. I have around 20 000 addresses blocked and around 200 networks.
You might get some ideas of my very very messy script.
https://pastebin.com/4v5se0kh
I know it is messy, but it works for me much faster and is much easier than fail2ban. I named that script suc2ban. You just need to find your own matches for your logfile (you probably have apache access.log, instead of my example which uses auth.log).