PHP Script to scan all ports of website or host
Following is PHP code which will scan all ports of particular host / website and will print list of all open ports in result. This code can be use to probe a server or host for open ports. This is often used by administrators to verify security policies of their networks and by attackers to identify services running on a host and exploit vulnerabilities. ports scanning is a process that sends client requests to a range of server port addresses on a host, with the goal of finding an active port; this is not a nefarious process in and of itself. The majority of uses of a port scan are not attacks, but rather simple probes to determine services available on a remote machine. So I will recommend to use it for making your servers more secure.
<?php$host = 'example.com';for ($i=0; $i<=9999; $i++){ $connection = @fsockopen($host, $i); if (is_resource($connection)) { echo '<h2>' . $host . ':' . $i . ' ' . '(' . getservbyport($i, 'tcp') . ') is open.' . "\n"; fclose($connection); }}?>
Comments
Post a Comment