Created
March 12, 2013 06:28
-
-
Save juffee/5140768 to your computer and use it in GitHub Desktop.
Function to use project honeypots black list.
https://www.projecthoneypot.org/
from here: http://planetozh.com/blog/my-projects/honey-pot-httpbl-simple-php-script/
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 | |
/** | |
REFERENCE: | |
http://planetozh.com/blog/my-projects/honey-pot-httpbl-simple-php-script/ | |
https://www.projecthoneypot.org/ | |
**/ | |
function checkIfCleanIp($ipToCheck, $apikey){ | |
// Project Honeypot | |
// your http:BL key | |
// sample: $apikey = 'jlonedutoxea'; | |
// build the lookup DNS query | |
// Example : for '127.9.1.2′ you should query 'abcdefghijkl.2.1.9.127.dnsbl.httpbl.org' | |
$lookup = $apikey . '.' . implode('.', array_reverse(explode ('.', $ipToCheck ))) . '.dnsbl.httpbl.org'; | |
// check query response | |
$result = explode( '.', gethostbyname($lookup)); | |
$test = gethostbyname($lookup); | |
if ($result[0] == 127) { | |
// query successful ! | |
$activity = $result[1]; | |
$threat = $result[2]; | |
$type = $result[3]; | |
if ($type & 0) $typemeaning .= 'Search Engine, '; | |
if ($type & 1) $typemeaning .= 'Suspicious, '; | |
if ($type & 2) $typemeaning .= 'Harvester, '; | |
if ($type & 4) $typemeaning .= 'Comment Spammer, '; | |
$typemeaning = trim($typemeaning,', '); | |
return false; | |
} else { | |
return true; | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment