php-net-portscan-1.0.3/ 0000755 0001750 0001750 00000000000 11315705620 013417 5 ustar zigo zigo php-net-portscan-1.0.3/package.xml 0000644 0001750 0001750 00000004536 00000100644 015524 0 ustar zigo zigo
Net_Portscanpear.php.netPortscanner 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 JansenMJmj@php.netyes2009-12-211.0.31.0.3stablestablePHP 2.02
* Implemented Feature Request #14432: Improve PHPCS results. (Patch by Daniel O'Connor.)
4.0.01.4.0b11.0.11.0.1stablestable2002-04-09PHP 2.02
This is a maintenance release to reflect some updates to the directory
structure.
1.01.0stablestable2001-11-15PHP 2.02
This is the first stable release.
php-net-portscan-1.0.3/Net_Portscan-1.0.3/ 0000755 0001750 0001750 00000000000 11315705607 016460 5 ustar zigo zigo php-net-portscan-1.0.3/Net_Portscan-1.0.3/Portscan.php 0000755 0001750 0001750 00000007527 00000100755 020756 0 ustar zigo zigo
*
* @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.portscan 0000755 0001750 0001750 00000000124 11315707074 021170 0 ustar zigo zigo The documentation for Net_Portscan is available at
http://pear.php.net/manual/
php-net-portscan-1.0.3/Net_Portscan-1.0.3/tests/ 0000755 0001750 0001750 00000000000 11315705607 017622 5 ustar zigo zigo php-net-portscan-1.0.3/Net_Portscan-1.0.3/tests/01-portscan.php 0000755 0001750 0001750 00000001624 11315707322 022404 0 ustar zigo zigo $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";
?>