Are you looking for someone to write the script for you? Looking for an algorithm (sounds like you already have one)? Looking for validation that your plan is a good idea? Or looking for something else?
It seems to me you've pretty much got a handle on what you want and even to some extent on how you want to do it. The only thing missing is the top of the bash script
Code:
#!/bin/bash
###
# My simple cracker detector and banner script
# runs from crontab every 5 minutes
# compares the last 100 lines of the vsftp.log to find
# matches of 5 subsequent fails within those last 100 lines and activates a
# dynamic block in iptables (not a permanent rule)
###
Following that, you can start in with your
Code:
tail -100
command to capture the end of the file (probably redirecting the output to file or piping it to something like grep or awk).
I might do something like this (though my syntax may be incorrect for the awk part - reading the man page for awk would be useful if not boring):
Code:
tail -100 vsftp.log | grep 'FAIL LOGIN' | awk '{print $12}' | sort > /tmp/failedips
# read in /tmp/failedips and compare each entry to the next keeping count to 5 and
# banning that IP if the count of 5 is reached for a single IP address.
Unfortunately I don't know bash well enough to write the loop part that reads in the /tmp/failedips file and compares each value with the previously-stored one.
I'd actually write that part in a Perl script and call the Perl from this bash script.

But that's just because I'm more comfortable with Perl for complicated bits of logic -- I know bash can do it and maybe someone else can help you out where I've left off.
Hope this helps!
[/code]