Home Page
RABiD BUNNY FEVER
K.T.K

  • May 12, 2021, 01:46:05 PM *
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Official site launch very soon, hurrah!


Author Topic: Telnet Workaround  (Read 4043 times)

Dakusan

  • Programmer Person
  • Administrator
  • Hero Member
  • *****
  • Posts: 527
    • View Profile
    • Dakusan's Domain
Telnet Workaround
« on: September 28, 2009, 05:32:18 AM »

Original post for Telnet Workaround can be found at https://www.castledragmire.com/Posts/Telnet_Workaround.
Originally posted on: 01/18/09

I recently had to do some work on a system where I was not allowed SSH/telnet access. Trying to do work strictly across ftp can take hours, especially when you have thousands of files to transfer, so I came up with a quick solution in PHP for simple command line access.


<form method=post action="exec.php">
   <table style="height:100%;width:100%">
      <tr><td height="10%">
         <textarea name=MyAction style="height:100%;width:100%"><?=(isset($_REQUEST['MyAction']) ? $_REQUEST['MyAction'] : '')?></textarea>
      </td></tr><tr><td height="90%">
         <textarea name=Output style="height:100%;width:100%"><?
if(isset($_REQUEST['MyAction']))
{
   $MyAction=preg_split("/\\r?\\n/", $_REQUEST['MyAction']);
   foreach($MyAction as $Action)
   {
      exec($Action, $MyOutput);
      print htmlentities(implode("\n", $MyOutput), ENT_QUOTES, 'ISO8859-1')."\n-----------------------\n";
   }
}
         ?></textarea>
      </td></tr><tr><td height=1>
         <input type=submit>
      </td></tr>
   </table>
</form>

This code allows you to enter commands on separate lines in the top box, and after the form is submitted, the output of each command is entered into the bottom box separated by dashed lines.

Note that  between each command the environment is reset, so commands like "cd" which change the current directory are not useable :-(. You must also change the line 'action="exec.php"' to reflect the name you give the file.


A more suitable solution would be possible through AJAX and a program that redirected console output from a persistent session, but this was just meant as quick fix :-).

Logged