summaryrefslogtreecommitdiffstats
path: root/abuse.pl
blob: 42e31a49356167a754dc33747170afea9a0b2541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/perl
use warnings;
use strict;
use File::Basename;
use Net::IP;
use Net::DNS;

my $abusednsbl = "abuse-contacts.abusix.org";

if (@ARGV == 0) {
  print "usage: ", basename($0), " IP ...\n";
  exit 1;
}

my $res = Net::DNS::Resolver->new;

for my $host (@ARGV) {
  my $IP = $host;
  
  my $ip = new Net::IP ($IP);
  my $querystring = $ip->reverse_ip().$abusednsbl;
  $querystring =~ s/\.in-addr\.arpa//;
  my $query = $res->query($querystring, "txt");
  if ($query) {
    print (($query->answer)[0]->rdata, "\n");
  } else {
    print "no abuse address for $IP\n";
    exit 1;
  }
}