Add real-time blacklist status checking via DNS

- Performs DNS queries to check current listing status on RBLs
- Reverses server IP octets for proper RBL query format
- Uses dig with 3-second timeout for responsive checking
- Only checks traditional RBLs (Spamhaus, Barracuda, SpamCop, SORBS, CBL)
- Skips email provider checks (not queryable via DNS RBL)
- Shows LISTED/CLEAN status with response codes for detailed info
- Verifies if delisting was successful or if IP still blocked
- Gracefully handles timeouts and DNS failures

Response codes indicate:
- 127.0.0.2: SBL (Spamhaus blocklist)
- 127.0.0.3: CSS (Spamhaus CSS)
- 127.0.0.10: PBL (Policy Blocklist)
- Other codes: Varies by RBL provider

Feature validates:
1. If IP extraction succeeded from rejection messages
2. Checks current status on active traditional RBLs
3. Provides clear indication of listing status
4. Suggests next steps based on results

Users can now verify if their IP is CURRENTLY listed on each RBL,
allowing them to confirm delisting success or identify remaining issues.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
cschantz
2026-02-06 16:30:10 -05:00
parent 5ed473e1c1
commit b5c6e015b4
+83
View File
@@ -916,6 +916,89 @@ TEMPLATE
fi fi
done done
# Real-time blacklist status checking (if IP was extracted)
if [ -n "$extracted_ip" ]; then
echo ""
print_info " 🔍 REAL-TIME BLACKLIST STATUS CHECK:"
echo ""
echo " Checking current listing status for: $extracted_ip"
echo ""
# Function to check if IP is currently listed on a blacklist RBL
check_blacklist_listing() {
local ip="$1"
local rbl_host="$2" # e.g., zen.spamhaus.org
local rbl_name="$3" # e.g., Spamhaus
# Reverse the IP octets: 1.2.3.4 → 4.3.2.1
local reversed_ip=$(echo "$ip" | awk -F. '{print $4"."$3"."$2"."$1}')
# Query the RBL with a 3-second timeout
local query="${reversed_ip}.${rbl_host}"
local result=$(dig +short +timeout=3 "$query" A 2>/dev/null | head -1)
if [ -n "$result" ]; then
# IP is listed - return the response code
echo "LISTED:$result"
else
# IP is not listed
echo "CLEAN"
fi
}
# Parse RBL servers from blacklist entries and check each
echo -e "$detected_blacklists" | sort -u | while IFS='|' read -r bl_name bl_url bl_difficulty bl_time; do
if [ -n "$bl_name" ]; then
# Extract RBL hostnames from URLs or use common patterns
case "$bl_name" in
*Spamhaus*)
rbl_host="zen.spamhaus.org"
short_name="Spamhaus"
;;
*Barracuda*)
rbl_host="bl.barracudacentral.org"
short_name="Barracuda"
;;
*SpamCop*)
rbl_host="bl.spamcop.net"
short_name="SpamCop"
;;
*SORBS*)
rbl_host="dnsbl.sorbs.net"
short_name="SORBS"
;;
*CBL*)
rbl_host="cbl.abuseat.org"
short_name="CBL"
;;
*)
# Skip email providers (not traditional RBLs)
continue
;;
esac
# Check current status
status=$(check_blacklist_listing "$extracted_ip" "$rbl_host" "$short_name")
if [[ "$status" == "LISTED"* ]]; then
response_code=$(echo "$status" | cut -d: -f2)
print_error "$short_name: CURRENTLY LISTED"
echo " Response: $response_code (meaning: check RBL for code details)"
echo " Action: Submit delisting request if not already done"
else
print_success "$short_name: NOT LISTED (Clean)"
fi
fi
done
echo ""
echo " 📌 Status Check Notes:"
echo " • DNS lookups may be cached - results reflect current RBL state"
echo " • Some RBLs may not respond within timeout window"
echo " • Check removal URLs above for detailed delisting status"
echo ""
fi
rm -f "$TEMP_BLACKLISTS" rm -f "$TEMP_BLACKLISTS"
fi fi