Trying to set up a script to send commands to a remote client on a Win32 system. Here is the code:
$command = $_POST['command'];
$host = $_POST['host'];
$port = $_POST['port'];
$fp = @fsockopen($host, $port, $e, $s, 15);
if (!$fp) {
echo 'Error! Here\'s your problem: ' . $e . ': ' . $s;
}else{
$fw = fwrite($fp, $command);
if (!$fw){
echo 'Failed sending command.';
fclose($fp);
}else{
fclose($fp);
echo 'Successfully sent: ' . $command;
}
}
My buddy is working on the remote client, and he says that this script is sending ''
However, my script is echoing Successfully sent: test
Am I doing something wrong, or is it a problem on his end?
(Not a solution …yet)
What does
print?
update: Does it work when you test it against this dummy server script (via php-cli)?
First try it on the same machine ($_POST[‘host’]===’localhost’) then on the remote machine (if there is such a thing).