#!/usr/bin/perl -w use strict; print "Content-type: text/html\n\n"; print "\\ \\ \Dig\ II\<\/TITLE\>\ \<\/HEAD\>\ \\ \\<\/SCRIPT\>\ \Connected\:\ An\ Internet\ Encyclopedia\<\/B\>\ \\ \Dig\ II\<\/EM\>\\ \\\ \Up\:\<\/B\>\ \Connected\:\ An\ Internet\ Encyclopedia\<\/A\>\\ \Up\:\<\/B\>\ \Programmed\ Instruction\ Course\<\/A\>\\ \Up\:\<\/B\>\ \Section\ 2\ \-\ Domain\ Naming\<\/A\>\\ \<\/CENTER\>\ \Prev\:\<\/B\>\ \Dig\ I\<\/A\>\\ \Next\:\<\/B\>\ \Zones\<\/A\>\\ \\\ \Dig\ II\<\/H3\>\\ "; print "\"; print "Dig\ II"; print "\<\/TITLE\>"; print "\ \ Try\ out\ Dig\ with\ the\ Web\ form\ below\.\ Use\ some\ of\ the\ demonstration\ queries\,\ and\ then\ make\ up\ some\ of\ your\ own\.\ \ Lookup\ the\ IP\ address\ of\ your\ local\ host\.\ \ Track\ how\ this\ information\ is\ obtained\ by\ disabling\ recursion\ and\ demanding\ authoritative\ answers\ \(Dig\ options\ "; print "\"; print "\+norecurse"; print "\<\/TT\>"; print "\ and\ "; print "\"; print "\+aa"; print "\<\/TT\>"; print "\)\,\ which\ renders\ caches\ effectively\ invisible\.\ "; print "\"; print "\"; print "\ "; print "\"; print "\ Dig\,\ the\ domain\ information\ grouper\,\ is\ a\ tool\ that\ sends\ DNS\ queries\ to\ servers\ and\ prints\ the\ replies\.\ \ I\ think\ most\ network"; print "\ engineers\ find\ it\ more\ useful\ than\ "; print "\"; print "nslookup"; print "\<\/A\>"; print "\,\ which\ has\ now\ be\ depricated\ by\ "; print "\"; print "ISC"; print "\<\/A\>"; print "\,\ anyway\.\ \ "; print "\"; print "\ The\ Web\ form\ below\ uses\ a\ Perl\ script\ to\ make\ DNS\ queries\.\ It\'s\ output\ is\ similar\ to\ Dig\,\ but\ not\ identical\,\ since\ it\'s\ purely\ Perl\-based\,\ so\ that\ it\ works\ on\ Windows\ systems\ that\ don\'t\ have\ Dig\.\ If\ it\ doesn\'t\ work\,\ try\ the\ "; print "\"; print "original\ version"; print "\<\/A\>"; print "\ at\ "; print "\"; print "freesoft\.org"; print "\<\/TT\>"; print "\.\ Dig\ is\ available\ as\ part\ of"; print "\ the\ "; print "\"; print "Bind"; print "\<\/A\>"; print "\ distribution\.\ \ "; use Net::DNS; my $buffer = ""; my @pairs; my %FORM; my %Class; my %Type; my $Recursion = ""; my $AuthAnswer = ""; my @dig_cmd = (); my $pid; if (exists $ENV{'CONTENT_LENGTH'}) { # Get the input read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); # Split the name-value pairs @pairs = split(/&/, $buffer); foreach my $pair (@pairs) { my ($name, $value) = split(/=/, $pair); # Un-Webify plus signs and %-encoding $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; # Stop people from using subshells to execute commands # Not a big deal when using sendmail, but very important # when using UCB mail (aka mailx). # $value =~ s/~!/ ~!/g; # Uncomment for debugging purposes # print "Setting $name to $value

"; $FORM{$name} = $value; } } else { $FORM{'NAME'} = "www.freesoft.org"; $FORM{'CLASS'} = "IN"; $FORM{'TYPE'} = "A"; $FORM{'RECURSION'} = "on"; $FORM{'AAONLY'} = "off"; $FORM{'NAMESERVER'} = "localhost"; } $Class{'IN'} = ""; $Class{'ANY'} = ""; $Type{'A'} = ""; $Type{'ANY'} = ""; $Type{'MX'} = ""; $Type{'NS'} = ""; $Type{'SOA'} = ""; $Type{'HINFO'} = ""; $Class{$FORM{'CLASS'}}="SELECTED"; $Type{$FORM{'TYPE'}}="SELECTED"; $Recursion="CHECKED" if ("$FORM{RECURSION}" eq "on"); $AuthAnswer="CHECKED" if ("$FORM{AAONLY}" eq "on"); print "

Domain Name: Class:
Nameserver: Type:
Recursion Enabled Authoritative Answer Only

\n"; my $resolver = new Net::DNS::Resolver; $resolver->nameservers($FORM{NAMESERVER}); # if you turn in debugging, you don't have to print the response # since it prints itself $resolver->debug(1); push(@dig_cmd, "dig"); if ("$FORM{RECURSION}" ne "on") { $resolver->recurse(0); push(@dig_cmd, "+norecurse"); } if ("$FORM{AAONLY}" eq "on") { push(@dig_cmd, "+aa"); } push(@dig_cmd, "\@$FORM{NAMESERVER}", $FORM{NAME}, $FORM{TYPE}, $FORM{CLASS}); $| = 1; print "\$ @dig_cmd

\n"; print "

\n";

my $packet = $resolver->query($FORM{NAME}, $FORM{TYPE}, $FORM{CLASS});

print ";; query status: ", $resolver->errorstring, "\n";

print "
\n"; print "\ "; print "\\\ \\Next\:\<\/B\>\ \Zones\<\/A\>\<\/CENTER\>\\ \Connected\:\ An\ Internet\ Encyclopedia\<\/B\>\ \\ \Dig\ II\<\/EM\>\ \<\/BODY\>\ \<\/HTML\>\ ";