sure, i can give you an example. but the best examples are in perlsec. you're running AS ROOT, and not checking your variables for taintedness. if i can get you to your web page, i can do VERY EVIL THINGS to your system. of course, i'd never do that ;-)

use -T as well as strict and warnings. don't use the PATH environment, unless you've cleaned it. when you execute a system call, use the full path to the executable, and pass an array, so the shell is bypassed. these and many other good practices can be learned by reading the perlsec documentation. i highly recommend reading Ovid's "Web Programming Using Perl" Course as well. it's helped me tremendously.

here's some code...

#!/usr/bin/perl -wT use strict; use CGI; # clean your environment BEGIN { $ENV{PATH} = '/usr/bin:/usr/local/bin'; } my $useradd = '/full/path/to/useradd'; my( $site_count, $username ); # and so on... # get input, which will be tainted... # my $username = $CGI->param('username'); # untaint input # for instance, username is 1 to 12 word characters if( $username =~ /^(\w{1,12})$/ ) { $username = $1 } # and so on... # now call system, with list of arguments to bypass shell system( $useradd, qq|-c "fullname"|, qq|-d /home/sites/site$site_count/users/$username|, qq|-g site$site_count|, qq|and so on...|, ) and error( "oh, i didn't expect that! $!" );

~Particle *accelerates*


In reply to Re^3: Using doublequotes in a system call by particle
in thread Using doublequotes in a system call by rguyer

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.