#!/usr/bin/perl -w # ================================================== # Author: Zeuxis Lo # Date : 2013-01-28 21:13 # Script: ftp-scan.pl # Remark: Scan FTP servers allowing Anonymous Login # ================================================== use strict; use warnings; use threads; use Thread::Queue; use IO::Socket::INET; use Net::FTP;
our $ftp_address_queue = Thread::Queue->new();
subftp{ while (my $ftp_address = $ftp_address_queue->dequeue_nb()) { if ($ftp_address eq "exit") { last; } my $ftp = Net::FTP->new($ftp_address, Timeout =>3); if (!$ftp || !$ftp->login()) { print"Not Working: $ftp_address\n"; }else{ print"Working: $ftp_address\n"; open(FILE, ">>ftp-scan.txt"); print(FILE "$ftp_address\n"); close(FILE); $ftp->quit(); } } }
subscanner{ my $ip_range_queue = shift; while (my $ip_address = $ip_range_queue->dequeue_nb()) { my $error = 0; my $socket = IO::Socket::INET->new( PeerAddr => $ip_address, PeerPort =>"21", Proto =>'tcp', Timeout =>3, ) or $error = 1; if ($error == 1) { print"No FTP: $ip_address\n"; }else{ $ftp_address_queue->enqueue($ip_address); print"FTP: $ip_address\n"; open(FILE, ">>ftp-scan.txt"); print(FILE "$ip_address\n"); close(FILE); close($socket); } } }
subip_range() { my $start_ip = $ARGV[0]; my $end_ip = $ARGV[1]; my $ip_range_queue = Thread::Queue->new(); my @start = split(/\./, $start_ip); my @end = split(/\./, $end_ip); $ip_range_queue->enqueue($start_ip);