#!/usr/bin/perl -w # Copyright (C) 2003 Paul T. Jobson # pjobson@visual-e.net # aim: vbrtrmn # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # The GNU General Public License is available here: # http://www.gnu.org/copyleft/gpl.html#SEC3 ################################################################## # digger.cgi # Program for doing recursive dig requests, used to find DNS # propagation issues. $| = 1; use strict; use CGI qw(:all); use CGI::Carp('fatalsToBrowser'); my ($digdata,@NSlist,$nextlevel,$hostin,$gtld); my $pass = param('password'); my $host = param('host'); push(@NSlist,param('gtld')); my $sent = "false"; &doHTMLStart; &checkforErrors; &startDigLoop; &doHTMLEnd; sub startDigLoop { print "
Attempting to Query $host at every Name Server in the returned Zone Files.\nThis may take a minute or so.

"; for (@NSlist) { $gtld = $_; &doTheDig; } } sub doTheDig { $digdata = `dig \@$gtld $host any`; &outputData; &extractNS; } sub checkforErrors { if ($pass eq "") { &doHTMLEnd; exit; } elsif ($pass ne "password") { &invalidPasswordExit; } elsif ($host eq "") { print "

Missing Host

"; exit; } elsif ($host =~ m/[\|&\+=\@%]/gi) { print "

Invalid Host

"; exit; } elsif ($#NSlist < 0) { print "

No gTLD Servers Selected

"; exit; } foreach (@NSlist) { if ($_ =~ m/[\|&\+=\@%]/gi) { print "

Invalid gTLD Server

"; exit; } } } sub outputData { my $header = "

# dig \@$gtld $host any

\n"; if ($digdata =~ /(status: QUERY REFUSED)/) { print "$header $1
"; } elsif ($digdata =~ /(status: SERVER FAILED)/) { print "$header $1
"; } elsif ($digdata =~ /(status: CONNECTION REFUSED)/) { print "$header $1
"; } elsif ($digdata =~ /(status: TIMED OUT)/) { print "$header $1
"; } elsif ($digdata =~ /(status: NXDOMAIN)/) { print "$header $1
"; } elsif ($digdata =~ /(status: REFUSED)/) { print "$header $1
"; } elsif ($digdata =~ /(status: SERVFAIL)/) { print "$header $1
"; } elsif ($digdata =~ /status: NOERROR/) { print "$header"; $digdata =~ s/$host/$host<\/font>/g; print $digdata; print "
"; } else { print "$header unknown error code, probably invalid name server or server time-out; try resubmitting query.
"; } } sub extractNS { my @templist = $digdata =~ m/(NS\s+.+\.\n)/g; @templist = map { s/NS\s+(.+)\.\n/$1/; $_; } @templist; # clean the array for (@templist) { my $ns = lc($_); unless("@NSlist" =~ /$ns/) { push(@NSlist, $ns); } } } sub invalidPasswordExit { print "

Invalid Password

"; exit; } sub doHTMLStart { print header(); print < über dig tool
HTMLSTART print ''; print < HTMLSTART print ''; print <
Password
Host to Dig
Starting Server
 

HTMLSTART
}

sub doHTMLEnd {
        print <
        
        
HTMLEND
}