How do you check if an ip address is blacklisted by one of the various DNS Blackhole Lists?
It's sort of easy, you reverse the address (say it was 1.2.3.4), and append the blacklist's address (say blacklist.example.net), and then do a dns lookup (of 4.3.2.1.blacklist.example.net). If the address is not found, chances are the blacklist hasn't heard of them, otherwise they're probably scum.
I've talked
about blocking these parasites before, so here's a chunk of code I use in
a few places to spot them. It's called
blacklist.py
and I think it's simple enough to use:
import blacklist
if blacklist.blacklisted("1.2.3.4") == 1:
print("scum")
else:
print("ok")
Update: Thanks to Blackie for spotting the typo in the above example (5 lines of code and I still make a mistake). Now fixed.