复制代码 代码如下:
<?php
$file = $_GET['file']; // "../../etc/passwd/0"
if (file_exists('/home/wwwrun/'.$file.'.php')) {
// file_exists will return true as the file /home/wwwrun/../../etc/passwd exists
include '/home/wwwrun/'.$file.'.php';
// the file /etc/passwd will be included
}
?>
复制代码 代码如下:
<?php
$file = $_GET['file'];
// 对字符串进行白名单检查
switch ($file) {
case 'main':
case 'foo':
case 'bar':
include '/home/wwwrun/include/'.$file.'.php';
break;
default:
include '/home/wwwrun/include/main.php';
}
?>
新闻热点
疑难解答