line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Net::MSN::PassPort - PassPort class used by Net::MSN and Net::MSN::SB.
|
2
|
|
|
|
|
|
|
# Originally written by:
|
3
|
|
|
|
|
|
|
# Adam Swann - http://www.adamswann.com/library/2002/msn-perl/
|
4
|
|
|
|
|
|
|
# Modified by:
|
5
|
|
|
|
|
|
|
# David Radunz - http://www.boxen.net/
|
6
|
|
|
|
|
|
|
#
|
7
|
|
|
|
|
|
|
# $Id: PassPort.pm,v 1.1 2003/10/18 03:10:49 david Exp $
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
package Net::MSN::PassPort;
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
8
|
use strict;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
44
|
|
12
|
1
|
|
|
1
|
|
8
|
use warnings;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
36
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
BEGIN {
|
15
|
|
|
|
|
|
|
# Modules
|
16
|
|
|
|
|
|
|
# CPAN
|
17
|
1
|
|
|
1
|
|
1532
|
use LWP::UserAgent;
|
|
1
|
|
|
|
|
1833794
|
|
|
1
|
|
|
|
|
36
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# Package specific
|
20
|
1
|
|
|
1
|
|
611
|
use Net::MSN::Debug;
|
|
1
|
|
|
|
|
16
|
|
|
1
|
|
|
|
|
31
|
|
21
|
|
|
|
|
|
|
|
22
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION);
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
61
|
|
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
2
|
$VERSION = do { my @r=(q$Revision: 1.1 $=~/\d+/g); sprintf "%d."."%03d"x$#r,@r };
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
581
|
|
25
|
|
|
|
|
|
|
}
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new {
|
28
|
0
|
|
|
0
|
0
|
|
my ($class, %args) = @_;
|
29
|
|
|
|
|
|
|
|
30
|
0
|
|
0
|
|
|
|
my $self = bless({
|
31
|
|
|
|
|
|
|
'Version' => $VERSION,
|
32
|
|
|
|
|
|
|
'Debug' => 0,
|
33
|
|
|
|
|
|
|
'Debug_Lvl' => 0,
|
34
|
|
|
|
|
|
|
'Debug_Log' => '',
|
35
|
|
|
|
|
|
|
'Debug_STDERR' => 1,
|
36
|
|
|
|
|
|
|
'Debug_STDOUT' => 0,
|
37
|
|
|
|
|
|
|
'Debug_LogCaller' => 1,
|
38
|
|
|
|
|
|
|
'Debug_LogTime' => 1,
|
39
|
|
|
|
|
|
|
'Debug_LogLvl' => 1,
|
40
|
|
|
|
|
|
|
'_L' => '',
|
41
|
|
|
|
|
|
|
'_Log' => ''
|
42
|
|
|
|
|
|
|
}, ref($class) || $class);
|
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
$self->set_options(\%args);
|
45
|
0
|
|
|
|
|
|
$self->_new_Log_obj();
|
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
return $self;
|
48
|
|
|
|
|
|
|
}
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub set_options {
|
51
|
0
|
|
|
0
|
0
|
|
my ($self, $opts) = @_;
|
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
my %opts = %$opts;
|
54
|
0
|
|
|
|
|
|
foreach my $key (keys %opts) {
|
55
|
0
|
0
|
|
|
|
|
if (ref $opts{$key} eq 'HASH') {
|
56
|
0
|
|
|
|
|
|
$self->{$key} =
|
57
|
0
|
|
|
|
|
|
\%{ merge($opts{$key}, $self->{$key}) };
|
58
|
|
|
|
|
|
|
} else {
|
59
|
0
|
|
|
|
|
|
$self->{$key} = $opts{$key};
|
60
|
|
|
|
|
|
|
}
|
61
|
|
|
|
|
|
|
}
|
62
|
|
|
|
|
|
|
}
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
sub _new_Log_obj {
|
65
|
0
|
|
|
0
|
|
|
my ($self) = @_;
|
66
|
|
|
|
|
|
|
|
67
|
0
|
0
|
0
|
|
|
|
return if ((defined $self->{_L} && $self->{_L}) ||
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
68
|
|
|
|
|
|
|
(defined $self->{_Log} && $self->{_Log}));
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# Create a new Net::MSN::Debug object for debug
|
71
|
0
|
|
|
|
|
|
$self->{_L} = new Net::MSN::Debug(
|
72
|
|
|
|
|
|
|
'Debug' => $self->{Debug},
|
73
|
|
|
|
|
|
|
'Level' => $self->{Debug_Lvl},
|
74
|
|
|
|
|
|
|
'LogFile' => $self->{Debug_Log},
|
75
|
|
|
|
|
|
|
'STDERR' => $self->{Debug_STDERR},
|
76
|
|
|
|
|
|
|
'STDOUT' => $self->{Debug_STDOUT},
|
77
|
|
|
|
|
|
|
'LogCaller' => $self->{Debug_LogCaller},
|
78
|
|
|
|
|
|
|
'LogTime' => $self->{Debug_LogTime},
|
79
|
|
|
|
|
|
|
'LogLevel' => $self->{Debug_LogLvl}
|
80
|
|
|
|
|
|
|
);
|
81
|
|
|
|
|
|
|
|
82
|
0
|
0
|
0
|
|
|
|
die "Unable to create L obj!\n"
|
83
|
|
|
|
|
|
|
unless (defined $self->{_L} && $self->{_L});
|
84
|
|
|
|
|
|
|
|
85
|
0
|
|
|
|
|
|
$self->{_Log} = $self->{_L}->get_log_obj();
|
86
|
|
|
|
|
|
|
|
87
|
0
|
0
|
0
|
|
|
|
die "Unable to create Log obj!\n"
|
88
|
|
|
|
|
|
|
unless (defined ($self->{_Log} && $self->{_Log}));
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub login {
|
92
|
0
|
|
|
0
|
0
|
|
my ($self, $handle, $password, $auth_key) = @_;
|
93
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my $passport_url = 'https://login.passport.com/login2.srf';
|
95
|
|
|
|
|
|
|
|
96
|
0
|
|
|
|
|
|
my %headers = (
|
97
|
|
|
|
|
|
|
'Authorization' => 'Passport1.4 '.
|
98
|
|
|
|
|
|
|
'OrgVerb=GET,OrgURL=http%3A%2F%2Fmessenger%2Emsn%2Ecom,'.
|
99
|
|
|
|
|
|
|
'sign-in='. $handle.
|
100
|
|
|
|
|
|
|
',pwd='. $password. ','. $auth_key,
|
101
|
|
|
|
|
|
|
'Connection' => 'Keep-Alive',
|
102
|
|
|
|
|
|
|
'Cache-Control' => 'no-cache'
|
103
|
|
|
|
|
|
|
);
|
104
|
|
|
|
|
|
|
|
105
|
0
|
|
|
|
|
|
my $ua = new LWP::UserAgent;
|
106
|
0
|
|
|
|
|
|
$ua->agent('MSMSGS');
|
107
|
0
|
|
|
|
|
|
my $res = $ua->get($passport_url, %headers);
|
108
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
$self->{_Log}("Logging into PassPort on: ". $passport_url. " as: ".
|
110
|
|
|
|
|
|
|
$handle, 3);
|
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ($res->is_success) {
|
113
|
0
|
|
|
|
|
|
$self->{_Log}("Authentication Successful", 3);
|
114
|
0
|
|
|
|
|
|
my $auth_info = $res->header('Authentication-Info');
|
115
|
0
|
0
|
|
|
|
|
unless (defined $auth_info) {
|
116
|
0
|
|
|
|
|
|
$self->{_Log}("No Authentication-Info Header Sent", 1);
|
117
|
0
|
|
|
|
|
|
return;
|
118
|
|
|
|
|
|
|
}
|
119
|
0
|
0
|
|
|
|
|
if ($auth_info =~ /from-PP\=\'(.+?)\'\,/) {
|
120
|
0
|
|
|
|
|
|
return $1;
|
121
|
|
|
|
|
|
|
} else {
|
122
|
0
|
|
|
|
|
|
$self->{_Log}("Unable to parse Authentication-Info for Session Key", 1);
|
123
|
|
|
|
|
|
|
}
|
124
|
|
|
|
|
|
|
} else {
|
125
|
0
|
0
|
|
|
|
|
if ($res->status_line =~ /401/) {
|
126
|
0
|
|
|
|
|
|
$self->{_Log}("Authentication Failed");
|
127
|
|
|
|
|
|
|
} else {
|
128
|
0
|
|
|
|
|
|
die "Error while getting ", $res->request->uri,
|
129
|
|
|
|
|
|
|
" -- ", $res->status_line, "\nAborting";
|
130
|
|
|
|
|
|
|
}
|
131
|
|
|
|
|
|
|
}
|
132
|
|
|
|
|
|
|
}
|
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
return 1;
|