line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Email::ARF::Hotmail; |
2
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
140050
|
use 5.010; |
|
5
|
|
|
|
|
19
|
|
|
5
|
|
|
|
|
193
|
|
4
|
5
|
|
|
5
|
|
28
|
use strict; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
184
|
|
5
|
5
|
|
|
5
|
|
25
|
use warnings; |
|
5
|
|
|
|
|
12
|
|
|
5
|
|
|
|
|
156
|
|
6
|
5
|
|
|
5
|
|
5301
|
use Email::ARF::Report; |
|
5
|
|
|
|
|
438890
|
|
|
5
|
|
|
|
|
168
|
|
7
|
5
|
|
|
5
|
|
48
|
use Email::MIME; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
113
|
|
8
|
5
|
|
|
5
|
|
4973
|
use Regexp::Common qw/net/; |
|
5
|
|
|
|
|
13879
|
|
|
5
|
|
|
|
|
25
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Items to export into callers namespace by default. Note: do not export |
15
|
|
|
|
|
|
|
# names by default without a very good reason. Use EXPORT_OK instead. |
16
|
|
|
|
|
|
|
# Do not simply export all your public functions/methods/constants. |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# This allows declaration use Email::ARF::Hotmail ':all'; |
19
|
|
|
|
|
|
|
# If you do not need this, moving things directly into @EXPORT or @EXPORT_OK |
20
|
|
|
|
|
|
|
# will save memory. |
21
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( 'all' => [ qw( |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
) ] ); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
our @EXPORT = qw( |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
our $VERSION = '0.12'; |
32
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
33
|
|
|
|
|
|
|
|
34
|
5
|
|
|
5
|
|
17997
|
use constant HOTMAIL_SENDER => 'staff@hotmail.com'; |
|
5
|
|
|
|
|
15
|
|
|
5
|
|
|
|
|
2975
|
|
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub _is_hotmail_report { |
37
|
4
|
|
|
4
|
|
10
|
my $parsed = shift; |
38
|
4
|
|
|
|
|
14
|
foreach my $field (('X-Original-Sender', 'Sender', 'From')) { |
39
|
8
|
|
|
|
|
28
|
my $val = $parsed->header($field); |
40
|
8
|
100
|
|
|
|
443
|
if (defined $val) { |
41
|
4
|
|
|
|
|
14
|
$val =~ s/^\/; |
42
|
4
|
|
|
|
|
23
|
$val =~ s/\>$//; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
8
|
100
|
66
|
|
|
53
|
if (defined($val) and $val eq HOTMAIL_SENDER) { |
46
|
4
|
|
|
|
|
23
|
return 1; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
|
50
|
0
|
|
|
|
|
0
|
return 0; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub create_report { |
54
|
4
|
|
|
4
|
1
|
577
|
my $class = shift; |
55
|
4
|
|
|
|
|
10
|
my $message = shift; |
56
|
|
|
|
|
|
|
|
57
|
4
|
|
|
|
|
39
|
my $parsed = Email::MIME->new($message); |
58
|
|
|
|
|
|
|
|
59
|
4
|
50
|
|
|
|
5826
|
if (_is_hotmail_report($parsed)) { |
60
|
|
|
|
|
|
|
# Get the original email and strip off all the extra header bits |
61
|
4
|
|
|
|
|
17
|
my $part = ($parsed->parts)[0]; |
62
|
4
|
|
|
|
|
50
|
my $orig_email = $part->body; |
63
|
4
|
|
|
|
|
284
|
my $hotmail_headers; |
64
|
4
|
100
|
|
|
|
25
|
if ($orig_email =~ /Received: /) { |
65
|
1
|
|
|
|
|
9
|
$orig_email =~ s/^(.*?)\n(Received: )/$2/s; |
66
|
1
|
|
|
|
|
7
|
$hotmail_headers = Email::Simple::Header->new($1); |
67
|
|
|
|
|
|
|
} else { |
68
|
3
|
|
|
|
|
30
|
$hotmail_headers = Email::Simple::Header->new($orig_email); |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
4
|
|
|
|
|
294
|
my $description = "An email abuse report from hotmail"; |
72
|
4
|
|
|
|
|
9
|
my %fields; |
73
|
4
|
|
|
|
|
45
|
$fields{"Feedback-Type"} = "abuse"; |
74
|
4
|
|
|
|
|
11
|
$fields{"User-Agent"} = "Email::ARF::Hotmail-conversion"; |
75
|
4
|
|
|
|
|
11
|
$fields{"Version"} = "0.1"; |
76
|
|
|
|
|
|
|
|
77
|
4
|
|
|
|
|
22
|
my $subject = $parsed->header("Subject"); |
78
|
|
|
|
|
|
|
|
79
|
4
|
|
|
|
|
262
|
my $source_ip; |
80
|
|
|
|
|
|
|
|
81
|
4
|
50
|
|
|
|
43
|
if ($subject =~ /complaint about message from ($RE{net}{IPv4})$/) { |
82
|
4
|
|
|
|
|
1265
|
$source_ip = $1; |
83
|
|
|
|
|
|
|
} else { |
84
|
0
|
|
|
|
|
0
|
die "Couldn't match subject: " . $subject; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
4
|
|
|
|
|
89
|
$fields{"Source-IP"} = $source_ip; |
88
|
|
|
|
|
|
|
|
89
|
4
|
|
|
|
|
61
|
my $or = $hotmail_headers->header('X-HmXmrOriginalRecipient'); |
90
|
|
|
|
|
|
|
|
91
|
4
|
100
|
|
|
|
103
|
if ($or) { |
92
|
1
|
|
|
|
|
3
|
$fields{'Original-Rcpt-To'} = $or; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
4
|
|
|
|
|
20
|
my $original_email = Email::MIME->new($orig_email); |
96
|
|
|
|
|
|
|
|
97
|
4
|
|
|
|
|
1752
|
return Email::ARF::Report->create( |
98
|
|
|
|
|
|
|
original_email => $original_email, |
99
|
|
|
|
|
|
|
description => $description, |
100
|
|
|
|
|
|
|
fields => \%fields |
101
|
|
|
|
|
|
|
); |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
} else { |
104
|
0
|
|
|
|
|
|
die "Not a hotmail abuse report"; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
1; |
109
|
|
|
|
|
|
|
__END__ |