line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Webqq::Encryption; |
2
|
1
|
|
|
1
|
|
553
|
use JE; |
|
1
|
|
|
|
|
3729154
|
|
|
1
|
|
|
|
|
24
|
|
3
|
1
|
|
|
1
|
|
15
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
57
|
|
4
|
1
|
|
|
1
|
|
3
|
use Exporter 'import'; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
20
|
|
5
|
1
|
|
|
1
|
|
3
|
use Digest::MD5 qw(md5_hex); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
34
|
|
6
|
1
|
|
|
1
|
|
321
|
use Webqq::Encryption::TEA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
20
|
|
7
|
1
|
|
|
1
|
|
360
|
use Webqq::Encryption::RSA; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
333
|
|
8
|
|
|
|
|
|
|
our @EXPORT_OK = qw(pwd_encrypt pwd_encrypt_js); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub pwd_encrypt{ |
11
|
0
|
|
|
0
|
0
|
|
my ($pwd,$md5_salt,$verifycode,$is_md5_pwd) = @_; |
12
|
0
|
0
|
|
|
|
|
$is_md5_pwd = 1 unless defined $is_md5_pwd; |
13
|
0
|
0
|
|
|
|
|
$pwd = md5_hex($pwd) if $is_md5_pwd == 0; |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
$md5_salt = eval qq{"$md5_salt"}; |
16
|
0
|
|
|
|
|
|
my $h1 = pack "H*",lc $pwd; |
17
|
0
|
|
|
|
|
|
my $s2 = md5_hex($h1 . $md5_salt) ; |
18
|
0
|
|
|
|
|
|
my $rsaH1= Webqq::Encryption::RSA::encrypt($h1); |
19
|
0
|
|
|
|
|
|
my $rsaH1Len = sprintf "%x",length($rsaH1)/2; |
20
|
0
|
|
|
|
|
|
my $hexVcode = Webqq::Encryption::TEA::strToBytes(uc $verifycode); |
21
|
0
|
|
|
|
|
|
my $vcodeLen = "000" . sprintf("%x",length($verifycode)); |
22
|
0
|
|
|
|
|
|
while(length($rsaH1Len) < 4){ |
23
|
0
|
|
|
|
|
|
$rsaH1Len = "0" . $rsaH1Len; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
0
|
|
|
|
|
|
my $saltPwd = Webqq::Encryption::TEA::encrypt($s2,$rsaH1Len . $rsaH1 . Webqq::Encryption::TEA::strToBytes($md5_salt) . $vcodeLen . $hexVcode); |
27
|
0
|
|
|
|
|
|
$saltPwd =~ tr/\/\+=/-*_/; |
28
|
0
|
|
|
|
|
|
return $saltPwd; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub pwd_encrypt_js { |
32
|
0
|
|
|
0
|
0
|
|
my ($pwd,$md5_salt,$verifycode,$is_md5_pwd) = @_; |
33
|
0
|
0
|
|
|
|
|
$is_md5_pwd = 1 unless defined $is_md5_pwd; |
34
|
0
|
|
|
|
|
|
my $je; |
35
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::_je ){ |
36
|
0
|
|
|
|
|
|
$je = $Webqq::Encryption::_je ; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else{ |
39
|
0
|
|
|
|
|
|
my $javascript; |
40
|
0
|
0
|
|
|
|
|
if(defined $Webqq::Encryption::_javascript){ |
41
|
0
|
|
|
|
|
|
$javascript = $Webqq::Encryption::_javascript; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else{ |
44
|
0
|
|
|
|
|
|
local $/ = undef; |
45
|
0
|
|
|
|
|
|
$javascript = ; |
46
|
0
|
|
|
|
|
|
$Webqq::Encryption::_javascript = $javascript; |
47
|
0
|
|
|
|
|
|
close DATA; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
$je = JE->new; |
50
|
0
|
|
|
|
|
|
$je->eval($javascript); |
51
|
0
|
0
|
|
|
|
|
croak "load javascript error: $@\n" if $@; |
52
|
0
|
|
|
|
|
|
$Webqq::Encryption::_je = $je; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
0
|
|
|
|
|
|
my $p = $je->eval(qq# |
56
|
|
|
|
|
|
|
var p = '$pwd'; |
57
|
|
|
|
|
|
|
var salt = '$md5_salt'; |
58
|
|
|
|
|
|
|
var verifycode = '$verifycode'; |
59
|
|
|
|
|
|
|
var r = \$.Encryption.getEncryption(p,salt,verifycode,$is_md5_pwd); |
60
|
|
|
|
|
|
|
return(r); |
61
|
|
|
|
|
|
|
#); |
62
|
|
|
|
|
|
|
|
63
|
0
|
0
|
0
|
|
|
|
if($p and !$@){ |
64
|
0
|
|
|
|
|
|
return $p; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
else{ |
67
|
0
|
|
|
|
|
|
croak "pwd_encrypt_js error $@\n"; |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
__DATA__ |