line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::YahooMessenger::HTTPS; |
2
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
3
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
30
|
|
4
|
1
|
|
|
1
|
|
1590
|
use WWW::Mechanize; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use MD5; |
6
|
|
|
|
|
|
|
use URI::Escape; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use constant YMSG_LOGIN_URL => |
9
|
|
|
|
|
|
|
'https://login.yahoo.com/config/pwtoken_get?src=ymsgr&ts=&login=%s&passwd=%s&chal=%s'; |
10
|
|
|
|
|
|
|
use constant YMSG_TOKEN_URL => |
11
|
|
|
|
|
|
|
'https://login.yahoo.com/config/pwtoken_login?src=ymsgr&ts=&token='; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new { |
14
|
|
|
|
|
|
|
my ( $class, $id, $password, $seed ) = @_; |
15
|
|
|
|
|
|
|
my $self = bless { _SEED_ => $seed }, $class; |
16
|
|
|
|
|
|
|
$self->_https_login( $id, $password, $seed ); |
17
|
|
|
|
|
|
|
return $self; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _https_login { |
21
|
|
|
|
|
|
|
my ( $self, $username, $password, $seed ) = @_; |
22
|
|
|
|
|
|
|
my $mech = WWW::Mechanize->new( agent => 'Mozilla/5.0', noproxy => 1 ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $url = |
25
|
|
|
|
|
|
|
sprintf( YMSG_LOGIN_URL, $username, $password, uri_escape($seed) ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
$mech->get($url); |
28
|
|
|
|
|
|
|
my @lines = split( "\r\n", $mech->content() ); |
29
|
|
|
|
|
|
|
chomp(@lines); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
my ( undef, $token ) = split( '=', $lines[1] ); |
32
|
|
|
|
|
|
|
chomp($token); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$url = YMSG_TOKEN_URL . $token; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
$mech->get($url); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
@lines = split( "\r\n", $mech->content() ); |
39
|
|
|
|
|
|
|
chomp(@lines); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
$self->{_CRUMB_} = $lines[1]; |
42
|
|
|
|
|
|
|
$self->{_Y_} = $lines[2]; |
43
|
|
|
|
|
|
|
$self->{_T_} = $lines[3]; |
44
|
|
|
|
|
|
|
$self->{_CRUMB_} =~ s/crumb=//g; |
45
|
|
|
|
|
|
|
$self->{_Y_} =~ s/Y=//g; |
46
|
|
|
|
|
|
|
$self->{_T_} =~ s/T=//g; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
return $self; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub y_string { |
52
|
|
|
|
|
|
|
return shift->{_Y_}; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub t_string { |
56
|
|
|
|
|
|
|
return shift->{_T_}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub crumb { |
60
|
|
|
|
|
|
|
return shift->{_CRUMB_}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
sub md5_string { |
64
|
|
|
|
|
|
|
my $self = shift; |
65
|
|
|
|
|
|
|
return $self->ym_hash( MD5->hash("$self->{_CRUMB_}$self->{_SEED_}") ); |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub ym_hash { |
69
|
|
|
|
|
|
|
my ( $self, $in ) = @_; |
70
|
|
|
|
|
|
|
my @base64digits = split( '', |
71
|
|
|
|
|
|
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
72
|
|
|
|
|
|
|
. "abcdefghijklmnopqrstuvwxyz" |
73
|
|
|
|
|
|
|
. "0123456789._" ); |
74
|
|
|
|
|
|
|
my @in = split( '', $in ); |
75
|
|
|
|
|
|
|
my $out = ''; |
76
|
|
|
|
|
|
|
my $length = 16; |
77
|
|
|
|
|
|
|
for ( ; $length >= 3 ; $length -= 3 ) { |
78
|
|
|
|
|
|
|
$out .= $base64digits[ ord( $in[0] ) >> 2 ]; |
79
|
|
|
|
|
|
|
$out .= |
80
|
|
|
|
|
|
|
$base64digits[ ( ( ord( $in[0] ) << 4 ) & 0x30 ) | |
81
|
|
|
|
|
|
|
( ord( $in[1] ) >> 4 ) ]; |
82
|
|
|
|
|
|
|
$out .= |
83
|
|
|
|
|
|
|
$base64digits[ ( ( ord( $in[1] ) << 2 ) & 0x3c ) | |
84
|
|
|
|
|
|
|
( ord( $in[2] ) >> 6 ) ]; |
85
|
|
|
|
|
|
|
$out .= $base64digits[ ord( $in[2] ) & 0x3f ]; |
86
|
|
|
|
|
|
|
shift(@in); |
87
|
|
|
|
|
|
|
shift(@in); |
88
|
|
|
|
|
|
|
shift(@in); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
if ( $length > 0 ) { |
91
|
|
|
|
|
|
|
$out .= $base64digits[ ord( $in[0] ) >> 2 ]; |
92
|
|
|
|
|
|
|
my $fragment = ( ord( $in[0] ) << 4 ) & 0x30; |
93
|
|
|
|
|
|
|
if ( $length > 1 ) { |
94
|
|
|
|
|
|
|
$fragment |= ord( $in[1] ) >> 4; |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
$out .= $base64digits[$fragment]; |
97
|
|
|
|
|
|
|
$out .= |
98
|
|
|
|
|
|
|
( $length < 2 ) |
99
|
|
|
|
|
|
|
? '-' |
100
|
|
|
|
|
|
|
: $base64digits[ ( ord( $in[1] ) << 2 ) & 0x3c ]; |
101
|
|
|
|
|
|
|
$out .= '-'; |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} |
104
|
|
|
|
|
|
|
return $out; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
1; |