line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Antispam::httpBL; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
1
|
|
|
1
|
|
36629
|
$Antispam::httpBL::VERSION = '0.02'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
10
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
7
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
8
|
1
|
|
|
1
|
|
995
|
use namespace::autoclean; |
|
1
|
|
|
|
|
30651
|
|
|
1
|
|
|
|
|
6
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
607
|
use Antispam::Toolkit 0.06; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Antispam::Toolkit::Result; |
12
|
|
|
|
|
|
|
use MooseX::Types::Moose qw( Str ); |
13
|
|
|
|
|
|
|
use WWW::Honeypot::httpBL; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Moose; |
16
|
|
|
|
|
|
|
use MooseX::StrictConstructor; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
with 'Antispam::Toolkit::Role::IPChecker'; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has access_key => ( |
21
|
|
|
|
|
|
|
is => 'ro', |
22
|
|
|
|
|
|
|
isa => Str, |
23
|
|
|
|
|
|
|
required => 1, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub check_ip { |
27
|
|
|
|
|
|
|
my $self = shift; |
28
|
|
|
|
|
|
|
my %p = @_; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $hp |
31
|
|
|
|
|
|
|
= WWW::Honeypot::httpBL->new( { access_key => $self->access_key() } ); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$hp->fetch( $p{ip} ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
my @details; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
push @details, 'IP address is a comment spammer' |
38
|
|
|
|
|
|
|
if $hp->is_comment_spammer(); |
39
|
|
|
|
|
|
|
push @details, 'IP address is an email harvester' |
40
|
|
|
|
|
|
|
if $hp->is_harvester(); |
41
|
|
|
|
|
|
|
push @details, 'IP address is suspicious' |
42
|
|
|
|
|
|
|
if $hp->is_suspicious(); |
43
|
|
|
|
|
|
|
push @details, 'IP address threat score is ' . $hp->threat_score(); |
44
|
|
|
|
|
|
|
push @details, 'Days since last activity for this IP: ' |
45
|
|
|
|
|
|
|
. $hp->days_since_last_activity(); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# See http://www.projecthoneypot.org/threat_info.php - a score that's much |
48
|
|
|
|
|
|
|
# above 75 is ridiculously unlikely, so we'll just treat >= 75 as a 10. |
49
|
|
|
|
|
|
|
my $score = $hp->threat_score() > 75 ? 10 : $hp->threat_score() / 7.5; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
return Antispam::Toolkit::Result->new( |
52
|
|
|
|
|
|
|
score => $score, |
53
|
|
|
|
|
|
|
details => \@details, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
{ |
58
|
|
|
|
|
|
|
unless ( WWW::Honeypot::httpBL->can('days_since_last_activity') ) { |
59
|
|
|
|
|
|
|
*WWW::Honeypot::httpBL::days_since_last_activity |
60
|
|
|
|
|
|
|
= \&WWW::Honeypot::httpBL::days_since_last_actvity; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
1; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
# ABSTRACT: Antispam checks using Project Honeypot's http blacklist |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=pod |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 NAME |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Antispam::httpBL - Antispam checks using Project Honeypot's http blacklist |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 VERSION |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
version 0.02 |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 SYNOPSIS |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
my $bl = Antispam::httpBL->new( access_key => 'abc123' ); |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
my $result = $bl->check_ip( ip => '1.2.3.4' ); |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
if ( $result->score() ) { ... } |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 DESCRIPTION |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This module implements the L<Antispam::Toolkit::Role::IPChecker> role using |
93
|
|
|
|
|
|
|
Project Honeypot's Http:BL API to check whether a given IP address is |
94
|
|
|
|
|
|
|
associated with spamming or email harvesting. |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=head1 METHODS |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
This class provides the following methods: |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 Antispam::httpBL->new( access_key => ... ) |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
This method constructs a new object. It requires an access key. You can get an |
103
|
|
|
|
|
|
|
access key from the Project Honeypot website at |
104
|
|
|
|
|
|
|
L<http://www.projecthoneypot.org/>. |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head2 $bl->check_ip( ip => ... ) |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
This method checks whether an ip address is associated with some sort of |
109
|
|
|
|
|
|
|
spam-related behavior. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
It returns an L<Antispam::Toolkit::Result> object. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
While the Http:BL API allows for threat scores from 0-255, the result will |
114
|
|
|
|
|
|
|
contain a score from 0-10. This score is the Http:NL threat score divided by |
115
|
|
|
|
|
|
|
7.5, and capped at 10. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
The details in the result object will break down all the results returned by |
118
|
|
|
|
|
|
|
the Http:BL API. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 BUGS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
123
|
|
|
|
|
|
|
C<bug-antispam-httpbl@rt.cpan.org>, or through the web interface at |
124
|
|
|
|
|
|
|
L<http://rt.cpan.org>. I will be notified, and then you'll automatically be |
125
|
|
|
|
|
|
|
notified of progress on your bug as I make changes. |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head1 DONATIONS |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
If you'd like to thank me for the work I've done on this module, please |
130
|
|
|
|
|
|
|
consider making a "donation" to me via PayPal. I spend a lot of free time |
131
|
|
|
|
|
|
|
creating free software, and would appreciate any support you'd care to offer. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Please note that B<I am not suggesting that you must do this> in order for me |
134
|
|
|
|
|
|
|
to continue working on this particular software. I will continue to do so, |
135
|
|
|
|
|
|
|
inasmuch as I have in the past, for as long as it interests me. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Similarly, a donation made in this way will probably not make me work on this |
138
|
|
|
|
|
|
|
software much more, unless I get so many donations that I can consider working |
139
|
|
|
|
|
|
|
on free software full time, which seems unlikely at best. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
To donate, log into PayPal and send money to autarch@urth.org or use the |
142
|
|
|
|
|
|
|
button on this page: L<http://www.urth.org/~autarch/fs-donation.html> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 AUTHOR |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
This software is Copyright (c) 2010 by Dave Rolsky. |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
This is free software, licensed under: |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
The Artistic License 2.0 |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=cut |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
__END__ |
160
|
|
|
|
|
|
|
|