-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrbl.sh
84 lines (76 loc) · 2.62 KB
/
rbl.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
## DNSBL Bulk Checker
## Developed By: SplitIce <https://www.x4b.net>
## Free for commercial & Non-commercial use or whatever, just dot sue me.
##
## Usage:
## ./rbl.sh listcheck - Verify that all DNSBLS in the list are responding within a reasonable time (online)
## ./rbl.sh details [ip1] [...] - Fetch details for all RBL entries for one or many IP addresses
## ./rbl.sh count [ip1] [...] - Fetch a total count of RBL entries for many IP addresses
DIR=$(dirname $0)
RBL=$DIR/rbl_list.txt
ADNS_CMD=$(type -a adnshost | awk '{print $3}')
DIG_CMD=$(type -a dig | awk '{print $3}')
function process_ip {
if [[ $1 == */* ]]; then
echo "$(prips $1)"
else
echo "$1"
fi
}
if [[ $1 == "check" ]]; then
$DIG_CMD +short +time=1 +tries=2 $2 | grep "127.0.0."
elif [[ $1 == "listcheck" ]]; then
RBL_C=$(cat "$RBL" | grep -v "#")
while read -r var; do
if [[ $(dig 1.1.1.1.$var +time=1 2>&1 | grep timed | wc -l) == "1" ]]; then
echo "$var timed out"
fi
done <<< "$RBL_C"
elif [[ $1 == "detailscheck" ]]; then
echo "Performing detailed lookup for $2"
RBL_C=$(cat "$RBL" | grep -v "#")
W=$( echo $2 | cut -d. -f1 )
X=$( echo $2 | cut -d. -f2 )
Y=$( echo $2 | cut -d. -f3 )
Z=$( echo $2 | cut -d. -f4 )
while read -r var; do
CHECK=$($DIG_CMD +short $Z.$Y.$X.$W.$var | grep "127.0.0." | wc -l)
if [[ $CHECK -gt 0 ]]; then
REASON=$($DIG_CMD +short $Z.$Y.$X.$W.$var TXT)
echo "$i blacklisted on $var for: $REASON"
fi
done <<< "$RBL_C"
elif [[ $1 == "details" ]]; then
for var_i in "${@:2}"
do
echo "$(process_ip $var_i)" | parallel --max-procs 100 bash "$0" detailscheck {}
done
elif [[ $1 == "count" ]]; then
COUNT=0
RBL_C=$(cat "$RBL" | grep -v "#")
JOBS=""
for var_i in "${@:2}"
do
while read -r var; do
W=$( echo $var | cut -d. -f1 )
X=$( echo $var | cut -d. -f2 )
Y=$( echo $var | cut -d. -f3 )
Z=$( echo $var | cut -d. -f4 )
R=$(echo "$RBL_C" | sed -e "s/^/$Z.$Y.$X.$W./g")
JOBS="$JOBS$R"
done <<< "$(process_ip $var_i)"
done
if [ -z $ADNS_CMD ]; then
echo "$JOBS" | parallel --max-procs 15 $DIG_CMD +short +time=1 +tries=2 {} | grep "127.0.0." | wc -l
else
adnshost --quiet -a $(echo "$JOBS" | tr "\\n" " ") | grep "127.0.0." | wc -l
fi
else
echo "Usage:"
echo "$0 listcheck - Verify that all DNSBLS in the list are responding within a reasonable time (online)"
echo "$0 details [ip1] [...] - Fetch details for all RBL entries for one or many IP addresses"
echo "$0 count [ip1] [...] - Fetch a total count of RBL entries for many IP addresses"
echo ""
echo "IP address can be either a single address or network in CIDR form"
fi