Re: [PHP4BETA] cat /etc/passwd

From: Date: Wed, 12 Apr 2000 14:19:01 +0000
Subject: Re: [PHP4BETA] cat /etc/passwd
References: 1  Groups: php.version4 
Request: Send a blank email to php-version4+get-13449@lists.php.net to get a copy of this message
Hi, Mike Robinson <mgrphp3@cgocable.net> asked : > how can I prevent > echo cat /etc/passwd; You can prevent this by having safe_mode_exec_dir empty and safe_mode set to 'On' in your php.ini : safe_mode=On safe_mode_exec_dir= Then, php refuses to system() commands that are not explicitly set in safe_mode_exec_dir, refuses to executes with backquotes, ans also checks that the files you want to fopen are owned by the same uid as the script you're executing. Example : <?php echo cat /etc/passwd; $fp=fopen('/etc/passwd',"r"); echo '$fp='.$fp; ?> Produces : Warning: Cannot execute using backquotes in safe mode in /home/httpd/html/lbb/dev/tests/catpass.php4 on line 2 Warning: SAFE MODE Restriction in effect. The script whose uid is 513 is not allowed to access /etc/passwd owned by uid 0 in /home/httpd/html/lbb/dev/tests/catpass.php4 on line 2 Warning: fopen("/etc/passwd","r") - Inappropriate ioctl for device in /home/httpd/html/lbb/dev/tests/catpass.php4 on line 2 $fp= Hope this helps, Flavien. -- Flavien LEBARBE OPEN CARE Support for Freedom mailto:flebarbe@ocare.com http://www.ocare.com Tel:+33 141430890 Fax:+33 141430891

« previous php.version4 (#13449) next »