0x01 [HCTF 2018] WarmUp [PHP][代码审计]
简单题。打开网页后一张滑稽,按F12寻找信息,发现代码注释里有一行
“`“`,在url后加上/source.php刷线页面,得到一段PHP代码。
<?php
highlight_file(__FILE__);
class emmm
{
public static function checkFile(&$page)
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
if (! isset($page) || !is_string($page)) {
echo "you can't see it";
return false;
}
if (in_array($page, $whitelist)) {
return true;
}
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
$_page = urldecode($page);
$_page = mb_substr(
$_page,
0,
mb_strpos($_page . '?', '?')
);
if (in_array($_page, $whitelist)) {
return true;
}
echo "you can't see it";
return false;
}
}
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
看这个判断语句
if (! empty($_REQUEST['file'])
&& is_string($_REQUEST['file'])
&& emmm::checkFile($_REQUEST['file'])
)
说明是在请求中包含有文件,以及文件是一个string,这两个都好说,看第三个是进入checkFile函数。
看代码逻辑的话,有三种情况会返回true
继续阅读“BUUOJ Web #1 [HCTF 2018]WarmUp [强网杯 2019] 随便注 [SUCTF 2019]EasySQL [RoarCTF 2019]Easy Calc”