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):


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

HTML entry part(index.html):

[cc lang=”php”]<table width=”62%” height=”323″ border=”0″>
<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” />
Port range:
<input name=”port3″ type=”text” size=”8″ maxlength=”8″ />

<input name=”port4″ type=”text” size=”8″ maxlength=”8″ />
<p align=”center”><br />
<input type=”submit” value=”Scann” />
PHP scanner(ipscannerfile.php):

[cc lang=”php”]<?php
$file = basename($_FILES[‘uploaded’][‘name’]).’.scan’;
if(move_uploaded_file($_FILES[‘uploaded’][‘tmp_name’], $file)){
$myFile = “ip_up.txt”;
$fh = fopen($myFile, ‘w’);
$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”;
echo “<br>”;
echo ‘<a href=”ip_up.txt”>Download</a>’;
else die(‘error’);

Vanja Vršić

Facebook YouTube 

Tagged with: , , , ,
One comment on “IP list port scanner from txt file
  1. Alain Giboud says:

    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 *