web-console icon indicating copy to clipboard operation
web-console copied to clipboard

block specific commands.

Open MadTomT opened this issue 9 years ago • 1 comments

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

MadTomT avatar Dec 15 '16 13:12 MadTomT

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";

nhalstead avatar Apr 27 '17 02:04 nhalstead