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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #!/bin/bash
# Date: Mar 20,2010
# Author: Ashwin Muni
# Purpose: Check the IP Against Major SPAM Sources.
## Uncomment to Debug
# set -x
# Variables
tmp_file='/tmp/dnsbl'
+ tmp_file=/tmp/dnsbl
#IN_DNSBL=127.0.0.[2-6]
#IN_DNSBL=127.0.0.
IN_DNSBL='127.0.0.2|127.0.0.3|127.0.0.4|127.0.0.5|127.0.0.6|127.0.0.7|127.0.0.8|127.0.0.9|127.0.0.10|127.0.0.'
+ IN_DNSBL='127.0.0.2|127.0.0.3|127.0.0.4|127.0.0.5|127.0.0.6|127.0.0.7|127.0.0.8|127.0.0.9|127.0.0.10|127.0.0.'
DIG=`which dig`
which dig
++ which dig
+ DIG=/usr/bin/dig
MAIL_ADMIN="test@example.com <a href="mailto:ashwin@linuxmaza.com">ashwin@linuxmaza.com</a>"
+ MAIL_ADMIN='test@example.com <a href="mailto:ashwin@linuxmaza.com">ashwin@linuxmaza.com</a>'
###################################################
# SCRIPT START
> $tmp_file
echo "Below IPs are Listed" >> $tmp_file
+ echo 'Below IPs are Listed'
if [ "$#" == 1 ]; then
for i in `cat rbllist.txt`; do
IP_REV=`echo $1 | awk -F\. '{ print $4"."$3"."$2"."$1 }'`
$DIG $IP_REV.$i | grep $IN_DNSBL
if [ $? == '0' ]; then
#echo "$1 Listed on $i"
echo -e "\033[31m \033[1m PROBLEM : Listed on $i \033[0m \033[22m"
echo "################################ Attention : $1 Listed on $i" >> $tmp_file
else
echo -e "Not Listed on $i : \033[32m \033[1m OK \033[22m \033[0m "
echo "$1 Not Listed on $i" >> $tmp_file
fi
done
echo -e "\033[31m \033[1m ===================$1 is LISTED ON BELOW SPAM SOURCES====================== \033[0m \033[22m"
cat $tmp_file | mail -s "DNSBL REPORT FOR $1" $MAIL_ADMIN
else
echo -e "\t\t\t\t\033[31m \033[1m Enter Proper Arguments:\n Script Usage :\n /bin/sh $0 IP.ADD.RE.SS \033[0m \033[22m"
# EOF |
Partager