]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/http_bl_support.mdwn
reviewing next patch
[ikiwiki.git] / doc / todo / http_bl_support.mdwn
1 [Project Honeypot](http://projecthoneypot.org/) has an HTTP:BL API available to subscribed (it's free, accept donations) people/orgs. There's a basic perl package someone wrote, I'm including a copy here.
2
3 [from here](http://projecthoneypot.org/board/read.php?f=10&i=112&t=112)
4
5 > The [[plugins/blogspam]] service already checks urls against
6 > the surbl, and has its own IP blacklist. The best way to
7 > support the HTTP:BL may be to add a plugin
8 > [there](http://blogspam.repository.steve.org.uk/file/cc858e497cae/server/plugins/).
9 > --[[Joey]] 
10
11 <pre>
12 package Honeypot;
13
14 use Socket qw/inet_ntoa/;
15
16 my $dns = 'dnsbl.httpbl.org';
17 my %types = (
18 0       => 'Search Engine',
19 1       => 'Suspicious',
20 2       => 'Harvester',
21 4       => 'Comment Spammer'
22 );
23 sub query {
24 my $key = shift || die 'You need a key for this, you get one at http://www.projecthoneypot.org';
25 my $ip = shift || do {
26 warn 'no IP for request in Honeypot::query().';
27 return;
28 };
29
30 my @parts = reverse split /\./, $ip;
31 my $lookup_name = join'.', $key, @parts, $dns;
32
33 my $answer = gethostbyname ($lookup_name);
34 return unless $answer;
35 $answer = inet_ntoa($answer);
36 my(undef, $days, $threat, $type) = split /\./, $answer;
37 my @types;
38 while(my($bit, $typename) = each %types) {
39 push @types, $typename if $bit & $type;
40 }
41 return {
42 days => $days,
43 threat => $threat,
44 type => join ',', @types
45 };
46
47 }
48 1;
49 </pre>
50
51 From the page:
52
53 > The usage is simple:
54
55 > use Honeypot;
56 > my $key = 'XXXXXXX'; # your key
57 > my $ip = '....'; the IP you want to check
58 > my $q = Honeypot::query($key, $ip);
59
60 > use Data::Dumper;
61 > print Dumper $q;
62
63 Any chance of having this as a plugin?
64
65 I could give it a go, too. Would be fun to try my hand at Perl. --[[simonraven]]
66
67 [[!tag wishlist]]