1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<?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 ); $password = unserialize($password ); echo $password ; } } else { highlight_file(__FILE__ ); } ?>
https://www.freebuf.com/column/151447.html
file://
— 访问本地文件系统
http://
— 访问 HTTP(s) 网址
ftp://
— 访问 FTP(s) URLs
php://
— 访问各个输入/输出流(I/O streams)
zlib://
— 压缩流
data://
— 数据(RFC 2397)
glob://
— 查找匹配的文件路径模式
phar://
— PHP 归档
ssh2://
— Secure Shell 2
rar://
— RAR
ogg://
— 音频流
expect://
— 处理交互式的流
**data://**中相关内容:
1 2 3 4 5 6 7 8 9 10
* data:,文本数据 * data:text/plain,文本数据 * data:text/html,HTML代码 * data:text/css;base64,css代码 * data:text/javascript;base64,javascript代码 * data:image/x-icon;base64,base64编码的icon图片数据 * data:image/gif;base64,base64编码的gif图片数据 * data:image/png;base64,base64编码的png图片数据 * data:image/jpeg;base64,base64编码的jpeg图片数据
更为详细的了解可参考:
https://www.cnblogs.com/fsjohnhuang/p/3903688.html
**php://**中的相关内容:
1 2 3 4 5 6
*php://filter:用于读取源代码并进行base64编码输出(一般可读取藏在源代码中的flag) eg:php://filter/read=convert.base64-encode/resource=useless.php *php://input:可以访问请求的原始数据的只读流, 将post请求中的数据作为PHP代码执行。 eg:就如本体中在对text赋值是可写成text=php://input,然后再用post把welcome to the zjctf一起传过去,同样可以绕过file_get_contents()函数
更为详细的了解可参考:
https://crayon-xin.github.io/2018/04/15/php%E4%BC%AA%E5%8D%8F%E8%AE%AE-php/