Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In order to connect to a shell using a web interface, you need a full apache server with php, like lamp/wamp</p> <p>Steps:</p> <ul> <li>Create a web interface to send to server commands an see the result. An ajax UI may be useful for that. I will supose that you know html/php/javascript and that is not a problem for you to implement that.</li> <li>The "exec" php function to call commands: <a href="http://php.net/manual/es/function.exec.php" rel="nofollow">http://php.net/manual/es/function.exec.php</a></li> </ul> <p>Example: </p> <pre><code>&lt;?php // Test the user!! you don't want that any one may use the command line of your server. ... // Get the command to execute $command=''; if (isset($_POST['command'])) { $command = $_POST['command']; } // Execute your command if ($command!='') echo exec($command); ?&gt; </code></pre> <p>You should take in consideration that errors are sent to stderr, so if you want to see errors, it's necesary to redirect: echo exec($command . ' 2>&amp;1');</p> <p>Security considerations:</p> <ul> <li>Use SSL for all communications</li> <li>be very careful to don't allow every one to access your shell, even with strange code or web modifications.</li> <li>Test that the $command is allowed, do not just execute whatever.</li> <li>Be very careful with commands that allow to upload files, like "wget".</li> </ul> <p>Other considerations: This script just allow to execute simple commands, but does not allow a full bi-directional communication with a complex software, for example you cannot run a game server as this. If this is your intention, on linux there is a application "screen" that allow to re-connect to a shell. </p> <pre><code>//Define a screen name, may be whatever, but must be unique $myScreenName='MyWebApp'; // To launch the app: echo exec('screen -S ' . $myScreenName . ' -d -m ' . $command . ' 2&gt;&amp;1 1&gt;log.log'); // To re-connect to the shell in order to send new content: echo exec('screen -S ' . $myScreenName . " -X -p0 stuff $'" . $command . "\n'"); // to test if the screen is active: function testIfActive($myScreenName) { exec('screen -ls', $screenLS); screenLs = implode('', $screenLS); return (stripos($screenLs, $myScreenName)!==false); } // to read the output, just read the log.log file. </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload