【发布时间】:2010-04-12 19:03:43
【问题描述】:
假设我们有一个简单的 php 脚本,它应该从 $_GET 数组中获取 ssh_host、ssh_username、ssh_port,并尝试使用此参数连接到 SSH。
$port = escapeshellcmd($_GET['ssh_port']);
$host = escapeshellcmd($_GET['ssh_host']);
$username = escapeshellcmd($_GET['ssh_username']);
$answer = shell_exec("ssh -p " . $port . " " . $user . "@" . $host);
escapeshellcmd() 够用还是我需要一些更棘手的东西?
或者我应该在这个例子中使用escapeshellarg()?
谢谢。
【问题讨论】: