rblcheck-web 964 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/usr/bin/perl
  2. # Multi-RBL Query tool, developer Vikram <vr@udel.edu>
  3. use IO::Socket::INET;
  4. die "Syntax: $0 -H <ip address>\n" unless $ARGV[1];
  5. $soc = new IO::Socket::INET->new(PeerPort=>80,
  6. Proto=>'tcp',
  7. PeerAddr=>"rbls.org") or die("Cannot connect to CERT");
  8. $ip = $ARGV[1];
  9. $uri = '/?q='.$ip;
  10. $soc->send("GET $uri HTTP/1.1\nHost: rbls.org\n\n");
  11. @buff = <$soc>;
  12. delete @buff[0..7];
  13. $len = @buff;
  14. $alert = 0;
  15. for( $i=0;$i<$len;$i++ ) {
  16. next unless( defined $buff[$i] );
  17. chomp($buff[$i]);
  18. #print "$buff[$i]\n";
  19. if ( $buff[$i] eq "<tr bgcolor=#ffc0c0>" ) {
  20. $rbl = substr($buff[$i+1], 5, index($buff[$i], "</tr>") - 5);
  21. next if ( index($rbl, '.') == -1 );
  22. print "$ip is listed in the following RBLS: " if ( $alert == 0 );
  23. print "$rbl ";
  24. $alert = 1;
  25. }
  26. }
  27. print "$ip is not listed in any RBLS" if ( $alert == 0 );
  28. print "\n";
  29. exit($alert);