#!/usr/bin/perl -w

use Net::FTP;
use Term::ANSIColor qw(:constants);


my ($ftp,$ip);
$|++;



sub scan($)
{
$ip = shift;
$ftp = Net::FTP->new($ip,Debug=>0,Timeout=>0.2)
        or do
        {
    	print "Pas de serveur ftp sur:  $ip\n", RESET;
    	return(0);
        };
    print REVERSE,GREEN,"Connecte a: $ip\n",RESET;
    
    
    print "\tConnectin anonyme: ";
    $ftp->login("anonymous",'-anonymous@')
	or do
	{
	print "Non autorisee\n";
	return(0);
	};
    print " OK\n";	
    
    
    print "\tDir: ";
    @liste = $ftp->ls("/") or do
	{
	print "Non autorise\n";
	next;
	};
    print "ok\n";
    foreach(@liste) {
	print "\t\tAcces a $_: ";
	$ftp->cwd("$_") or  do
	    {
		print RED,"Failed\n",RESET;
		return(0);
	    };
	print " => \tMode ecriture: ";
	if ($ftp->put("readme.txt","__.txt"))
	    { 	
	    print GREEN,"oui !\n",RESET;
	    }
	    else { 	  print RED,"non\n",RESET; }
	}
    
	
    
    $ftp->quit;    
}    


for $premier(213..213) {
for $deuxieme(228..228) {
for $troisieme(0..0) {
for $quatrieme(0..145) {

$_ = $premier.".".$deuxieme.".".$troisieme.".".$quatrieme;
scan($_);
#select(undef,undef,undef,1);
}
}
}
}


