Jump to content

system/exec not working in browser


olkhicha_appa

Recommended Posts

hello, If  I have following

 

In two files, and I serve foo.php then I notice

  • If I use commandline execution i.e. php foo.php then foo.txt is touched/created all right. i.e. system command is executed as expected
  • But If I use browser then I notice that the shell command in config.php is *not* executed

Any ideas as to why this might be happening?

 

----------

config.php

<?php
bar = system('touch foo.txt');
?>

 

and in foo.php

<?php
require(('config.php');
dummy = system('ls -la foo.txt');
echo "$dummy";
?>

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/45238-systemexec-not-working-in-browser/
Share on other sites

Its a linux box

 

Linux <server-name> 2.6.9-022stab078.9-enterprise #1 SMP Thu Jun 8 12:38:51 MSD 2006 i686 athlon i386 GNU/Linux

 

And no I dont see any errors.

Short of asking to hosting guys, how can I find out if executing shell commands is disabled?

check phpinfo(); to see if your in safe mode

 

Note: When safe mode is enabled, you can only execute executables within the safe_mode_exec_dir. For practical reasons it is currently not allowed to have .. components in the path to the executable.

 

 

I am sorry but I called victory too quickly.

I have a much smaller example.

The actual code is

<?php
$foo=system('touch foo.txt',$boo);
if($boo == 1)
$url ="http://";
else
$url="foo.txt";

echo '<html>',"\n\n";
echo 'The link to the generated file is <a href=', $url, '>foo.txt</a>',"\n\n";
echo '</html>',"\n\n";
?>

 

If you do above on command line the URL is fine(i.e. exit status of system() is 0) but if you use browser you will notice the exit status is 1

 

For seeing the reult http://kher.org/bug.php. Alternatively, save the code locally and execute on command line.

It also has php info.

 

 

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.