This file is indexed.

/usr/share/php/Net/Portscan.php is in php-net-portscan 1.0.3-2.

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
<?php
/**
 * PHP 4
 *
 * Copyright (c) 1997-2003 The PHP Group
 *
 * This source file is subject to version 2.0 of the PHP license,
 * that is bundled with this package in the file LICENSE, and is
 * available at through the world-wide-web at
 * http://www.php.net/license/2_02.txt.
 * If you did not receive a copy of the PHP license and are unable to
 * obtain it through the world-wide-web, please send a note to
 * license@php.net so we can mail you a copy immediately.
 *
 * Authors: Martin Jansen <mj@php.net>
 *
 * @category Net
 * @package  Net_Portscan
 * @author   Martin Jansen <mj@php.net>
 * @license  PHP 2.02 <http://www.php.net/license/2_02.txt>
 * @version  CVS: $Id: Portscan.php 292446 2009-12-21 21:03:44Z mj $
 * @link     http://pear.php.net/net_portscan
 */

define("NET_PORTSCAN_SERVICE_FOUND", true);
define("NET_PORTSCAN_NO_SERVICE", false);

/**
 * Portscan class
 *
 * This class provides methods to scan ports on machines,
 * that are connected to the internet. See README for more
 * information on how to use it.
 *
 * @category Net
 * @package  Net_Portscan
 * @author   Martin Jansen <mj@php.net>
 * @license  PHP 2.02 <http://www.php.net/license/2_02.txt>
 * @link     http://pear.php.net/net_portscan
 */
class Net_Portscan
{
    // {{{ checkPort()

    /**
     * Check if there is a service available at a certain port.
     *
     * This function tries to open a connection to the port
     * $port on the machine $host. If the connection can be
     * established, there is a service listening on the port.
     * If the connection fails, there is no service.
     *
     * @param string  $host    Hostname
     * @param integer $port    Portnumber
     * @param integer $timeout Timeout for socket connection in seconds
     *                         (default is 30).
     *
     * @access public
     * @return string
     */
    function checkPort($host, $port, $timeout = 30)
    {
        $socket = @fsockopen($host, $port, $errorNumber, $errorString, $timeout);

        if (!$socket) {
            return NET_PORTSCAN_NO_SERVICE;
        }

        @fclose($socket);
        return NET_PORTSCAN_SERVICE_FOUND;
    }

    // }}}
    // {{{ checkPortRange()

    /**
     * Check a range of ports at a machine
     *
     * This function can scan a range of ports (from $minPort
     * to $maxPort) on the machine $host for running services.
     *
     * @param string  $host    Hostname
     * @param integer $minPort Lowest port
     * @param integer $maxPort Highest port
     * @param integer $timeout Timeout for socket connection in seconds
     *                         (default is 30).
     *
     * @access public
     *
     * @return array  Associative array containing the result
     */
    function checkPortRange($host, $minPort, $maxPort, $timeout = 30)
    {
        for ($i = $minPort; $i <= $maxPort; $i++) {
            $retVal[$i] = Net_Portscan::checkPort($host, $i, $timeout);
        }

        return $retVal;
    }

    // }}}
    // {{{ getService()

    /**
     * Get name of the service that is listening on a certain port.
     *
     * @param integer $port     Portnumber
     * @param string  $protocol Protocol (Is either tcp or udp. Default is tcp.)
     *
     * @access public
     *
     * @return string  Name of the Internet service associated with $service
     */
    function getService($port, $protocol = "tcp")
    {
        return @getservbyport($port, $protocol);
    }

    // }}}
    // {{{ getPort()

    /**
     * Get port that a certain service uses.
     *
     * @param string $service  Name of the service
     * @param string $protocol Protocol (Is either tcp or udp. Default is tcp.)
     *
     * @access public
     *
     * @return integer Internet port which corresponds to $service
     */
    function getPort($service, $protocol = "tcp")
    {
        return @getservbyname($service, $protocol);
    }

    // }}}
}