another clumsy hack

Seeing a lot of junk that looks spammy, so this is a first cut at denying them whatever they are looking for.

#!/usr/local/bin/bash
cat /usr/local/www/data-dist/.htaccess.base > /usr/local/www/data-dist/.htaccess.tmp
grep "Successfully fetched" /var/log/httpd/httpd-error.log | awk '{ print $8 }' | cut -d"." -f1,2,3 | >> /usr/local/www/data-dist/.htaccess.dyn
sort -n /usr/local/www/data-dist/.htaccess.dyn | uniq | awk '{ print "Deny from "$1"." }' >> /usr/local/www/data-dist/.htaccess.tmp
cp /usr/local/www/data-dist/.htaccess.tmp /usr/local/www/data-dist/.htaccess

Leave a Reply

Your email address will not be published. Required fields are marked *