Skip to content

Instantly share code, notes, and snippets.

@whitekid
Created May 16, 2013 05:06
Show Gist options
  • Save whitekid/5589530 to your computer and use it in GitHub Desktop.
Save whitekid/5589530 to your computer and use it in GitHub Desktop.
moinmoin에 계정 생성을 지속적으로 하는 그 아이피 차단하는 스크립트
#!/usr/local/bin/bash
patterns+='?action=newaccount '
access_file='/usr/local/www/wiki/.htaccess'
ips_tmp=`mktemp`
trap 'on_exit; exit' SIGINT SIGQUIT EXIT
function on_exit(){
rm -f $ips_tmp
}
for pattern in $patterns; do
grep "$pattern" /var/log/httpd-access.log | awk '{print $1}' | awk '{print $1"."$2"."$4}' FS=. >> $ips_tmp
done
ips=`sort $ips_tmp | uniq | tr '\n' ' '`
if [ -w $access_file ]; then
cat > $access_file <<EOF
Order deny,allow
Deny from $ips
EOF
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment