[MRCTF2020]Ez_bypass
打开题目
I put something in F12 for you include 'flag.php';
<?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
进行代码审计
-
从
if (md5($id) === md5($gg) && $id !== $gg)
可以看出这里考的是md5强碰撞md5()无法处理数组,所以如果传入的两个参数都是数组,那么md5()函数返回的都是false,false===false成立
?gg[]=1&id[]=2
-
在之后
!is_numeric($passwd)
和$passwd == 1234567
这两个判断条件中可以看出这里是php弱类型比较php在比较不同类型的数据时,会首先将两边的数据转化为同一类型,字符型数据与数字型数据进行比较,字符型数据会转化为数据型数据。
比如1234567a会转化为1234567再进行比较,同时也绕过了is_numeric()函数
-
回显得到flag