Created
February 12, 2018 09:21
-
-
Save scristian/548a5200a1a9e32633dd10de96ed488d to your computer and use it in GitHub Desktop.
spam ip check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$rbls = [ | |
'b.barracudacentral.org', | |
'cbl.abuseat.org', | |
'http.dnsbl.sorbs.net', | |
'misc.dnsbl.sorbs.net', | |
'socks.dnsbl.sorbs.net', | |
'web.dnsbl.sorbs.net', | |
'dnsbl-1.uceprotect.net', | |
'dnsbl-3.uceprotect.net', | |
'rbl.spamlab.com', | |
'noptr.spamrats.com', | |
'httpbl.abuse.ch', | |
'multi.surbl.org', | |
'dnsbl.sorbs.net', | |
'dul.dnsbl.sorbs.net', | |
'smtp.dnsbl.sorbs.net', | |
'spam.dnsbl.sorbs.net', | |
'zombie.dnsbl.sorbs.net', | |
'dyna.spamrats.com', | |
'spam.spamrats.com', | |
'query.senderbase.org', | |
'combined.rbl.msrbl.net', | |
]; | |
$ip = ''; | |
$rev = join('.', array_reverse(explode('.', trim($ip)))); | |
$i = 1; | |
$rbl_count = count($rbls); | |
$listed_rbls = []; | |
foreach ($rbls as $rbl) | |
{ | |
printf('Checking %s, %d of %d... ', $rbl, $i, $rbl_count); | |
$lookup = sprintf('%s.%s', $rev, $rbl); | |
$listed = gethostbyname($lookup) !== $lookup; | |
printf('[%s]%s', $listed ? 'LISTED' : 'OK', PHP_EOL); | |
if ( $listed ) | |
{ | |
$listed_rbls[] = $rbl; | |
} | |
$i++; | |
} | |
printf('%s listed on %d of %d known blacklists%s', $ip, count($listed_rbls), $rbl_count, PHP_EOL); | |
if ( ! empty($listed_rbls) ) | |
{ | |
printf('%s listed on %s%s', $ip, join(', ', $listed_rbls), PHP_EOL); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment