打开是个滑稽笑脸
查看源代码发现了这个提示
打开,又是一道代码审计题
看到这句话
该源代码界面为source.php,尝试打开hint.php
看来还是得乖乖审计
(参考博客:BUUCTF-warmup - zesiar0 - 博客园
<?php
highlight_file(__FILE__); //打印代码
class emmm //定义emmm
{
public static function checkFile(&$page) //将传入的参数赋给$page
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
//声明$whitelist(白名单)数组
if (! isset($page) || !is_string($page)) { //第一个if:若$page变量不存在或非字符串
echo "you can't see it"; //打印"you can't see it"
return false; //若不是字符串返回false
}
if (in_array($page, $whitelist)) { 第二个if:$page是否存在于$whitelist数组中,存在则返回true
return true;
}
$_page = mb_substr( //该代码表示截取$page中'?'前部分,若无则截取整个$page
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) { //第二个if:$page是否存在于$whitelist数组中,存在则返回true
return true;
}
$_page = urldecode($page); //url解码$page
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?') //(有疑问) 查找字符串'?'在字符串_page . '?'中的 位置
);
if (in_array($_page, $whitelist)) { //第三个if:判断截取后的$page是否存在于$whitelist数组中,截取$page中'?'前部分,存在则返回true
return true;
}
echo "you can't see it";
return false;
}
}
//第四个if:判断url解码并截取后的$page是否存在于$whitelist中,存在则返回true
若以上四个if语句均未返回值,则返回false
if (! empty($_REQUEST['file']) //$_REQUEST['file']值非空
&& is_string($_REQUEST['file']) //$_REQUEST['file']值为字符串
&& emmm::checkFile($_REQUEST['file']) //能够通过checkFile函数校验
) {
include $_REQUEST['file']; //包含$_REQUEST['file']文件
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
查找字符串a在字符串string中首次出现的位置
mb_strpos($string,&a)
如:mb_strpos($_page . '?', '?')
在字符串string中截取以start开始,以end结尾的子串
当传入的file变量的值需要满足:非空,字符串,能通过checkfile函数校验
mb_substr($string,$start,$end)
如:mb_substr( //该代码表示截取$page中'?'前部分,若无则截取整个$page
$page,
0,
mb_strpos($page . '?', '?')
)
如何构造payload????
这里我就不懂了,这是截取自其他人的wp
这个十分不理解