Last active
October 21, 2017 05:53
-
-
Save enonethreezed/c43ac78b25453bea50d0016d58a94353 to your computer and use it in GitHub Desktop.
This script will read from rsyslog pipe and block any IP (if desired) that does an unauthorized AXFR petition.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
somepipe=/var/log/rsyslog.pipe | |
while true | |
do | |
if read line <$somepipe | |
then | |
if grep -i --line-buffered -P '^(?=.*named)(?=.*cache)(?=.*denied)' $line; | |
then | |
offendingIP="$(grep -P '^(?=.*named)(?=.*cache)(?=.*denied)' $line | egrep '([0-9]{1,3}\.){3}[0-9]{1,3}')" | |
echo Your offending IP is $offendingIP | |
# AYOR | |
# iptables -A INPUT -i eth0 -s $offendingIP -j DROP | |
f | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment