YahooMessenger/HTTPS.pm

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