Skip to content

Commit d50cf78

Browse files
committed
added support for listing by CIDR and added concurrency to details action
1 parent 6dba938 commit d50cf78

1 file changed

Lines changed: 34 additions & 19 deletions

File tree

rbl.sh

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,21 @@
44
## Developed By: SplitIce <https://www.x4b.net>
55
## Free for commercial & Non-commercial use or whatever, just dot sue me.
66
##
7-
## Usage:
7+
## Usage:
88
## ./rbl.sh listcheck - Verify that all DNSBLS in the list are responding within a reasonable time (online)
99
## ./rbl.sh details [ip1] [...] - Fetch details for all RBL entries for one or many IP addresses
1010
## ./rbl.sh count [ip1] [...] - Fetch a total count of RBL entries for many IP addresses
1111

1212
RBL=rbl_list.txt
1313

14+
function process_ip {
15+
if [[ $1 == */* ]]; then
16+
echo "$(prips $1)"
17+
else
18+
echo "$1"
19+
fi
20+
}
21+
1422
if [[ $1 == "check" ]]; then
1523
dig +short +time=1 +tries=2 $2 | grep "127.0.0."
1624
elif [[ $1 == "listcheck" ]]; then
@@ -21,42 +29,49 @@ elif [[ $1 == "listcheck" ]]; then
2129
echo "$var timed out"
2230
fi
2331
done <<< "$RBL_C"
24-
elif [[ $1 == "details" ]]; then
32+
elif [[ $1 == "detailscheck" ]]; then
2533
echo "Performing detailed lookup for $2"
26-
RBL_C=$(cat "$RBL" | grep -v "#")
2734

28-
for i in "${@:2}"; do
29-
W=$( echo $i | cut -d. -f1 )
30-
X=$( echo $i | cut -d. -f2 )
31-
Y=$( echo $i | cut -d. -f3 )
32-
Z=$( echo $i | cut -d. -f4 )
35+
RBL_C=$(cat "$RBL" | grep -v "#")
36+
W=$( echo $2 | cut -d. -f1 )
37+
X=$( echo $2 | cut -d. -f2 )
38+
Y=$( echo $2 | cut -d. -f3 )
39+
Z=$( echo $2 | cut -d. -f4 )
3340

34-
while read -r var; do
35-
CHECK=$(dig +short $Z.$Y.$X.$W.$var | grep "127.0.0." | wc -l)
41+
while read -r var; do
42+
CHECK=$(dig +short $Z.$Y.$X.$W.$var | grep "127.0.0." | wc -l)
3643

37-
if [[ $CHECK -gt 0 ]]; then
44+
if [[ $CHECK -gt 0 ]]; then
3845
REASON=$(dig +short $Z.$Y.$X.$W.$var TXT)
3946
echo "$i blacklisted on $var for: $REASON"
40-
fi
41-
done <<< "$RBL_C"
42-
done
47+
fi
48+
done <<< "$RBL_C"
49+
elif [[ $1 == "details" ]]; then
50+
for var_i in "${@:2}"
51+
do
52+
echo "$(process_ip $var_i)" | parallel --max-procs 100 bash "$0" detailscheck {}
53+
done
4354
elif [[ $1 == "count" ]]; then
4455
COUNT=0
4556
RBL_C=$(cat "$RBL" | grep -v "#")
4657

47-
for var in "${@:2}"
58+
for var_i in "${@:2}"
4859
do
60+
while read -r var; do
4961
W=$( echo $var | cut -d. -f1 )
5062
X=$( echo $var | cut -d. -f2 )
5163
Y=$( echo $var | cut -d. -f3 )
5264
Z=$( echo $var | cut -d. -f4 )
5365
R=$(echo "$RBL_C" | sed -e "s/^/$Z.$Y.$X.$W./g" | parallel --max-procs 100 bash "$0" check {} | wc -l)
5466
let "COUNT=R+COUNT"
67+
done <<< "$(process_ip $var_i)"
5568
done
5669
echo $COUNT
5770
else
58-
echo "Usage:"
59-
echo "$0 listcheck - Verify that all DNSBLS in the list are responding within a reasonable time (online)"
60-
echo "$0 details [ip1] [...] - Fetch details for all RBL entries for one or many IP addresses"
61-
echo "$0 count [ip1] [...] - Fetch a total count of RBL entries for many IP addresses"
71+
echo "Usage:"
72+
echo "$0 listcheck - Verify that all DNSBLS in the list are responding within a reasonable time (online)"
73+
echo "$0 details [ip1] [...] - Fetch details for all RBL entries for one or many IP addresses"
74+
echo "$0 count [ip1] [...] - Fetch a total count of RBL entries for many IP addresses"
75+
echo ""
76+
echo "IP networks in CIDR form may also be specified"
6277
fi

0 commit comments

Comments
 (0)