Eliminate Spam Now... >g< Python w/DNS/&POP3
Sheila King
usenet at thinkspot.net
Sun Mar 17 18:53:57 EST 2002
On Sun, 17 Mar 2002 21:56:15 GMT, Benjamin Schollnick
<junkster at rochester.rr.com> wrote in comp.lang.python in article
<junkster-2D9783.16561617032002 at typhoon4-3.nyroc.rr.com>:
> Folks,
>
> I'm running into a slight problem...
>
> I'm attempting to use the (py)DNSlib (sourceforge project), to look
> up Spammers via ORBZ (or similiar group)...
>
> And I'm able to pull up the DNS information, but every entry I try
> response with a valid root level DNS entry.... Can anyone enlighten me
> regarding the operations of the black hole lists? I can't seem to find
> any of the sights that explain the actual functionality.
>
> (I've tried reversing the octets [i.e. 13.175.214.14 ==
> 14.214.175.13], with no luck)
>
> = Benjamin
This will do it for you. Note that I'm using the Spamcop black hole list,
but you can use any one you want:
import socket
def IP_in_bl(host, IPaddy):
IPquads = IPaddy.split('.')
IPquads.reverse()
reverseIP = '.'.join(IPquads)
IPlookup = "%s.%s" % (reverseIP, host)
try:
resolvesIP = socket.gethostbyname(IPlookup)
if resolvesIP.startswith('127.'):
return 1
except socket.gaierror:
return 0
###############################
#
# begin main test program
#
###############################
IPaddy = '211.192.182.125'
host = 'bl.spamcop.net'
if IP_in_bl(host, IPaddy):
print "OPEN RELAY!!!"
else:
print "not a known Open Relay."
--
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/
More information about the Python-list
mailing list