l#!/usr/bin/perl use Net::FTP; my $database = shift; my $THE_PORT = 21; my $THE_FUNCTION = \&checkanonftp; open (DB,"<" . $database) || die ("Could not open database: $!"); while ($line = ) { # split our fields ($address, $portcount, $ports, $status, $seqindex, $os) = split(/\|/,$line); if ($portcount > 0) #if there are no ports open, just skip it { @portlist = (); @portlist = split(/\,/,$ports); foreach $port (@portlist) { ($number, $state, $protocol, $service) = split(/\./,$port); if ($number eq $THE_PORT && $state eq "open") { $username = "anonymous"; $password = "anonymous\@example.org"; print STDERR "Trying $address...\n"; $FAILED = 0; if ($ftp = Net::FTP->new($address, Timeout => 15)) { if ($ftp->login($username,$password)) { print "$address\n"; print STDERR "Logged into $address\n"; } else { print STDERR "Cant login to $address\n"; } $ftp->quit(); } else { print STDERR "Cant connect to $address\n"; } } } } }