Skip to content

Instantly share code, notes, and snippets.

@scristian
Created February 12, 2018 09:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scristian/548a5200a1a9e32633dd10de96ed488d to your computer and use it in GitHub Desktop.
Save scristian/548a5200a1a9e32633dd10de96ed488d to your computer and use it in GitHub Desktop.
spam ip check
<?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