#!/usr/bin/perl
#Coded in a hurry by Renaud Allard
#
#Usage check_dnsbl IP
#
#You should have downloaded the blacklists list at http://www.llorien.org/blacklists.txt for this script to work
#Take care it doesn't validate anything.

$ip=$ARGV[0];

@sip = split (/\./, $ip);

$rip = "$sip[3].$sip[2].$sip[1].$sip[0]";

open (RBL, "<blacklists.txt");

while (<RBL>) {
	$found = 0;
	s/\n//g;
	$cmd = "dig -t ANY $rip.$_ |";
	open (CMD, "$cmd");
	while (<CMD>) {
		$line = $_;
		if ($line =~ /TXT/ || $line =~ /127\.0\./) {
			print $line;
			$found = 1;
		}
	}
	close (CMD);
	if ($found) {
		print "\n";
	}
}

close (RBL);
