web-console
web-console copied to clipboard
block specific commands.
Hi.
is it possible to build up a list of commands that the user can't run ? eg vi, tail etc and show 'unsupported command' on screen ?
Thanks
You might be able to with a preg_match() and an Array of Commands to block. With that you could do something like this:
<?php
$blocked_commands[] = "vi";
$blocked_commands[] = "nano";
function allowedCommandCall($commandIn){
global $blocked_commands;
foreach($blocked_commands as $key => $command){
if(preg_match("/(^|.)".$command."(.|$)/i", $commandIn, $matches) == TRUE){ return FALSE; }
}
return TRUE;
}
// Just a Test of it.
echo allowedCommandCall("sudo nano /var/www/index.html")?"Allowed":"Blocked";