Created
May 7, 2014 12:32
-
-
Save akalongman/b50bc11a9303adb6f2db to your computer and use it in GitHub Desktop.
Port scanner on PHP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('max_execution_time', 0); | |
ini_set('memory_limit', -1); | |
$host = 'google.com'; | |
$ports = array(21, 25, 80, 81, 110, 143, 443, 587, 2525, 3306); | |
foreach ($ports as $port) | |
{ | |
$connection = @fsockopen($host, $port, $errno, $errstr, 2); | |
if (is_resource($connection)) | |
{ | |
echo '<h2>' . $host . ':' . $port . ' ' . '(' . getservbyport($port, 'tcp') . ') is open.</h2>' . "\n"; | |
fclose($connection); | |
} | |
else | |
{ | |
echo '<h2>' . $host . ':' . $port . ' is not responding.</h2>' . "\n"; | |
} | |
} |
Example: I want to check for 100 IP addresses, with 3 ports 20, 40, 60. Can anyone help me with a complete code to run the check port loop of 100 IP addresses? Thanks everyone
Do you still need help?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: I want to check for 100 IP addresses, with 3 ports 20, 40, 60. Can anyone help me with a complete code to run the check port loop of 100 IP addresses? Thanks everyone