line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mojo::Webqq::Model::Ext; |
2
|
|
|
|
|
|
|
BEGIN{ |
3
|
1
|
|
|
1
|
|
5
|
eval{ |
4
|
1
|
|
|
|
|
223
|
require Webqq::Encryption; |
5
|
|
|
|
|
|
|
}; |
6
|
1
|
50
|
|
|
|
958
|
unless($@){ |
7
|
0
|
|
|
|
|
|
$Mojo::Webqq::Model::Ext::has_webqq_encryption = 1; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
our $_retcode; |
11
|
|
|
|
|
|
|
our $_verifycode; |
12
|
|
|
|
|
|
|
our $_md5_salt; |
13
|
|
|
|
|
|
|
our $_verifysession; |
14
|
|
|
|
|
|
|
our $_is_rand_salt; |
15
|
|
|
|
|
|
|
our $_api_check_sig; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub model_ext_authorize{ |
18
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
19
|
0
|
0
|
|
|
|
|
if(not $Mojo::Webqq::Model::Ext::has_webqq_encryption){ |
20
|
0
|
|
|
|
|
|
$self->warn("未安装 Webqq::Encryption 模块,无法获取扩展信息,安装方法参见: https://metacpan.org/pod/distribution/Webqq-Encryption/lib/Webqq/Encryption.pod"); |
21
|
0
|
|
|
|
|
|
$self->model_ext(0); |
22
|
0
|
|
|
|
|
|
return; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
0
|
0
|
0
|
|
|
|
if($self->login_type eq 'login' and $self->account !~ /^\d+$/){ |
26
|
0
|
|
|
|
|
|
$self->error("使用账号密码登录方式,account参数不是有效的QQ号码"); |
27
|
0
|
|
|
|
|
|
$self->stop(); |
28
|
|
|
|
|
|
|
} |
29
|
0
|
0
|
|
|
|
|
if($self->pwd){ |
30
|
0
|
0
|
|
|
|
|
$self->info("开始账号密码方式登录...") if $self->login_type eq 'login'; |
31
|
0
|
0
|
|
|
|
|
$self->info("尝取扩展信息授权...") if $self->login_type eq 'qrlogin'; |
32
|
0
|
|
0
|
|
|
|
my $ret = $self->_model_ext_prepare() && $self->_model_ext_check() && $self->_model_ext_login() && $self->_model_ext_check_sig(); |
33
|
0
|
0
|
|
|
|
|
if($ret){ |
34
|
0
|
|
|
|
|
|
$self->model_ext($ret); |
35
|
|
|
|
|
|
|
#$self->info("账号密码方式登录成功"); |
36
|
0
|
|
|
|
|
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
else{ |
39
|
|
|
|
|
|
|
#$self->info("账号密码方式失败"); |
40
|
0
|
|
|
|
|
|
return 0; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
else{ |
44
|
0
|
|
|
|
|
|
$self->warn("未设置有效的登录密码,无法进行登录"); |
45
|
0
|
|
|
|
|
|
return 0; |
46
|
|
|
|
|
|
|
} |
47
|
0
|
|
|
|
|
|
return 1; |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
sub _model_ext_prepare { |
50
|
0
|
|
|
0
|
|
|
my $self = shift; |
51
|
0
|
|
|
|
|
|
$self->debug("账号登录中(prepare)..."); |
52
|
0
|
|
|
|
|
|
my(undef,$ua,$tx) = $self->http_get('https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=715030901&daid=73&pt_no_auth=1&s_url=http%3A%2F%2Fqun.qq.com%2F',{Referer=>'http://qun.qq.com/',ua_debug_res_body=>0, blocking=> 1}); |
53
|
0
|
0
|
|
|
|
|
return $tx->res->code == 200?1:0; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub _model_ext_check { |
57
|
0
|
|
|
0
|
|
|
my $self = shift; |
58
|
0
|
|
|
|
|
|
$self->debug("账号登录中(check)..."); |
59
|
0
|
0
|
|
|
|
|
my $content = $self->http_get( |
60
|
|
|
|
|
|
|
$self->gen_url('https://ssl.ptlogin2.qq.com/check', |
61
|
|
|
|
|
|
|
( |
62
|
|
|
|
|
|
|
regmaster => '', |
63
|
|
|
|
|
|
|
pt_tea => 2, |
64
|
|
|
|
|
|
|
pt_vcode => 1, |
65
|
|
|
|
|
|
|
uin => ($self->login_type eq 'login'?$self->account:$self->uid), |
66
|
|
|
|
|
|
|
appid => 715030901, |
67
|
|
|
|
|
|
|
js_ver => 10233, |
68
|
|
|
|
|
|
|
js_type => 1, |
69
|
|
|
|
|
|
|
login_sig => $self->search_cookie("pt_login_sig"), |
70
|
|
|
|
|
|
|
u1 => 'http%3A%2F%2Fqun.qq.com%2F', |
71
|
|
|
|
|
|
|
r => rand(), |
72
|
|
|
|
|
|
|
pt_uistyle=> 40, |
73
|
|
|
|
|
|
|
pt_jstoken=> 485008785 |
74
|
|
|
|
|
|
|
) |
75
|
|
|
|
|
|
|
), |
76
|
|
|
|
|
|
|
{blocking=>1,Referer => 'https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=715030901&daid=73&pt_no_auth=1&s_url=http%3A%2F%2Fqun.qq.com%2F'}, |
77
|
|
|
|
|
|
|
); |
78
|
0
|
|
|
|
|
|
my($retcode,$verifycode,$md5_salt,$verifysession,$is_rand_salt) = $content =~/'([^']*)'/g; |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if($retcode == 0 ){ |
81
|
0
|
|
|
|
|
|
$_retcode = $retcode; |
82
|
0
|
|
|
|
|
|
$_verifycode = $verifycode; |
83
|
0
|
|
|
|
|
|
$_md5_salt = $md5_salt; |
84
|
0
|
|
|
|
|
|
$_verifysession = $verifysession; |
85
|
0
|
|
|
|
|
|
$_is_rand_salt = $is_rand_salt; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
else{ |
88
|
0
|
|
|
|
|
|
$self->error("账号登录失败: 可能因为登录环境变化引起,解决方法参见:https://github.com/sjdy521/Mojo-Webqq/issues/183"); |
89
|
|
|
|
|
|
|
} |
90
|
0
|
0
|
|
|
|
|
return $retcode == 0? 1 : 0; |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _model_ext_login{ |
94
|
0
|
|
|
0
|
|
|
my $self = shift; |
95
|
0
|
|
|
|
|
|
$self->debug("账号登录中(login)..."); |
96
|
0
|
0
|
0
|
|
|
|
my $content = $self->http_get( |
|
|
|
0
|
|
|
|
|
97
|
|
|
|
|
|
|
$self->gen_url('https://ssl.ptlogin2.qq.com/login', |
98
|
|
|
|
|
|
|
( |
99
|
|
|
|
|
|
|
u => ($self->login_type eq 'login'?$self->account:$self->uid), |
100
|
|
|
|
|
|
|
verifycode => $_verifycode, |
101
|
|
|
|
|
|
|
pt_vcode_v1 => 0, |
102
|
|
|
|
|
|
|
pt_verifysession_v1 => ,$_verifysession // $self->search_cookie('verifysession'), |
103
|
|
|
|
|
|
|
p => Webqq::Encryption::pwd_encrypt($self->pwd,$_md5_salt,$_verifycode,1), |
104
|
|
|
|
|
|
|
pt_randsalt => $_is_rand_salt || 0,, |
105
|
|
|
|
|
|
|
pt_jstoken => 485008785, |
106
|
|
|
|
|
|
|
u1 => 'http%3A%2F%2Fqun.qq.com%2F', |
107
|
|
|
|
|
|
|
ptredirect => 1, |
108
|
|
|
|
|
|
|
h => 1, |
109
|
|
|
|
|
|
|
t => 1, |
110
|
|
|
|
|
|
|
g => 1, |
111
|
|
|
|
|
|
|
from_ui => 1, |
112
|
|
|
|
|
|
|
ptlang => 2052, |
113
|
|
|
|
|
|
|
action => '1-14-1515074375763', |
114
|
|
|
|
|
|
|
js_ver => 10233, |
115
|
|
|
|
|
|
|
js_type => 1, |
116
|
|
|
|
|
|
|
login_sig => $self->search_cookie("pt_login_sig"), |
117
|
|
|
|
|
|
|
pt_uistyle => 40, |
118
|
|
|
|
|
|
|
aid => 715030901, |
119
|
|
|
|
|
|
|
daid => 73, |
120
|
|
|
|
|
|
|
has_onekey => 1, |
121
|
|
|
|
|
|
|
) |
122
|
|
|
|
|
|
|
) . '&', |
123
|
|
|
|
|
|
|
{ |
124
|
|
|
|
|
|
|
Referer => 'https://xui.ptlogin2.qq.com/cgi-bin/xlogin?appid=715030901&daid=73&pt_no_auth=1&s_url=http%3A%2F%2Fqun.qq.com%2F', |
125
|
|
|
|
|
|
|
blocking => 1, |
126
|
|
|
|
|
|
|
}, |
127
|
|
|
|
|
|
|
); |
128
|
|
|
|
|
|
|
|
129
|
0
|
|
|
|
|
|
my($retcode,undef,$api_check_sig,undef,$info,$nick) = $content =~/'([^']*)'/g; |
130
|
0
|
0
|
|
|
|
|
if($retcode != 0){ |
131
|
0
|
|
|
|
|
|
$self->warn("账号登录失败: $info"); |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else{ |
134
|
0
|
|
|
|
|
|
$_api_check_sig = $api_check_sig; |
135
|
|
|
|
|
|
|
} |
136
|
0
|
0
|
|
|
|
|
return $retcode == 0?1:0; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub _model_ext_check_sig { |
140
|
0
|
|
|
0
|
|
|
my $self = shift; |
141
|
0
|
|
|
|
|
|
$self->debug("账号登录中(check_sig)..."); |
142
|
0
|
|
|
|
|
|
my(undef,$ua,$tx) = $self->http_get($_api_check_sig,{ua_debug_res_body=>0}); |
143
|
0
|
0
|
|
|
|
|
return $tx->res->code == 200?1:0; |
144
|
|
|
|
|
|
|
} |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
1; |