#!/usr/bin/python # rbl-info.cgi - print information on a host listed in an rbl # Copyright (C) 2004 Gordon Messmer # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA import cgi import socket import string def revIP(ip): bytes = string.split(ip, '.') if len(bytes) != 4: return bytes.reverse() return '%s.%s.%s.%s' % tuple(bytes) def getRBL(ip, rblDomain): rip = revIP(ip) if not rip: return rblQuery = rip + '.' + rblDomain try: rblRR = socket.gethostbyname(rblQuery) except: return return rblRR request = cgi.FieldStorage() try: smtpHost = request['ip'].value rblDomain = request['rbl'].value rblHelp = request['info'].value # Strip off the IPv6 info for both display and lookup purposes. if len(smtpHost) > len('::ffff:') and smtpHost[:7] == '::ffff:': smtpHost = smtpHost[7:] rblStatus = getRBL(smtpHost, rblDomain) if rblStatus: rblStatusTextClass = 'positive' rblStatusText = '''The mail server at %s is listed in the %s DNS blacklist. See %s for more information.''' % (smtpHost, rblDomain, rblHelp, rblHelp) else: rblStatusTextClass = 'negative' rblStatusText = '''The mail server at %s is no longer listed in the %s DNS blacklist. You should now be able to send messages to RealNetworks, Inc. See %s for more information.''' % (smtpHost, rblDomain, rblHelp, rblHelp) except: # No CGI input rblStatusTextClass = 'negative' rblStatusText = '' print '''Content-type: text/html; charset=UTF-8 RBL Help

Why is my mail getting rejected?

RealNetworks, Inc. is currently using several RBLs to reduce the rate of incoming unsolicited commercial email (SPAM). These RBLs list mail servers which are known to be open relays, and commonly used to send spam.

%s

If your mail is being rejected, then you should alert whoever is responsible for your mail service immediately.

Email from your mail server will be blocked by any site who uses an RBL. The number of sites using RBL\'s is increasing rapidly, because they are an effective way to reduce spam.

''' % (rblStatusTextClass, rblStatusText)