line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webqq::Encryption; |
2
|
1
|
|
|
1
|
|
56303
|
use Carp; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
114
|
|
3
|
1
|
|
|
1
|
|
6
|
use Exporter 'import'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
1
|
|
|
1
|
|
3
|
use Digest::MD5 qw(md5_hex); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
41
|
|
5
|
1
|
|
|
1
|
|
355
|
use Webqq::Encryption::TEA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
24
|
|
6
|
1
|
|
|
1
|
|
473
|
use Webqq::Encryption::RSA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
66
|
|
7
|
|
|
|
|
|
|
our @EXPORT_OK = qw(pwd_encrypt pwd_encrypt_js); |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = "1.7"; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
BEGIN{ |
12
|
1
|
|
|
1
|
|
3
|
eval{require JE;}; |
|
1
|
|
|
|
|
112
|
|
13
|
1
|
50
|
|
|
|
400
|
$Webqq::Encryption::has_je = 1 unless $@; |
14
|
|
|
|
|
|
|
} |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub pwd_encrypt{ |
17
|
0
|
|
|
0
|
0
|
|
my ($pwd,$md5_salt,$verifycode,$is_md5_pwd) = @_; |
18
|
0
|
0
|
|
|
|
|
$is_md5_pwd = 1 unless defined $is_md5_pwd; |
19
|
0
|
0
|
|
|
|
|
$pwd = md5_hex($pwd) if $is_md5_pwd == 0; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
$md5_salt = eval qq{"$md5_salt"}; |
22
|
0
|
|
|
|
|
|
my $r = pack "H*",lc $pwd; |
23
|
0
|
|
|
|
|
|
my $s = md5_hex($r . $md5_salt); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
my $a = Webqq::Encryption::TEA::strToHex(uc $verifycode); |
26
|
0
|
|
|
|
|
|
my $l = sprintf "%x",length($a)/2; |
27
|
0
|
|
|
|
|
|
while(length($l)<4){ |
28
|
0
|
|
|
|
|
|
$l = "0" . $l; |
29
|
|
|
|
|
|
|
} |
30
|
0
|
|
|
|
|
|
my $c = Webqq::Encryption::TEA::encrypt($s,$pwd . Webqq::Encryption::TEA::strToHex($md5_salt) . $l . $a ); |
31
|
0
|
|
|
|
|
|
my $u = sprintf "%x",length($c)/2; |
32
|
0
|
|
|
|
|
|
while(length($u)<4){ |
33
|
0
|
|
|
|
|
|
$u = "0" . $u; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
my $h = Webqq::Encryption::RSA::encrypt( pack "H*",$u . $c ); |
37
|
0
|
|
|
|
|
|
$h = MIME::Base64::encode_base64(pack("H*",$h),""); |
38
|
0
|
|
|
|
|
|
$h =~ tr/\/\+=/-*_/; |
39
|
0
|
|
|
|
|
|
return $h; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub pwd_encrypt_js { |
43
|
0
|
0
|
|
0
|
0
|
|
croak "The JE module is not found, You must install it first\n" unless $Webqq::Encryption::has_je; |
44
|
0
|
|
|
|
|
|
my ($pwd,$md5_salt,$verifycode,$is_md5_pwd) = @_; |
45
|
0
|
0
|
|
|
|
|
$is_md5_pwd = 1 unless defined $is_md5_pwd; |
46
|
0
|
|
|
|
|
|
my $je; |
47
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::_je ){ |
48
|
0
|
|
|
|
|
|
$je = $Webqq::Encryption::_je ; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
else{ |
51
|
0
|
|
|
|
|
|
my $javascript; |
52
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::_javascript){ |
53
|
0
|
|
|
|
|
|
$javascript = $Webqq::Encryption::_javascript; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
else{ |
56
|
0
|
|
|
|
|
|
local $/ = undef; |
57
|
0
|
|
|
|
|
|
$javascript = ; |
58
|
0
|
|
|
|
|
|
$Webqq::Encryption::_javascript = $javascript; |
59
|
0
|
|
|
|
|
|
close DATA; |
60
|
|
|
|
|
|
|
} |
61
|
0
|
|
|
|
|
|
$je = JE->new; |
62
|
0
|
|
|
|
|
|
$je->eval($javascript); |
63
|
0
|
0
|
|
|
|
|
croak "load javascript error: $@\n" if $@; |
64
|
0
|
|
|
|
|
|
$Webqq::Encryption::_je = $je; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
my $p = $je->eval(qq# |
68
|
|
|
|
|
|
|
var p = '$pwd'; |
69
|
|
|
|
|
|
|
var salt = '$md5_salt'; |
70
|
|
|
|
|
|
|
var verifycode = '$verifycode'; |
71
|
|
|
|
|
|
|
var r = \$.Encryption.getEncryption(p,salt,verifycode,$is_md5_pwd); |
72
|
|
|
|
|
|
|
return(r); |
73
|
|
|
|
|
|
|
#); |
74
|
|
|
|
|
|
|
|
75
|
0
|
0
|
0
|
|
|
|
if($p and !$@){ |
76
|
0
|
|
|
|
|
|
return $p; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
else{ |
79
|
0
|
|
|
|
|
|
croak "pwd_encrypt_js error $@\n"; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
1; |
84
|
|
|
|
|
|
|
__DATA__ |