Last active
September 21, 2016 21:33
-
-
Save nixjobin/9085cf99c2696f44010b to your computer and use it in GitHub Desktop.
rblcheck-jobnix.sh
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 | |
#Author : Jobin Joseph | |
#Website : JobinJoseph.com | |
# You can copy this script in /etc/cron.hourly or via a crontab entry. | |
# This script will list the available / configured IPs on the server and will check against 40+ RBLs. | |
# Thanks to rbl-check.org for the API | |
JBIPS=/tmp/blacklistedip | |
#checking against RBL's | |
for JIP in `ifconfig|grep "inet addr" |awk '{print $2}'|cut -d":" -f2 |egrep -v "^10\.|^127\."` ; do | |
JOP=`curl http://rbl-check.org/rbl_api.php?ipaddress=$JIP |egrep -v "notlisted|INPS" | grep -i "listed"` | |
if [ $? -eq 0 ] ; then | |
touch $JBIPS | |
echo "$JIP" >> $JBIPS | |
echo "===============" >> $JBIPS | |
echo $JOP | tr ";" " " >> $JBIPS | |
echo -e >> $JBIPS | |
else | |
echo "IP $JIP is safe" | |
fi | |
done | |
#Send email if IPs in blacklist | |
if [ -e $JBIPS ] ; then | |
cat $JBIPS | mail -s "[ALERT] - `hostname` IPs is in RBL list" your-email-id@gmail.com | |
rm -f $JBIPS | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment