php-net-portscan-1.0.3/0000755000175000017500000000000011315705620013417 5ustar zigozigophp-net-portscan-1.0.3/package.xml0000644000175000017500000000453600000100644015524 0ustar zigozigo Net_Portscan pear.php.net Portscanner utilities. The Net_Portscan package allows one to perform basic portscanning functions with PHP. It supports checking an individual port or checking a whole range of ports on a machine. Martin Jansen MJ mj@php.net yes 2009-12-21 1.0.3 1.0.3 stable stable PHP 2.02 * Implemented Feature Request #14432: Improve PHPCS results. (Patch by Daniel O'Connor.) 4.0.0 1.4.0b1 1.0.1 1.0.1 stable stable 2002-04-09 PHP 2.02 This is a maintenance release to reflect some updates to the directory structure. 1.0 1.0 stable stable 2001-11-15 PHP 2.02 This is the first stable release. php-net-portscan-1.0.3/Net_Portscan-1.0.3/0000755000175000017500000000000011315705607016460 5ustar zigozigophp-net-portscan-1.0.3/Net_Portscan-1.0.3/Portscan.php0000755000175000017500000000752700000100755020756 0ustar zigozigo * * @category Net * @package Net_Portscan * @author Martin Jansen * @license PHP 2.02 * @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 * @license PHP 2.02 * @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); } // }}} } php-net-portscan-1.0.3/Net_Portscan-1.0.3/README.portscan0000755000175000017500000000012411315707074021170 0ustar zigozigoThe documentation for Net_Portscan is available at http://pear.php.net/manual/ php-net-portscan-1.0.3/Net_Portscan-1.0.3/tests/0000755000175000017500000000000011315705607017622 5ustar zigozigophp-net-portscan-1.0.3/Net_Portscan-1.0.3/tests/01-portscan.php0000755000175000017500000000162411315707322022404 0ustar zigozigo $element) { echo "Port " . $port . ": "; if ($element == NET_PORTSCAN_SERVICE_FOUND) { echo " Service found.\n"; } else { echo " No service found.\n"; } } /** Test for getService() */ echo "On port 22, there service " . Net_Portscan::getService(22) . " is running.\n"; /** Test for getPort() */ echo "The finger service usually runs on port " . Net_Portscan::getPort("finger") . ".\n"; ?>