summaryrefslogtreecommitdiff
path: root/contrib/whoisd/whoisd.pl
diff options
context:
space:
mode:
authorepoch <epoch@hacking.allowed.org>2013-11-01 09:12:45 +0000
committerepoch <epoch@hacking.allowed.org>2013-11-01 09:12:45 +0000
commit1c0dfe1d6fbd33f24da3e8bad01acbb7565e6d3d (patch)
tree0789805e80ddb6ad8abe10d03bddd563bbff57b2 /contrib/whoisd/whoisd.pl
parent98c417e0e11819b4250bf9852adbc49f52f3c8b5 (diff)
downloadresdb-1c0dfe1d6fbd33f24da3e8bad01acbb7565e6d3d.tar.gz
resdb-1c0dfe1d6fbd33f24da3e8bad01acbb7565e6d3d.zip
Added mkz to anonet and as many of the needed files as I could think of.
That as.c is the part of NetBSD traceroute that does AS lookups.
Diffstat (limited to 'contrib/whoisd/whoisd.pl')
-rwxr-xr-xcontrib/whoisd/whoisd.pl122
1 files changed, 80 insertions, 42 deletions
diff --git a/contrib/whoisd/whoisd.pl b/contrib/whoisd/whoisd.pl
index 67636c9..e1854a0 100755
--- a/contrib/whoisd/whoisd.pl
+++ b/contrib/whoisd/whoisd.pl
@@ -31,27 +31,30 @@ if($QUERY eq "!!\n") {
$HACK=1;
}
-# ASNs
-if($QUERY =~ m/^AS(.+?)$/) {
- printf "%% AS section for %s\n", $QUERY;
- my $AS=$1;
- chdir("$RESDB/db/as") || die "%% error";
- if(chdir($AS) || die "%% error") {
- foreach(split(/\n/,`grep '' -r .`)) {
- $out = $_;
- $out =~ s/^\.\///g;
- $out =~ m/^(.+?):(.+?)$/;
- ($title, $value) = ($1, $2);
- printf "%-20s %s\n", $title . ":", $value;
- if($title eq "owner") {
- $QUERY = $value;
+sub ASN_lookup {
+ if($QUERY =~ m/^AS(.+?)$/) {
+ printf "%% AS section for %s\n", $QUERY;
+ my $AS=$1;
+ chdir("$RESDB/db/as") || die "%% error";
+ if(chdir($AS) || die "%% error") {
+ foreach(split(/\n/,`grep '' -r .`)) {
+ $out = $_;
+ $out =~ s/^\.\///g;
+ $out =~ m/^(.+?):(.+?)$/;
+ ($title, $value) = ($1, $2);
+ printf "%-20s %s\n", $title . ":", $value;
+ if($title eq "owner") {
+ $QUERY = $value;
+ }
}
+ } else {
+ printf "AS not found.";
}
- } else {
- printf "AS not found.";
}
}
+ASN_lookup();
+
# IPv4 addresses
if($QUERY =~ m/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/) {
printf "%% IP section for %s\n", $QUERY unless $HACK;
@@ -74,7 +77,6 @@ if($QUERY =~ m/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-
}
}
-
# if we get here and there's still a . in the query it is probably a domain.
if($QUERY =~ m/\./) {
printf "%% domain section for %s\n", $QUERY;
@@ -102,34 +104,70 @@ if($QUERY =~ m/\./) {
}
}
+#ipv6 addresses
+#if($QUERY =~ m/:/) {#close enough?
+# $QUERY =~ s/://g;
+# $QUERY =~ s/[^a-fA-F0-9]//g;
+# $QUERY = uc($QUERY);
+# chdir("$RESDB/db/ip6");
+# foreach(split(//,$QUERY)) {
+# chdir($_);;
+# }
+# foreach(split(/\n/,`grep '' -r .`)) {
+# $out = $_;
+# $out =~ s/^\.\///g;
+# $out =~ m/^(.+?):(.+?)$/;
+# ($title, $value) = ($1, $2);
+# printf "%-20s %s\n", $title . ":", $value;
+# if($title eq "owner") {
+# $QUERY = $value;
+# }
+# }
+#}
+
+
# default to assuming it is a name.
-printf "%% user section for '%s'\n", $QUERY unless $HACK;
+ printf "%% user section for '%s'\n", $QUERY unless $HACK;
-chdir("$RESDB/db/usr") || die "%% error";
-if(chdir($QUERY)) {
- foreach(split(/\n/,`grep '' -r .`)) {
+ chdir("$RESDB/db/usr") || die "%% error";
+ if(chdir($QUERY)) {
+ foreach(split(/\n/,`grep '' -r .`)) {
+ $out = $_;
+ $out =~ s/^\.\///g;
+ $out =~ m/^(.+?):(.+?)$/;
+ ($title, $value) = ($1, $2);
+ printf "%-20s %s\n", $title . ":", $value unless $HACK;
+ }
+ } else {
+ printf "%-20s missing db/usr file.\n", "warning" . ":" unless $HACK;
+ }
+ chdir("$RESDB/db/as") || die "%% error";
+ my @asn;
+ foreach(split(/\n/,`grep '^$QUERY\$' */owner | cut -d/ -f1`)) {
$out = $_;
- $out =~ s/^\.\///g;
- $out =~ m/^(.+?):(.+?)$/;
- ($title, $value) = ($1, $2);
- printf "%-20s %s\n", $title . ":", $value unless $HACK;
+ $out =~ s/\n//g;
+ printf "%-20s AS%s\n", "origin" . ":", $out if $HACK;
+ printf "%-20s AS%s\n", "origin" . ":", $out unless $HACK;
+ @asn[scalar(@asn)]=$out;
+ }
+ chdir("$RESDB/db/ip") || die "%% error";
+ my $merp;
+ foreach(split(/\n/,`grep '^$QUERY\$' */*/*/owner | cut -d/ -f1-3`)) {
+ $merp=`cat $_/cidr`;
+ chomp $merp;
+ printf "%-20s %s\n", "cidr" . ":", $merp;
+ }
+
+ foreach(split(/\n/,`grep -i -e "^$QUERY\$" "$RESDB/db/dom"/*/*/owner`)) {
+ $out = $_;
+ $out =~ s/.*\/db\/dom\/(.+?)\/(.+?)\/owner.*/\2\.\1/;
+ if ($out ne "") { #fix this comparison.
+ printf "%-20s %s\n", "domain" . ":", $out;
+ }
}
-} else {
- printf "%-20s missing db/usr file.\n", "warning" . ":" unless $HACK;
-}
-chdir("$RESDB/db/as") || die "%% error";
-foreach(split(/\n/,`grep '^$QUERY\$' */owner | cut -d/ -f1`)) {
- $out = $_;
- $out =~ s/\n//g;
- printf "%-20s AS%s\n", "origin" . ":", $out if $HACK;
- printf "%-20s AS%s\n", "origin" . ":", $out unless $HACK;
-}
-foreach(split(/\n/,`grep -i -e "^$QUERY\$" "$RESDB/db/dom"/*/*/owner`)) {
- $out = $_;
- $out =~ s/.*\/db\/dom\/(.+?)\/(.+?)\/owner.*/\2\.\1/;
- if ($out ne "") { #fix this comparison.
- printf "%-20s %s\n", "domain" . ":", $out;
+ foreach(@asn) {
+ $QUERY="AS$_"; #meh. fix to pass it instead of global.
+ ASN_lookup();
}
-}
-#printf "%-20s %s\n", "notice:","$QUERY did not claim any domains yet";
+ #printf "%-20s %s\n", "notice:","$QUERY did not claim any domains yet";