/ 这道题有点过于简单了 /
打开题目,发现给出了php源码
I put something in F12 for you
include 'flag.php';
$flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}';
if(isset($_GET['gg'])&&isset($_GET['id'])) {
$id=$_GET['id'];
$gg=$_GET['gg'];
if (md5($id) === md5($gg) && $id !== $gg) {
echo 'You got the first step';
if(isset($_POST['passwd'])) {
$passwd=$_POST['passwd'];
if (!is_numeric($passwd))
{
if($passwd==1234567)
{
echo 'Good Job!';
highlight_file('flag.php');
die('By Retr_0');
}
else
{
echo "can you think twice??";
}
}
else{
echo 'You can not get it !';
}
}
else{
die('only one way to get the flag');
}
}
else {
echo "You are not a real hacker!";
}
}
else{
die('Please input first');
}
}Please input first
尝试直接打开flag.php,发现是空白,猜想可能是内容被过滤,使用filter伪协议转成base64编码试下:
http://ae23e8a0-f262-4fce-9b25-08692d35287b.node5.buuoj.cn:81/?file=php://filter/read=convert.base64-encode/resource=flag.php
并没有什么变化,那么先按源码中的思路来,看起来我们的目标是触发highlight_file()函数高亮显示flag.php的内容,触发该函数前,存在五层绕过,我们来逐个分析:
第一层绕过:
没什么好说的,url通过GET方式传参$gg和$id
第二层绕过:
需满足md5($id) === md5($gg) && $id !== $gg,注意到这里的判断是强相等,md5值开头为0e的一般弱相等绕过方式无法使用。这里使用数组来绕过,原理:md5函数无法处理参数是数组时的情况,会返回NULL,两个NULL自然强相等
payload:
http://ae23e8a0-f262-4fce-9b25-08692d35287b.node5.buuoj.cn:81/?id[]=1&gg[]=2
第三层绕过:
使用Hackbar以POST方式传参$passwd,没什么好说的
第四、五层绕过:
需满足!is_numeric($passwd)和$passwd==1234567,注意到后一个条件是弱相等,直接构造$passwd=1234567abc,触发highlight_file()函数得到flag,结束战斗
---[End]---
Comments | NOTHING