Skip to content

Instantly share code, notes, and snippets.

@kimitoboku
Created June 30, 2015 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kimitoboku/4b6afda838d042c51e06 to your computer and use it in GitHub Desktop.
Save kimitoboku/4b6afda838d042c51e06 to your computer and use it in GitHub Desktop.
#! /bin/sh
sudo tail -f /var/log/apache2/p3/access.log | awk '{
d = sprintf("%s-%s",$1,$4)
if($1 ~ /::1/)
{
}else if(list[$1]=="done"){
}else if(!(d in data)){
data[d] = 0;
}else if(data[d] == 1){
c = sprintf("sudo iptables -I INPUT -s %s -j DROP", $1);
print c;
system(c);
close(c);
list[$1]="done";
}else{
data[d]++;
}
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment