1.warmup
打开靶机后页面显示为一张图片看源码,注释里有一个文件
访问文件后得到一串代码
<?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\" />";
}
?>
作为一个初学者不是很理解,就问ai也没有看懂,知道我看到一位大佬的文章,就是初学者的福音
文章链接Buuctf-Web-[HCTF 2018]Warm Up 题解&代码审计_buuctf [hctf 2018]warmup-优快云博客,写的巨好,总的来说checkfile会检查三次,两次参数处理,不能直接通过文件路径访问到文件,需要传参,?file=source.php?ffffllllaaaagggg,代码会截取第一个问号前的内容检查是否在白名单中,后面加入ffffllllaaaagggg就可以绕过白名单检查,但是还没完因为查不到,ffffllllaaaagggg不在html目录下,查找相关内容得知,Web应用程序的文件系统中,目录的顺序通常指的是目录的层级结构和它们之间的组织关系从根目录开始向下展开:根目录 这是服务器上Web应用程序的顶级目录。www:通常作为Web服务器的文档根目录,存放可以直接通过Web浏览器访问的静态资源,如HTML、CSS、JavaScript文件和图片var:存放应用程序运行时产生的数据,如日志文件、会话文件、临时文件和数据库文件src 或 application:存放应用程序的源代码,包括后端逻辑、脚本和配置文件。
用?file=source.php?../../../../../ffffllllaaaagggg就可以获得、
2.include
启动靶机后点击tips后
毫无头绪有题目include可能是文件包含,用php伪协议?file=php://filter/read=convert.base64-encode/resource=flag.php,?file=php://filter/read=convert.base64-encode/resource=文件名,通常用与php文件包含漏洞,可以指定资源内容进行base64编码
解码即可得到flag flag{136d3d89-bb8f-43d0-abe0-3db91e1982de}