| 1 | 1 | ▶ | use Webqq::Client::Util qw(console); | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 2 | 0 | ▶ | sub Webqq::Client::_check_verify_code{ | ||||||||||||
|
Subroutine
_check_verify_code: not called CC=10 SCAR=47.0
| |||||||||||||||
| 3 | 0 | console "检查验证码...\n"; | |||||||||||||
| 4 | 0 | my $self = shift; | |||||||||||||
| 5 | 0 | my $ua = $self->{ua}; | |||||||||||||
| 6 | 0 | my $api_url = 'https://ssl.ptlogin2.qq.com/check'; | |||||||||||||
| 7 | 0 | ▶ | my @headers = $self->{type} eq 'webqq'? (Referer=>'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=5&mibao_css=m_webqq&appid=1003903&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fweb2.qq.com%2Floginproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20140612002') | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 8 | : (Referer=>'https://ui.ptlogin2.qq.com/cgi-bin/login?daid=164&target=self&style=16&mibao_css=m_webqq&appid=501004106&enable_qlogin=0&no_verifyimg=1&s_url=http%3A%2F%2Fw.qq.com%2Fproxy.html&f_url=loginerroralert&strong_login=1&login_state=10&t=20131024001') | ||||||||||||||
| 9 | ; | ||||||||||||||
| 10 | |||||||||||||||
| 11 | 0 | ▶ | my $query_string_ul = $self->{type} eq 'webqq'? 'http%3A%2F%2Fweb2.qq.com%2Floginproxy.html' | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 12 | : 'http%3A%2F%2Fw.qq.com%2Fproxy.html' | ||||||||||||||
| 13 | ; | ||||||||||||||
| 14 | my @query_string = ( | ||||||||||||||
| 15 | uin => $self->{qq_param}{qq}, | ||||||||||||||
| 16 | appid => $self->{qq_param}{g_appid}, | ||||||||||||||
| 17 | js_ver => $self->{qq_param}{g_pt_version}, | ||||||||||||||
| 18 | js_type => 0, | ||||||||||||||
| 19 | login_sig => $self->{qq_param}{g_login_sig}, | ||||||||||||||
| 20 | 0 | u1 => $query_string_ul, | |||||||||||||
| 21 | r => rand(), | ||||||||||||||
| 22 | ); | ||||||||||||||
| 23 | |||||||||||||||
| 24 | 0 | ▶ | if($self->{type} eq 'smartqq'){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 25 | 0 | unshift @query_string,( | |||||||||||||
| 26 | pt_tea => 1, | ||||||||||||||
| 27 | ); | ||||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | 0 | my @query_string_pairs; | |||||||||||||
| 31 | 0 | ▶ | push @query_string_pairs , shift(@query_string) . "=" . shift(@query_string) while(@query_string); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 32 | |||||||||||||||
| 33 | 0 | $ua->cookie_jar()->set_cookie(0,"chkuin",$self->{qq_param}{qq},"/","ptlogin2.qq.com",); | |||||||||||||
| 34 | |||||||||||||||
| 35 | 0 | ▶ | for(my $i=1;$i<=$self->{ua_retry_times};$i++){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 36 | 0 | my $response = $ua->get($api_url.'?'.join("&",@query_string_pairs),@headers); | |||||||||||||
| 37 | 0 | ▶ | if($response->is_success){ | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 38 | 0 | my $content = $response->content(); | |||||||||||||
| 39 | 0 | ▶ | print $content,"\n" if $self->{debug}; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 40 | 0 | my %d = (); | |||||||||||||
| 41 | 0 | @d{qw( retcode cap_cd md5_salt verifysession isRandSalt)} = $content=~/'(.*?)'/g ; | |||||||||||||
| 42 | 0 | $d{md5_salt} =~ s/\\\\x/\x/g; | |||||||||||||
| 43 | #$self->{qq_param}{md5_salt} = eval qq{"$d{md5_salt}"}; | ||||||||||||||
| 44 | 0 | $self->{qq_param}{md5_salt} = $d{md5_salt}; | |||||||||||||
| 45 | 0 | $self->{qq_param}{cap_cd} = $d{cap_cd}; | |||||||||||||
| 46 | 0 | $self->{qq_param}{verifysession} = $d{verifysession}; | |||||||||||||
| 47 | 0 | $self->{qq_param}{isRandSalt} = $d{isRandSalt}; | |||||||||||||
| 48 | 0 | ▶ | if($d{retcode} ==0){ | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 49 | 0 | console "检查结果: 很幸运,本次登录不需要验证码\n"; | |||||||||||||
| 50 | 0 | $self->{qq_param}{verifycode} = $d{cap_cd}; | |||||||||||||
| 51 | } | ||||||||||||||
| 52 | elsif($d{retcode} == 1){ | ||||||||||||||
| 53 | 0 | console "检查结果: 需要输入图片验证码\n"; | |||||||||||||
| 54 | 0 | $self->{qq_param}{is_need_img_verifycode} = 1 | |||||||||||||
| 55 | } | ||||||||||||||
| 56 | |||||||||||||||
| 57 | 0 | return 1; | |||||||||||||
| 58 | } | ||||||||||||||
| 59 | } | ||||||||||||||
| 60 | 0 | return 0; | |||||||||||||
| 61 | } | ||||||||||||||
| 62 | 1 | 1; | |||||||||||||