]> sipb.mit.edu Git - ikiwiki.git/blob - doc/wishlist/http_bl_support.mdwn
30fb9c9b3493cadbb55857464e4c82ba1209fbf3
[ikiwiki.git] / doc / wishlist / 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 <pre>
6 package Honeypot;
7
8 use Socket qw/inet_ntoa/;
9
10 my $dns = 'dnsbl.httpbl.org';
11 my %types = (
12 0       => 'Search Engine',
13 1       => 'Suspicious',
14 2       => 'Harvester',
15 4       => 'Comment Spammer'
16 );
17 sub query {
18 my $key = shift || die 'You need a key for this, you get one at http://www.projecthoneypot.org';
19 my $ip = shift || do {
20 warn 'no IP for request in Honeypot::query().';
21 return;
22 };
23
24 my @parts = reverse split /\./, $ip;
25 my $lookup_name = join'.', $key, @parts, $dns;
26
27 my $answer = gethostbyname ($lookup_name);
28 return unless $answer;
29 $answer = inet_ntoa($answer);
30 my(undef, $days, $threat, $type) = split /\./, $answer;
31 my @types;
32 while(my($bit, $typename) = each %types) {
33 push @types, $typename if $bit & $type;
34 }
35 return {
36 days => $days,
37 threat => $threat,
38 type => join ',', @types
39 };
40
41 }
42 1;
43 </pre>
44
45 From the page:
46
47 > The usage is simple:
48
49 > use Honeypot;
50 > my $key = 'XXXXXXX'; # your key
51 > my $ip = '....'; the IP you want to check
52 > my $q = Honeypot::query($key, $ip);
53
54 > use Data::Dumper;
55 > print Dumper $q;
56
57 Any chance of having this as a plugin?
58
59 I could give it a go, too. Would be fun to try my hand at Perl. --[[simonraven]]