IP range port scanner

The task of this script is to scan open ports given by specific ip address range. It is used by entering the IP range and port range you want to scan. It consists of two parts: the HTML entry forms and PHP scripts for processing. After a completed scan, script throws a list with open IP addresses. Demo: http://vrsho.com/demo/ipscanner/
First part(index.html):
<html>
<table width='62%' height='323' border='0'>
<tr>
<td width='300' valign='top'><form id='form1' name='form1' method='post' action='ipscanner.php'>
<p><strong>Select ip range to scann:</strong></p>
<p>
IP Range:
<input name='ip1' type='text' size='15' maxlength='15' />
-
<input name='ip2' type='text' size='15' maxlength='15' />
</p>
<p>
Port range:
<input name='port1' type='text' size='8' maxlength='8' />
-
<input name='port2' type='text' size='8' maxlength='8' />
</p>
<p align='center'>
<input name='submit' type='submit' value='Scann' />
</p>
</form>
</td>
</tr>
</table>
</html>
Second part(ipscanner.php):
<?php
error_reporting(0);
$from = $_POST['ip1'];
$to = $_POST['ip2'];
$port1=$_POST['port1'];
$port2=$_POST['port2'];
$myFile = "ip_up.txt";
$fh = fopen($myFile, 'w');
$arry1 = explode(".",$from);
$arry2 = explode(".",$to);
$a1 = $arry1[0]; $b1 = $arry1[1]; $c1 = $arry1[2]; $d1 = $arry1[3];
$a2 = $arry2[0]; $b2 = $arry2[1]; $c2 = $arry2[2]; $d2 = $arry2[3];
while( $d2 >= $d1 || $c2 > $c1 || $b2 > $b1 || $a2 > $a1){
if($d1 > 255){
$d1 = 1;
$c1 ++;
}
if($c1 > 255){
$c1 = 1;
$b1 ++;
}
if($b1 > 255){
$b1 = 1;
$a1 ++;
}
$ip = '$a1.$b1.$c1.$d1';
for($i=$port1;$i<(int)$port2+1;$i++) {
$tB = microtime(true);
$fP = fSockOpen($ip, $i, $errno, $errstr, 1);
$tA = microtime(true);
if (!$fP) {echo $ip.":".$i." - down";}
else {
echo $ip.":".$i." - ".round((($tA - $tB) * 1000), 0)." ms";
fwrite($fh,$ip."\r\n");
}
echo "<br>";
flush();
}
$d1 ++;
}
echo '<a href="ip_up.txt">Download</a>';
?>
Vanja Vršić
Vanja Vršić

Facebook YouTube 

One Response to IP range port scanner

  1. Gym Workout says:

    I think other website proprietors should take this web site as an model, very clean and magnificent user friendly style and design, as well as the content. You’re an expert in this topic!

Leave a Reply

Your email address will not be published. Required fields are marked *