IP list port scanner from txt file

This script is used for scanning list of IP addresses specified in a text file. It is used by selecting a file and entering a 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.

List of IP addresses should look like this(in each row one address):

10.0.0.1
10.0.2.5
10.0.3.8
10.0.2.1

 

Demo: http://vrsho.com/demo/ipscannerfile/

HTML entry part(index.html):

[cc lang=”php”]<table width=”62%” height=”323″ border=”0″>
<tr>
<td width=”324″ valign=”top”><form enctype=”multipart/form-data” action=”ipscannerfile.php” method=”POST”>
<p><strong>Scann IP address list from file: </strong></p>
<p>Select file
<input name=”uploaded” type=”file” />
</p>
<p>
Port range:
<input name=”port3″ type=”text” size=”8″ maxlength=”8″ />

<input name=”port4″ type=”text” size=”8″ maxlength=”8″ />
</p>
<p align=”center”><br />
<input type=”submit” value=”Scann” />
</p>
</form>
</td>
</tr>
</table>[/cc]

PHP scanner(ipscannerfile.php):

[cc lang=”php”]<?php
error_reporting(0);
$file = basename($_FILES[‘uploaded’][‘name’]).’.scan’;
if(move_uploaded_file($_FILES[‘uploaded’][‘tmp_name’], $file)){
$myFile = “ip_up.txt”;
$fh = fopen($myFile, ‘w’);
$port1=$_POST[‘port3’];
$port2=$_POST[‘port4’];
$ofile = @fopen($file, “r”);
if ($ofile) {
while (!feof($ofile)){
$ip1 = fgets($ofile, 2048);
$ip = trim($ip1);
for($i=$port1;$i<$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();
}}}
echo ‘<a href=”ip_up.txt”>Download</a>’;
}
else die(‘error’);
?>[/cc]

1 Comment on “IP list port scanner from txt file

  1. Hi code you please upload the code in to pastebin or something like that?
    I tried to copy the code and when I run i have this error
    PHP Syntax Check: Parse error: syntax error, unexpected ‘–’ (T_STRING) in your code on line 20
    echo $ip.”:”.$i.” – “.round((($tA – $tB) * 1000), 0).” ms”;

    is this encoding utf8?

Leave a Reply

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

*