Tuesday, April 12, 2011

dns blacklist bash script

LISTS="sbl-xbl.spamhaus.org zen.spamhaus.org bl.spamcop.net dnsbl.njabl.org b.barracudacentral.org dnsbl.sorbs.net pbl.spamhaus.org"
HOSTS="1.2.3.4 127.0.0.1"

for list in $LISTS
do
for host in $HOSTS
do
W=$( echo ${host} | cut -d. -f1 )
X=$( echo ${host} | cut -d. -f2 )
Y=$( echo ${host} | cut -d. -f3 )
Z=$( echo ${host} | cut -d. -f4 )
result=`dig +short $Z.$Y.$X.$W.$list`
if [ "$result" != "" ]; then
echo "$host listed in $list"
fi
done
done

No comments:

Post a Comment