#!/usr/bin/perl # Nettool CGI # By: David A. Flanigan # No Warrnety provided or implied, use at your own risk. # Free for any use. Please send improvements back to dave@flanigan.net # E-mail dave@flanigan.net with questions on modifying this script. # http://www.flanigan.net/scripts # #Load Libs use CGI qw(:param); #init varables my $cdate = `/bin/date`; chomp $cdate; # get url params my $tool = param('tool'); my $dest = param('dest'); #Watch for baddies trying to pass params to the tools $dest =~ tr/ //d; if ($dest =~ /^\-/) { print "Content-Type: text/html\n\n"; print "Attetmp to pass params to network tools detected and logged\n"; exit; } #Set executables by tool if ($tool eq "ping") { $exe = "/bin/ping -c 5"; } elsif ($tool eq "trace") { $exe = "/bin/traceroute"; } elsif ($tool eq "whois") { $exe = "/usr/bin/whois"; } elsif ($tool eq "lookup") { $exe = "/usr/bin/host"; } #Or we don't know this tool else { print "Content-Type: text/html\n\n"; print "Unknwown tool\n"; print "\\"; print "Tool = $tool, $Destination = $dest\n"; exit; } # Do it print "Content-Type: text/html\n\n"; print "Tool = $tool \t Target = $dest\n"; print "\\n"; system ("$exe $dest"); print "\<\/PRE\>\n"; print "Task Completed on $cdate"; print "\\"; print "Click \here\<\/a\> to return to our Network Tools"; exit(0);