Compare commits
3 Commits
df0f552ef2
...
19ddf883ee
Author | SHA1 | Date | |
---|---|---|---|
|
19ddf883ee | ||
|
c64617f937 | ||
|
4a28125ee2 |
@ -16,7 +16,7 @@ To deploy:
|
|||||||
|
|
||||||
3. Create the user the scripts will run as:
|
3. Create the user the scripts will run as:
|
||||||
|
|
||||||
useradd -s /sbin/nologin _forumspam
|
useradd -s $(which nologin) _forumspam
|
||||||
|
|
||||||
4. Set up the firewall program
|
4. Set up the firewall program
|
||||||
|
|
||||||
|
@ -2,14 +2,18 @@
|
|||||||
|
|
||||||
logf='/var/log/nginx/access.log'
|
logf='/var/log/nginx/access.log'
|
||||||
cache='/tmp/forumspam_cache'
|
cache='/tmp/forumspam_cache'
|
||||||
tail_opts='-F' # set to `-f` on OpenBSD!
|
|
||||||
|
case `uname` in
|
||||||
|
(*"BSD"*) tail_opts='-f';;
|
||||||
|
(*) tail_opts='-F';;
|
||||||
|
esac
|
||||||
|
|
||||||
test -f $cache || install -m 600 /dev/null $cache
|
test -f $cache || install -m 600 /dev/null $cache
|
||||||
|
|
||||||
tail $tail_opts $logf | while read line ; do
|
tail $tail_opts $logf | while read line ; do
|
||||||
case $line in (*"POST"*)
|
case $line in (*"POST"*)
|
||||||
ip=`echo $line | awk '{print $1}'`
|
ip=`echo $line | awk '{print $1}'`
|
||||||
ip_regex=`echo $ip | sed 's/\./\\./g'`
|
ip_regex=`echo $ip | sed 's/\./\\./g; s/^/^/; s/$/$/'`
|
||||||
if ! grep -q $ip_regex $cache; then
|
if ! grep -q $ip_regex $cache; then
|
||||||
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
|
/usr/local/bin/forumspam.sh "$ip" && echo $ip >> $cache
|
||||||
fi
|
fi
|
||||||
|
Reference in New Issue
Block a user