Changeset 2767

Show
Ignore:
Timestamp:
10/18/06 21:10:22 (7 years ago)
Author:
qldrob
Message:

Fix nasty shell-escape bug that allowed full access to the shell. Sigh.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/branches/2.2/asterisk-cli/page.cli.php

    r1350 r2767  
    6666  putenv("PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"); 
    6767  putenv("SCRIPT_FILENAME=" . strtok(stripslashes($txtCommand), " "));  /* PHP scripts */ 
    68   $ph = popen(stripslashes("asterisk -rx \"$txtCommand\""), "r" ); 
     68  $badchars = array("'", "`", "\\", ";", "\""); // Strip off any nasty chars. 
     69  $fixedcmd = str_replace($badchars, "", $txtCommand); 
     70  $ph = popen(stripslashes("asterisk -rx \"$fixedcmd\""), "r" ); 
    6971  while ($line = fgets($ph)) 
    7072    echo htmlspecialchars($line);