This is a very nice script written by D. Strout over at VPSBoard.com here. Be sure to leave him some feedback and comments about it. Let us know how you have used it or even modified it for your needs.
<?php /** * SpamHaus SBL Chcker * Takes domain and returns number of assigned SBLs and total blocked IPs. * Written by D. Strout (http://www.dstrout.net) */ $domain = $_REQUEST["domain"]; //Input through web //$domain = $argv[1]; //Input through command line if (!domainValid($domain) || strpos($domain, ".") === false) exit("Invalid domain name!"); //Check valid domain $spamHaus = file_get_contents("http://www.spamhaus.org/sbl/listings/$domain"); //Retrieve Spamhaus page for this domain $subnets = explode("</b></span>", $spamHaus); //Subnet sizes are followed by these two tags. $totalIPs = 0; for ($i = 1; $i < count($subnets) - 1; $i++) { //Loop through SBLs - first and last items in array aren't SBLs, don't count them. $subnetSize = explode("/", $subnets[$i]); $subnetSize = (int) $subnetSize[count($subnetSize) - 1]; $totalIPs += pow(2, 32-$subnetSize); //Parse subnet size and calculate number of IPs. Add to $totalIPs } echo "SpamHaus records ".number_format($totalIPs)." IP addresses "; echo "marked as spam under "; echo count($subnets) - 2; echo " SBLs assigned to $domain.\n"; //Output function domainValid($domain) { //Domain validity checker return ( preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $domain) //Check valid characters && preg_match("/^.{1,253}$/", $domain) //Check valid length overall && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $domain) //Check valid length in each part ); } ?>
Tags: checker, ips, sbl, spam
Comments: 1 (One) on this item
You might be interested in this:
Copyright © Security, Server Tweaking, IT Management Blog By SolidShellSecurity [SpamHaus SBL Checker PHP Script - Takes domain and returns number of assigned SBLs and total blocked IPs.], All Right Reserved. 2014.
The post SpamHaus SBL Checker PHP Script – Takes domain and returns number of assigned SBLs and total blocked IPs. appeared first on Security, Server Tweaking, IT Management Blog By SolidShellSecurity.