summaryrefslogtreecommitdiff
path: root/scan-sixxs-asns.pl
diff options
context:
space:
mode:
authorJason Fesler <jfesler@free.gigo.com>2014-04-02 19:48:27 -0700
committerJason Fesler <jfesler@free.gigo.com>2014-04-02 19:48:27 -0700
commitcb465c6f511d63b5445a640735295de967126e2c (patch)
tree4b2e5639c92e9e659bc234b07eefcaae031b501c /scan-sixxs-asns.pl
parente8e6401f8c7bb6ab64dbbcfc10618e792fcbd85b (diff)
downloadmod_ip-1.0.tar.gz
mod_ip-1.0.zip
Imported without history from https://falling-sky.googlecode.com/svn/trunk/mod_ip revision 15111.0
Diffstat (limited to 'scan-sixxs-asns.pl')
-rwxr-xr-xscan-sixxs-asns.pl45
1 files changed, 45 insertions, 0 deletions
diff --git a/scan-sixxs-asns.pl b/scan-sixxs-asns.pl
new file mode 100755
index 0000000..ecbb5d5
--- /dev/null
+++ b/scan-sixxs-asns.pl
@@ -0,0 +1,45 @@
+#! /usr/bin/perl
+
+# Scan the SIXXS pops page,
+# Screen scrape it to generate the CHECK_PREFIX lines in mod_ip.c
+
+# Output will be like
+# CHECK_PREFIX("2001:14b8:100::/40","fihel01.sixxs.net dna");
+# CHECK_PREFIX("2001:15c0:65ff::/48","simbx01.sixxs.net amis");
+# CHECK_PREFIX("2001:15c0:6600::/40","simbx01.sixxs.net amis");
+
+use strict;
+use LWP::Simple qw(get);
+use Socket;
+use Socket6;
+
+my $top_url = "http://www.sixxs.net/pops/prefixes/";
+my $top_html = get($top_url);
+my @lines = split( /\n/, $top_html );
+@lines = grep( m#/tools/whois#, @lines );
+foreach my $line (@lines) {
+ if ( $line =~ m#href="/tools/whois/\?(\S+?)">\1# ) {
+ my ($ip) = $1;
+ my ( $prefix, $bits ) = split( m#/#, $ip );
+ my $buffer = inet_pton( AF_INET6,$prefix );
+ if ( length($buffer) ) {
+ my $ipnew = unpack( "H*", $buffer );
+ my @ipnew = split(//,$ipnew);
+ my $lookup = join(".",reverse(@ipnew),"origin6.asn.cymru.com.");
+ my $cmd = "dig +short +notcp $lookup TXT";
+ system $cmd;
+ }
+ next;
+
+ my $url = "http://test-ipv6.com/ip/?testip=$prefix&asn=1";
+ print STDERR "..";
+ my $got = get($url);
+ print STDERR "..\n";
+ if ( $got =~ m#,"asn":"(\d+)",# ) {
+ print "$prefix $1\n";
+ } else {
+ print $got;
+ }
+ }
+} ## end foreach my $line (@lines)
+