<HTML>
<HEAD>
<?php
/****************************************************************
* Random port scanner
* by Vincent A. Menard
* thabob -at- gmail.com
* http://www.ground418.org
*****************************************************************/
// Configs

// Host name, ex.: www.example.com, 
// if you put this script in the web root.
$h "www.example.com";

// Port to look at
$p 1080;


$ip rand(1255).".".rand(1255).".".rand(1,255).".".rand(1,255);
$count $_GET['cnt'];
$found $_GET['found'];
$count++;
$fp =@ fsockopen($ip1080$errno$errstr5);
if (!
$fp) {
    echo
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5;URL=http://".$h."/sock_scan.php?cnt=$count&found=$found\">";
} else {
    
fclose($fp);
    
$found $found."<br>$ip";
    
// now we found one, we can insert it into a database
    // see www.ground418.org/outils/files/SQL_Suite.tar for the includes.
    // table -> t1: col1 = found address, col2 = port, col3 = when it was looked, col4 = who fount it
    //include 'SQL_Class.php';
    //include 'SQL_Statement.php';
    //$dbh = new SQL_Class();
    //$stmt = $dbh->execute("SELECT COUNT(*) FROM t1 WHERE col1 = '".$ip."' AND col2 = '".$p."'");
    //$cnt = $stmt->sql_result();
    //if ($cnt == 1)
    //    $stmt = $dbh->execute("UPDATE t1 SET col2=NOW(), col3='".$h."' WHERE col1='".$ip."' AND col2 = '".$p."'");
    //else
    //    $stmt = $dbh->execute("INSERT INTO t1 SET col1='".$ip."', col3=NOW(), col4='".$h."'");
    
    // Or you can simply throw it in the ground418 database, if it's a 1080 port.
    
    
if ($p 1080) {
        
$fp =@ fopen ("http://www.ground418.org/textes/proxies/add.php?ip=".$ip"rb");
        @
fclose($fp);
    }
    echo
"<META HTTP-EQUIV=\"Refresh\" CONTENT=\"5;URL=http://".$h."/sock_scan.php?cnt=$count&found=$found\">";

}
?>
<TITLE>php Random Port Scanner</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<?php 
echo "Just tested $ip (...)<br>";
echo 
"Scanned IP: $count<br><br>Found: <br>";
if (
$found == "")
    echo 
"none.";
else 
    echo
"<br><b>".$found.":".$p."</b>"
?>
</BODY>
</HTML>