diff --git "a/open_basedir \347\240\224\347\251\266.md" "b/open_basedir \347\240\224\347\251\266.md" index a743e54..480340c 100644 --- "a/open_basedir \347\240\224\347\251\266.md" +++ "b/open_basedir \347\240\224\347\251\266.md" @@ -1,3 +1,7 @@ + + + + Open_basedir 指令用来限制php只能访问哪些目录,所有php中相关文件读写的函数都会经过 `open_bsaedir` 的检查(但不限制system的命令执行) 设置open_basedir 的方法,在linux下,不同的目录由`:` 分割 @@ -6,6 +10,33 @@ Open_basedir 指令用来限制php只能访问哪些目录,所有php中相关 在window下不同目录由`;`分割 +###绕过方法### +1.通过命令执行函数 +``` +``` + +2.通过软连接绕过 + +``` +symlink("tmplink/../../1.txt","exploit"); +echo file_put_contents("http://127.0.0.1/exploit"); +``` + +3.通过glob伪协议 +``` + +``` + 先来纠正一个《代码审计》一书中的小错误(可能是已修复), 书中说指定的限制实际上是前缀,而不是目录名,例如,如果配置open_basedir=/www/a , 那么目录`/www/a` 和 `/www/ab` 都是可以访问的。 所以如果要将访问权限限制在指定的目录内, 请用斜线结束路径名。 @@ -20,7 +51,7 @@ var_dump(scandir('/var/www/ab')); //报错 ``` -### 一个失效的直接列举目录的方法 +### 一个失效的直接列举目录的方法(php 5.6环境可用) 在p牛的博客中介绍的一种利用DirectoryIterator + Glob 直接列举目录的方法,glob 数据流包装器从php5.3.0 起开始有效的, 用来查找匹配的文件路径。 此方法在linux列举目录无视open_basedir. @@ -327,4 +358,4 @@ PHP_FUNCTION(imagettftext) -参考: https://www.leavesongs.com/PHP/php-bypass-open-basedir-list-directory.html \ No newline at end of file +参考: https://www.leavesongs.com/PHP/php-bypass-open-basedir-list-directory.html