Showing posts with label perl ip RBL. Show all posts
Showing posts with label perl ip RBL. Show all posts

Saturday, April 26, 2008

RBL Check

This will check to see if a given IP address exists in the various (free) RBL's in service.

#!/usr/bin/perl
use Net::DNS;

%list = (
'sbl-xbl.spamhaus.org' => 'http://www.spamhaus.org',
'pbl.spamhaus.org' => 'http://www.spamhaus.org',
'bl.spamcop.net' => 'http://www.spamcop.net',
'dsn.rfc-ignorant.org' => 'http://www.rfc-ignorant.org',
'postmaster.rfc-ignorant.org' => 'http://www.rfc.ignorant.org',
'abuse.rfc-ignorant.org' => 'http://www.rfc.ignorant.org',
'whois.rfc-ignorant.org' => 'http://www.rfc.ignorant.org',
'ipwhois.rfc-ignorant.org' => 'http://www.rfc.ignorant.org',
'bogusmx.rfc-ignorant.org' => 'http://www.rfc.ignorant.org',
'dnsbl.sorbs.net' => 'http://www.sorbs.net',
'badconf.rhsbl.sorbs.net' => 'http://www.sorbs.net',
'nomail.rhsbl.sorbs.net' => 'http://www.sorbs.net',
'cbl.abuseat.org' => 'http://www.abuseat.org/support',
'relays.visi.com' => 'http://www.visi.com',
'list.dsbl.org' => 'http://www.dsbl.org',
'opm.blitzed.org' => 'http://www.blitzed.org',
'zen.spamhaus.org' => 'http://www.spamhaus.org',
'combined.njabl.org' => 'http://www.njabl.org/',
);

if($ARGV[0] eq "") { die "Need to supply an IP address to check."; }
$ip = join(".", reverse(split(/\./,$ARGV[0])));

foreach $line (keys %list) {

$host = "$ip.$line";
$res = Net::DNS::Resolver->new;
$query = $res->search("$host");

if($query) {
foreach $rr ($query->answer) {
next unless $rr->type eq "A";
}
print "$ARGV[0] is listed in $line.\n";
}
}