我需要允許如下:是否有可能[如何?]將shell_exec()命令列入黑名單和白名單?
shell_exec('whois ' . $domain);
,但我需要禁止一切,如:
shell_exec('ls');
shell_exec('rm -rf /');
shell_exec('sudo service nginx restart');
是有可能 「白名單」 只有一個shell_exec
命令?
我需要允許如下:是否有可能[如何?]將shell_exec()命令列入黑名單和白名單?
shell_exec('whois ' . $domain);
,但我需要禁止一切,如:
shell_exec('ls');
shell_exec('rm -rf /');
shell_exec('sudo service nginx restart');
是有可能 「白名單」 只有一個shell_exec
命令?
如果它是關於一些腳本 - 只是不通過用戶輸入shell_exec
說法,叫它當一些PARAM符合某個值
if ($_GET['cmd'] === 'whois') {
shell_exec('whois whatever');
}
如果它是關於一種託管,那麼你應該限制對數據的訪問使用OS權限。因此用戶將能夠撥打shell_exec('rm -rf /')
但沒有任何事情發生。
我猜每個用戶的限制可以在這裏工作。我會試一試。 –
也許它不是一個真正的回答你的問題,但:
您可以用PHP檢查:
if(substr($command , 0, 5) === "whois"){
shell_exec($command);
}
但我仍然不認爲它聰明地把用戶輸入了shell_exec但如果你真的想要它,我應該首先檢查everthing與PHP
它可能更適合[serverfault](http://serverfault.com/) –