{"id":38,"date":"2016-11-20T15:42:50","date_gmt":"2016-11-20T15:42:50","guid":{"rendered":"https:\/\/anthonyparkes.co.uk\/?p=38"},"modified":"2016-11-20T15:42:50","modified_gmt":"2016-11-20T15:42:50","slug":"projecthoneypot-dns-blacklist-blocker","status":"publish","type":"post","link":"https:\/\/anthonyparkes.co.uk\/?p=38","title":{"rendered":"Projecthoneypot DNS Blacklist Blocker"},"content":{"rendered":"<p>I made this PHP script to help project parts of my site that I wanted to block spam bots to access. This is now protecting all my sites and pages (including this one).<br \/>\nthe code is simple you just need to include it at the top of all the pages you want to project.<\/p>\n<p>The code for the check is below and is free to anyone that wishes to use it. The version I use has a bit more than below including an exclusion\u00a0list for anyone that has a blacklisted dynamic IP as well as stats of what has been blocked. My Stats are at\u00a0<a href=\"https:\/\/web.archive.org\/web\/20120918005321\/http:\/\/www.aj-services.com\/dnsbl\/list.php\">http:\/\/www.aj-services.com\/dnsbl\/list.php<\/a> this\u00a0shows the power of the script and how many known spammers it is blocking.<\/p>\n<pre>&lt;?php\r\n\/\/ Script by Anthony Parkes (www.aj-services.com)\r\n\/\/ this is a very basic script that can be added to any page that you\r\n\/\/ might not want spam bots to see. For Example feedback forms or contact\r\n\/\/ pages. I have added this to the top of index.php in wordpress and it\r\n\/\/ protects the site well.\r\n\/\/ To Install: Copy the file to your webserver and place the following line at the top of all\r\n\/\/ the php files you wish to protect.\r\n\/\/ include(\"\/path\/to\/checkip.php\");\r\n\/\/\/\/\/\/ SETTINGS \/\/\/\/\/\/\/\/\/\r\n$accesskey = \"\"; \/\/ this is your projecthoneypot.org http:bl key\r\n$maxlastseen = \"14\"; \u00a0\/\/ Only block ips that have been seen on the honeypot project in the last xx days (value can be 1-99)\r\n\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\r\nif ($tocheck == \"\") {\r\n$tocheck = $_SERVER['REMOTE_ADDR'];\r\n}\r\n$check = $accesskey . \".\" . implode( '.', array_reverse( explode( '.', $tocheck ) ) ) . '.dnsbl.httpbl.org';\r\n$results = gethostbyname($check);\r\nlist($r_a, $r_b, $r_c, $r_d) = explode(\".\", $results);\r\nif ($r_a == \"127\") {\r\n\/\/is listed\r\n$lastseen = $r_b;\r\n$threat = $r_c;\r\nif ($r_d == \"0\") { $type = \"Search Engine\"; }\r\nif ($r_d == \"1\") { $type = \"Suspicious\"; }\r\nif ($r_d == \"2\") { $type = \"Harvester\"; }\r\nif ($r_d == \"3\") { $type = \"Suspicious &amp; Harvester\"; }\r\nif ($r_d == \"4\") { $type = \"Comment Spammer\"; }\r\nif ($r_d == \"5\") { $type = \"Suspicious &amp; Comment Spammer\"; }\r\nif ($r_d == \"6\") { $type = \"Harvester &amp; Comment Spammer\"; }\r\nif ($r_d == \"7\") { $type = \"Suspicious, Harvester &amp; Comment Spammer\"; }\r\nif ($r_d != \"0\") {\r\n$blacklisted = \"1\";\r\nif ($lastseen &gt; $maxlastseen) { $blacklisted = \"0\"; }\r\nif ($blacklisted == \"1\") {\r\necho \"Your IP is blacklisted\";\r\necho \"&lt;p&gt;&lt;b&gt;$type&lt;\/b&gt; Last Seen &lt;b&gt;$lastseen&lt;\/b&gt; Day(s) ago.\";\r\necho \" Threat Level of &lt;b&gt;$threat&lt;\/b&gt;&lt;br&gt;\";\r\necho \"&lt;p&gt;This Blacklist is managed and maintained by projecthoneypot.org\";\r\nexit;\r\n}\r\n}\r\n}\r\n\/\/ Not blacklisted then load the rest of the page.\r\n?&gt;<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I made this PHP script to help project parts of my site that I wanted to block spam bots to access. This is now protecting<\/p>\n","protected":false},"author":2,"featured_media":39,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-projects"],"_links":{"self":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/38","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=38"}],"version-history":[{"count":1,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions"}],"predecessor-version":[{"id":40,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/38\/revisions\/40"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=\/wp\/v2\/media\/39"}],"wp:attachment":[{"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/anthonyparkes.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}