Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

rbl interface in python (spamming)?

1 view
Skip to first unread message

per...@my-deja.com

unread,
Nov 13, 2000, 3:00:00 AM11/13/00
to
Hello:

Looking for a python module that talks to RBL

Thanks,

-- Niranjan


Sent via Deja.com http://www.deja.com/
Before you buy.

Paul Wright

unread,
Nov 15, 2000, 3:00:00 AM11/15/00
to
In article <8upo9e$jrp$1...@nnrp1.deja.com>, <per...@my-deja.com> wrote:
>Looking for a python module that talks to RBL

The RBL just uses a DNS zone. To look see if IP address a.b.c.d is in
the RBL, look up d.c.b.a.rbl.maps.vix.com. If it exists, that host is in
the RBL. You can do DNS lookups using the gethostbyname function in the
socket module. Here's an example:

import string
import socket

def is_in_rbl (ip, rbl_domain = "rbl.maps.vix.com"):

l = string.split (ip, ".")
l.reverse ()
lookup_host = string.join (l, ".") + "." + rbl_domain
try:
addr = socket.gethostbyname (lookup_host)
except socket.error:
addr = ''

# Some RBL-like lists use the returned addr to signify something,
# so we'll return it.
return addr

if __name__ == "__main__":
if is_in_rbl ("127.0.0.2"):
print "127.0.0.2 is in the RBL."

if is_in_rbl ("127.0.0.2", "relays.orbs.org"):
print "127.0.0.2 is in the ORBS."
# Cut here

What I think would be really cool is an automated spam reporting helper
using Python. There's one in Perl but I can't help thinking Python would
be easier to extend, and to add a GUI too and so on. Maybe I'll write
one.

--
----- Paul Wright ------| 12. The Enterprise visits an earth-type planet
-paul....@pobox.com--| called "Paradise" where everyone is happy all of
http://pobox.com/~pw201 | the time. However, everything is soon revealed to
| be exactly what it seems.

0 new messages