Lists files in current working directory. If the command is detected on the servers system, the command is executed on the server, to support arguments. The command is escaped by PHP’s escapeshellcmd to prevent other actions. If you want to execute commands on the shell, use the Sys plugin.
Command line interface
Syntax
- $ ls [args]
Arguments
- args – (mixed, optional) Only supported if ls is detected on the servers system.
Example

ls.php
- <?
- require("../plugin.php");
- if (is_ajax()) {
- if ($_POST["action"] == 'ls') {
- // try "secure" ls access on system
- if (@shell_exec("ls --help 2>&1")) die(shell_exec(escapeshellcmd($_POST['cmd'])." 2>&1"));
- // try exec (cannot redirect error stream in safe_mode)
- unset($out);
- exec("ls --help", $out);
- if ($out) {
- unset($out);
- exec(escapeshellcmd($_POST['cmd']), $out);
- die(implode("\n", $out)."\n");
- }
- // just print all files
- $files = glob("*");
- if ($files) echo implode("\n", $files);
- exit;
- }
- exit;
- }
- ?>
- /**
- * List directory
- **/
- TinyShell.plugins.ls = new Class({
- description: "List files",
- run : function(terminal, args, line) {
- this.t = terminal;
- terminal.ajax_request(this.print, "<?php echo $_AJAX_URL?>", "action=ls&cmd="+encodeURIComponent(line));
- },
- print : function(response) {
- this.t.print(response);
- this.t.resume();
- }
- });