Sys

Executes commands directory on the servers shell. If shell access is denied, the application tries to execute the command as an external program. Commands that requires user input are not supported. You will have to create your own TinyShell plugin, if such does not already exist. This command is the only command, together with Login that may be called by the TinyShell core; if this plugin is installed, TinyShell sends commands to sys, if a command was not found as a native TinyShell plugin. When shell access is enabled, standard error stream is automatically piped to standard output stream.

Command line interface

Syntax

  1. $ sys cmd

Arguments

  • cmd – (text) The command you wish to execute on the server. Commands should not be quoted or anything, just type the complete command after the sys keyword.

Example

sys.php

  1. <?
  2. require("../plugin.php");
  3. if (is_ajax()) {
  4. if ($_POST["action"] == 'system') {
  5. unset($out);
  6. if( !ini_get('safe_mode') ) $out = @shell_exec($_POST['cmd']." 2>&1");
  7. else {
  8. // unfortunately error stream cannot be redirected in safe_mode
  9. // since this will be escaped by escapeshellcmd
  10. echo "sys: PHP safe_mode_exec_dir is: ".ini_get('safe_mode_exec_dir')."\n";
  11. exec($_POST['cmd'], $out);
  12. $out = $out ? implode("\n", $out)."\n" : "";
  13. }
  14. echo $out;
  15. }
  16. exit;
  17. }
  18. ?>
  19. /**
  20. * Run command on system
  21. **/
  22. TinyShell.plugins.sys = new Class({
  23. description: "Run commands on the server",
  24. run : function(terminal, args, line) {
  25. this.t = terminal;
  26. if (line.length > 4) terminal.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=system&cmd="+encodeURIComponent(line.substring(4)));
  27. else this.t.print("sys: usage: sys command").resume();
  28. },
  29. print : function(response) {
  30. this.t.print(response);
  31. this.t.resume();
  32. }
  33. });

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>