Last active
August 29, 2015 14:24
-
-
Save 0x9900/143d2add4950ebceed23 to your computer and use it in GitHub Desktop.
This file contains hidden or 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/ksh | |
# | |
USAGE="Usage: dnsbl [-b] ipaddress" | |
set -A RBL_LST "zen.spamhaus.org" "bl.spamcop.net" \ | |
"b.barracudacentral.org" "cbl.abuseat.org" \ | |
"hostkarma.junkemailfilter.com" | |
if [[ $# < 1 || $# > 2 ]]; then | |
echo $USAGE | |
exit 1 | |
fi | |
if [[ $1 == "-b" ]]; then | |
BLOCK=1 | |
shift | |
fi | |
if [[ $# != 1 ]]; then | |
echo $USAGE | |
exit 1 | |
fi | |
ip=${1} | |
revip=$(IFS=.; set -- $ip ; echo "${4}.${3}.${2}.${1}") | |
for rbl_server in ${RBL_LST[@]}; do | |
result=$(dig +short "${revip}.${rbl_server}") | |
if echo ${result} | grep -q "127\.0\.0\.2"; then | |
[[ $BLOCK == 1 ]] && { | |
sudo spamdb -t -a $ip | |
echo -n "blocking " | |
} | |
echo -n "${ip} found on ${rbl_server}\n" | |
break | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment