这是我的代码
$file = $_GET['file'];
include "$file.html";
Run Code Online (Sandbox Code Playgroud)
当我传递这样的 URL: 时
test.php?file=sample.php%00,由于空字节注入,应该包含文件 sample.php。但相反,我收到了一个错误:
Failed opening 'sample.php' for inclusion.
我检查了文件路径并尝试给它提供绝对路径。
我在 Windows 上使用 PHP 5.3.8 版。我在这里缺少什么?谢谢
我知道不应该使用寄存器全局变量而不能理解为什么?
例如:这是我经常发现的代码,用于演示在example.com?authorized=1向脚本传递类似内容时使用寄存器全局变量的安全风险:
if (authenticated_user())
{
$authorized = true;
}
if ($authorized)
{
include '/highly/sensitive/data.php';
}
Run Code Online (Sandbox Code Playgroud)
我的问题是,如果用户必须传入authorized=1url,他应该知道我在我的脚本中使用的变量名,对吧?怎么可能?
同样不是一个函数parse_str(),其行为有点类似于注册全局变量的安全风险吗?
php ×2