forked from nixjobin/rbl-checker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnixhive-rblchecker.sh
37 lines (29 loc) · 952 Bytes
/
nixhive-rblchecker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#Author : Jobin Joseph
#Bio : JobinJoseph.com
#Blog : www.nixhive.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
JMAIL="[email protected]"
#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" $JMAIL
rm -f $JBIPS
fi
exit 0