forked from jvehent/Postscreen-Stats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbl-check.sh
executable file
·51 lines (51 loc) · 2.06 KB
/
rbl-check.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -u
# Replace the SRV list with your own machines' full Internet DNS names
SRV="localhost"
# Build up the RBL list using the bash += append operator
RBL="bl.spamcop.net b.barracudacentral.org zen.spamhaus.org "
RBL+="dnsbl.sorbs.net spam.dnsbl.sorbs.net truncate.gbudb.net all.s5h.net "
RBL+="dnsbl-1.uceprotect.net dnsbl-2.uceprotect.net dnsbl-3.uceprotect.net "
RBL+="bl.spamcannibal.org psbl.surriel.com ubl.unsubscore.com db.wpbl.info "
RBL+="all.spamrats.com rbl.megarbl.net srnblack.surgate.net "
RBL+="dnsbl.inps.de drone.abuse.ch httpbl.abuse.ch korea.services.net "
RBL+="short.rbl.jp virus.rbl.jp spamrbl.imp.ch wormrbl.imp.ch virbl.bit.nl "
RBL+="ips.backscatterer.org spamguard.leadmon.net dnsbl.tornevall.org "
RBL+="ix.dnsbl.manitu.net tor.dan.me.uk bad.psky.me rbl.efnetrbl.org "
RBL+="dnsbl.dronebl.org access.redhawk.org "
RBL+="rbl.interserver.net query.senderbase.org bogons.cymru.com "
# Other DNSbl lists: free.v4bl.org hostkarma.junkemailfilter.com
for server in $SRV
do
# Resolve the DNS name into an Internet IP address
ip=$(dig +short $server | grep -E "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$")
# Testing IP address = 127.0.0.2
#ip="127.0.0.2"
# Reverse the IP address octets for DNSbl check format
r_ip=$(echo "$ip" | awk -F"." '{for(i=NF;i>0;i--) printf i!=1?$i".":"%s",$i}')
for rbl in $RBL
do
if [ "$#" -gt 0 ]
then
echo "testing $server ($ip) against $rbl"
fi
result=$(dig +short "$r_ip"."$rbl")
if [ ! -z "$result" ]
then
# Some DNSbls return multiple results, change newlines to spaces
echo -n "$server ($ip) is in $rbl with result ${result//$'\n'/ }"
# Also try to get any TXT DNS records
text=$(dig +short "$r_ip"."$rbl" TXT)
if [ ! -z "$text" ]
then
echo " and text ${text//$'\n'/ }"
else
echo ""
fi
fi
if [[ "$#" -gt 0 && -z "$result" ]]
then
echo "\`->negative"
fi
done
done