#!/usr/bin/perl -w # nph-trace.cgi, output the traceroute to a host a line at at time. # jum@anubis.han.de use CGI qw(:standard); use CGI::Carp qw(fatalsToBrowser); my @spammers = ("193.251.40.5"); $SIG{"PIPE"} = 'DEFAULT'; if (grep(/^@{[quotemeta(remote_host())]}$/, @spammers)) { print header(-nph=>1); print start_html(-title=>"traceroute/tracepath", -BGCOLOR=>"white"), img({src=>'/img/hannet2.gif'}), h1("traceroute/tracepath"); print 'Not available', br; print a({href=>'/'}, 'back to the home page'); print end_html; exit 0 } if (param()) { #$arg = param('keywords'); $arg = param('addr'); print header(-nph=>1, -expires=>'+5m'); $v6 = ""; if (param('ipv6') && param('ipv6') eq 'on') { $v6 = "6"; } if (param('method') eq 'traceroute') { $cmd = 'traceroute'; } elsif (param('method') eq 'tracepath') { $cmd = 'tracepath'; } elsif (param('method') eq 'layer four trace') { $cmd = 'lft -S -E'; $v6 = ""; # does not support v6 } else { $cmd = 'traceroute'; } $cmd .= $v6; print start_html(-title=>"$cmd to $arg", -BGCOLOR=>"white"), img({src=>'/img/hannet2.gif'}), h1("$cmd to $arg"), hr; if ($arg !~ /^[0-9a-zA-Z\.:][0-9a-zA-Z\.:-]*$/) { print "Illegal chars in argument"; } else { $| = 1; print "
";
system("$cmd $arg 2>&1");
print "";
}
} else {
print header(-nph=>1, -expires=>'+5m');
print start_html(-title=>"traceroute/tracepath", -BGCOLOR=>"white"),
img({src=>'/img/hannet2.gif'}),
h1("traceroute/tracepath");
}
print hr, start_multipart_form;
print "IP Address: ", textfield(-name=>'addr', -size=>64, -maxlength=>255,
-default=>$ENV{'REMOTE_ADDR'});
print submit(-name=>'start', -value=>' Start '), "