Skip to content

Instantly share code, notes, and snippets.

@hostmiza
Forked from tbreuss/dnsbl.php
Created August 7, 2018 08:17
Show Gist options
  • Save hostmiza/ccf5d1d9a99396f8943c2fccadb449a4 to your computer and use it in GitHub Desktop.
Save hostmiza/ccf5d1d9a99396f8943c2fccadb449a4 to your computer and use it in GitHub Desktop.

Revisions

  1. @tbreuss tbreuss revised this gist Mar 15, 2018. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions dnsbl.php
    Original file line number Diff line number Diff line change
    @@ -32,8 +32,7 @@ function dnsbllookup($ip)
    "bl.spamcop.net",
    "list.dsbl.org",
    "sbl.spamhaus.org",
    "xbl.spamhaus.org",
    "relays.osirusoft.com"
    "xbl.spamhaus.org"
    ];

    $listed = "";
  2. @tbreuss tbreuss revised this gist Jun 9, 2016. No changes.
  3. @tbreuss tbreuss created this gist Jun 9, 2016.
    68 changes: 68 additions & 0 deletions dnsbl.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    <?php
    /***********************************************************************************************************************
    * This is a simple PHP script to lookup for blacklisted IP against multiple DNSBLs at once.
    **********************************************************************************************************************/
    ?>
    <html>
    <head>
    <title>DNSBL Lookup Tool - IP Blacklist Check Script</title>
    </head>
    <body>
    <h2>IP Blacklist Check Script</h2>
    <form action="" method="get">
    <input type="text" value="" name="ip"/>
    <input type="submit" value="LOOKUP"/>
    </form>
    <?php

    /**
    * The IP-address to be looked up.
    * @param string $ip
    */
    function dnsbllookup($ip)
    {
    // Add your preferred list of DNSBL's
    $dnsbl_lookup = [
    "dnsbl-1.uceprotect.net",
    "dnsbl-2.uceprotect.net",
    "dnsbl-3.uceprotect.net",
    "dnsbl.dronebl.org",
    "dnsbl.sorbs.net",
    "zen.spamhaus.org",
    "bl.spamcop.net",
    "list.dsbl.org",
    "sbl.spamhaus.org",
    "xbl.spamhaus.org",
    "relays.osirusoft.com"
    ];

    $listed = "";

    if ($ip) {
    $reverse_ip = implode(".", array_reverse(explode(".", $ip)));
    foreach ($dnsbl_lookup as $host) {
    if (checkdnsrr($reverse_ip . "." . $host . ".", "A")) {
    $listed .= $reverse_ip . '.' . $host . ' <font color="red">Listed</font><br />';
    }
    }
    }

    if (empty($listed)) {
    echo '"A" record was not found';
    } else {
    echo $listed;
    }
    }

    if (isset($_GET['ip']) && $_GET['ip'] != null) {
    $ip = $_GET['ip'];
    if (filter_var($ip, FILTER_VALIDATE_IP)) {
    echo dnsbllookup($ip);
    } else {
    echo "Please enter a valid IP";
    }
    }

    ?>
    </body>
    </html>