in reply to CGI and Traceroute
Lots of good advice, but I'm surprised no one mentioned avoiding the shell entirely by using the multi-argument forms of system() or exec() to call traceroute directly.
Put together with the above advice and some sugar, you get something like ...
#!/usr/bin/perl -wT $|++; use strict; use CGI qw( header start_html end_html param p ); print header, start_html( "RavenGate TraceRoute Results" ); if ( param('trace') and param('trace') =~ /^[-.0-9a-zA-Z]+$/ ) { print p( "Hello There- I am writing this from " . "scratch so please be patient. Thanks!" ), "<pre>"; system( "/usr/sbin/traceroute", param('trace') ); print "</pre>"; print p( "Oops, there was a problem running traceroute" ) if $?; } elsif ( param('trace') ) { print p( "Oops,", param('trace'), "contains illegal characters" ); } else { print p( "Oops, you forgot to give me a host to trace to." ); }
As for that one line that "doesn't work", you need to escape the pipe (ie, $value =~ s /\|/ /g;).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Possible Security Hole (was RE: Re: CGI and Traceroute)
by merlyn (Sage) on Oct 19, 2000 at 08:11 UTC | |
by footpad (Abbot) on Oct 19, 2000 at 19:37 UTC | |
by KM (Priest) on Oct 19, 2000 at 19:55 UTC | |
by Kanji (Parson) on Oct 20, 2000 at 07:16 UTC | |
by merlyn (Sage) on Oct 20, 2000 at 10:27 UTC |