tags:

views:

39

answers:

1

I have access to a shared web host. The website installed there uses exec(). About 4 months ago the function was enabled, but now they have put it on the disable_functions list. They put exec, passthru and shell_exec on that list but they forgot to put system:) This makes me think that the server admin is not very aware on what he's doing. Anyway, they now say that those functions should have never be enabled and they wont re-enable them.

The installed website uses exec() to start some php scripts that would do some background work. Right now i'm looking to see if there is any other "legal" way to start those php scripts in background(i expect system() to work, but maybe they will disable it in the future also). And now my simple question: In the perdefined file structure i see a cgi-bin folder. Whats its use? From what i read on the web it is used to generate "dynamic" pages when accessed through the browser, but the server has php anyway installed, so i dont see its use.

+1  A: 

/cgi-bin/ is a directory where CGI script should be placed.
You can work around restrictions on exec in PHP by using CGI.

Create a file named somefile.sh with contents:

#!/bin/sh
printf "Content-Type: text/plain\n\n"
#your code here

This will only work if /bin/sh actually exists, and is executable (if you're not in a chroot without /bin/sh for example)

There are enough ways to get a command executed. If they disable CGI, you can continue with SSI.

Lekensteyn
I get an "Internal server error" now.I made sh.sh, changed permissions to be executable by anyone with the content `#!/bin/bashecho "dsfsdfsdf"` accesing it through http://site.com/cgi-bin/sh.sh
Quamis
I forgot that CGI scripts need to send a Content-Type header. See updated post.
Lekensteyn
thx, it works:)
Quamis