Compare commits
No commits in common. "19ddf883ee7c63db26d817a3c24a837ab4e21f74" and "df0f552ef290b6d5f1ad51d1fa4fd348c4950c62" have entirely different histories.
19ddf883ee
...
df0f552ef2
@ -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 $(which nologin) _forumspam
|
useradd -s /sbin/nologin _forumspam
|
||||||
|
|
||||||
4. Set up the firewall program
|
4. Set up the firewall program
|
||||||
|
|
||||||
|
@ -2,18 +2,14 @@
|
|||||||
|
|
||||||
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; s/^/^/; s/$/$/'`
|
ip_regex=`echo $ip | sed 's/\./\\./g'`
|
||||||
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