Code
# !/usr/bin/perl
#############
# Coded by satyr [Cyber Lords Community]
# http://www.cyberlords.net
# v00000000000z2 02.01.07
# ./ftpchecker.pl ftplist
# ftplist format:
# ftp://login1:pass1@host1.com
# ftp://login2:pass2@host2.com
# ftp://login3:pass3@host3.com
#####
use strict;
use IO::Socket;
my $verbose = 0;
my $pids = 50;
my @forked;
open(LIST, $ARGV[0]) or die "$!";
my @list = <LIST>;
close(LIST);
my $once=0;
while(1) {
my @check_now = @list[$once..$once+$pids];
for (my $i=0;$i<=$pids;$i++) {
unless($check_now[$i]) {
killpidz();
exit print "Scan is complete\n";
}
if (my $pid=fork()) {
push(@forked,$pid);
} else {
###################MAIN CHECK###########################
chomp $check_now[$i];
#print "Checikng $check_now[$i]\n";
my ($login, $pass, $host) = ($check_now[$i]) =~ /^ftp\:\/\/([^:]+):(.+)\@(.+?)\/?$/;
my $ans = check($login, $pass, $host);
if($ans == 230){
print "$check_now[$i] 230 - good!\n"
}
elsif ($ans == 0){
$ans = "$check_now[$i] Error connecting. " if $verbose eq 1;
}
else {
print "$check_now[$i] BAD\n" if $verbose eq 1;
}
#########################################################
exit;
}
}
$once += $pids;
killpidz();
}
sub check{
my ($user, $pass, $host)=@_;
my $data;
my $sock=IO::Socket::INET->new(PeerAddr => $host, PeerPort => 21, Proto => "tcp", Timeout => 5) or return 0;
$sock->recv($data, 1024);
$sock->send("user $user\n");
$sock->recv($data, 1024);
$sock->send("pass $pass\n");
$sock->recv($data, 1024);
return $1 if $data=~/([0-9]{3})/;
}
sub killpidz {
foreach (@forked) {
chomp;
waitpid($_,0);
kill("TERM" => $_)
}
undef @forked;
}