清理 PHP 中的文件路径
2022-08-30 14:30:23
我希望使我的小程序安全,以便潜在的恶意用户无法查看服务器上的敏感文件。
$path = "/home/gsmcms/public_html/central/app/webroot/{$_GET['file']}";
if(file_exists($path)) {
echo file_get_contents($path);
} else {
header('HTTP/1.1 404 Not Found');
}
在我的头顶上,我知道诸如'...的输入。/../../../../../etc/passwd'会很麻烦,但想知道我应该期待哪些其他恶意输入以及如何防止它们。