This file is indexed.

/usr/share/php/Net/DNSBL/SURBL.php is in php-net-dnsbl 1.3.3-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * PEAR::Net_DNSBL
 *
 * This class acts as interface to generic Realtime Blocking Lists
 * (RBL)
 *
 * PHP versions 4 and 5
 *
 * LICENSE: This source file is subject to version 3.01 of the PHP license
 * that is available through the world-wide-web at the following URI:
 * http://www.php.net/license/3_01.txt.  If you did not receive a copy of
 * the PHP License and are unable to obtain it through the web, please
 * send a note to license@php.net so we can mail you a copy immediately.
 *
 * Net_DNSBL looks up an supplied host if it's listed in 1-n supplied
 * Blacklists
 *
 * @category  Net
 * @package   Net_DNSBL
 * @author    Sebastian Nohn <sebastian@nohn.net>
 * @author    Ammar Ibrahim <fixxme@fixme.com>
 * @copyright 2004-2009 Sebastian Nohn <sebastian@nohn.net>
 * @license   http://www.php.net/license/3_01.txt  PHP License 3.01
 * @version   CVS: $Id: SURBL.php,v 1.11 2009/05/08 07:10:42 nohn Exp $
 * @link      http://pear.php.net/package/Net_DNSBL
 * @see       Net_DNS
 * @since     File available since Release 1.0.0
 */

require_once 'Cache/Lite.php';
require_once 'HTTP/Request.php';
require_once 'Net/CheckIP.php';
require_once 'Net/DNSBL.php';

/**
 * PEAR::Net_DNSBL_SURBL
 *
 * This class acts as interface to the SURBL - Spam URI Realtime Blocklists.
 *
 * Services_SURBL looks up an supplied URI if it's listed in a
 * Spam URI Realtime Blocklists.
 *
 * @category Net
 * @package  Net_DNSBL
 * @author   Sebastian Nohn <sebastian@nohn.net>
 * @license  http://www.php.net/license/3_01.txt PHP License 3.01
 * @version  Release: 1.3.3
 * @link     http://pear.php.net/package/net_dnsbl Package Home
 */

class Net_DNSBL_SURBL extends Net_DNSBL
{

    /**     
     * Array of blacklists.
     *
     * Must have one or more elements.
     *
     * @var    string[]
     * @access protected
     */
    var $blacklists = array('multi.surbl.org');

    /**
     * File containing whitelisted hosts.
     *
     * There are some whitelisted hosts (co.uk for example). This
     * requires the package to not ask the domain name but the host
     * name (spammer.co.uk instead of co.uk).
     * 
     * @var    string
     * @see    $twoLevelCcTld
     * @access protected
     */
    var $doubleCcTldFile = 'http://spamcheck.freeapp.net/two-level-tlds';

    /**
     * Array of whitelisted hosts.
     *
     * @var    array
     * @see    $twoLevelCcTldFile
     * @access private
     */
    var $twoLevelCcTld = array();

    /**
     * Check if the last two parts of the FQDN are whitelisted.
     *
     * @param string $fqdn Host to check if it is whitelisted.
     *
     * @access protected
     * @return boolean True if the host is whitelisted
     */
    function isDoubleCcTld($fqdn)
    {
        // 30 Days should be way enough
        $options = array(
                         'lifeTime' => '2592000',
                         'automaticSerialization' => true
                         );
        $id      = md5($this->doubleCcTldFile);

        $cache = new Cache_Lite($options);
        if ($data = $cache->get($id)) {
            // Cache hit
        } else {
            // Cache miss
            $http = &new HTTP_Request($this->doubleCcTldFile);
            if (!PEAR::isError($http->sendRequest())) {
                $data = $http->getResponseBody();
            }
            $data = explode("\n", $data);
            $data = array_flip($data);
            $cache->save($data, $id);
        } // if 
        if (array_key_exists($fqdn, $data)) {
            return true;
        } else {
            return false;
        } // if
    } // function

    /**
     * Get Hostname to ask for.
     *
     * Performs the following steps:
     *
     * (1) Extract the hostname from the given URI
     * (2) Check if the "hostname" is an ip
     * (3a) IS_IP Reverse the IP (1.2.3.4 -> 4.3.2.1)
     * (3b) IS_FQDN Check if is in "CC-2-level-TLD"
     * (3b1) IS_IN_2LEVEL: we want the last three names
     * (3b2) IS_NOT_2LEVEL: we want the last two names
     * (4) return the FQDN to query.
     *
     * @param string $uri       URL to check. 
     * @param string $blacklist Blacklist to check against. 
     *
     * @access protected
     * @return string Host to lookup
     */
    function getHostForLookup($uri, $blacklist) 
    {
        // (1) Extract the hostname from the given URI
        $host       = '';
        $parsed_uri = parse_url($uri);
        $host       = urldecode($parsed_uri['host']);
        // (2) Check if the "hostname" is an ip
        if (Net_CheckIP::check_ip($host)) {
            // (3a) IS_IP Reverse the IP (1.2.3.4 -> 4.3.2.1)
            $host = $this->reverseIp($host);
        } else {
            $host_elements = explode('.', $host);
            while (count($host_elements) > 3) {
                array_shift($host_elements);
            } // while
            $host_3_elements = implode('.', $host_elements);
            
            $host_elements = explode('.', $host);
            while (count($host_elements) > 2) {
                array_shift($host_elements);
            } // while
            $host_2_elements = implode('.', $host_elements);
            
            // (3b) IS_FQDN Check if is in "CC-2-level-TLD"
            if ($this->isDoubleCcTld($host_2_elements)) {
                // (3b1) IS_IN_2LEVEL: we want the last three names
                $host = $host_3_elements;
            } else {
                // (3b2) IS_NOT_2LEVEL: we want the last two names
                $host = $host_2_elements;
            } // if
        } // if
        // (4) return the FQDN to query
        $host .= '.'.$blacklist;
        return $host;
    } // function
    
} // class
?>