BUUCTF [MRCTF2020]Ez_bypass
记录一次BUUCTF做题过程
首先打开题目
将其还原,大概是这样
I put something in F12 for you
<?php
include 'flag.php';
$flag='MRCTF{xxxxxxxxxxxxxxxxxxxxxxxxx}';
if(isset($_GET['gg'])&&isset($_GET['id'])) { // 传入两个GET,gg和id
$id=$_GET['id'];
$gg=$_GET['gg'];
if (md5($id) === md5($gg) && $id !== $gg) { // 经过md5后两个值,全等,且传入的值不相同
echo 'You got the first step';
if(isset($_POST['passwd'])) { // 传入POST,passwd
$passwd=$_POST['passwd'];
if (!is_numeric($passwd)) { // passwd不能为数字
if($passwd==1234567) { // 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
分析
- 我们需要传入两个GET值和一个POST值
- 两个GET值不相同,但经过md5函数后相同
- POST值不能为数字,但要和1234567对等
- 很明显,这题考的是MD5函数漏洞和PHP弱类型比较
- 因为md5()无法处理数组,当你传入数组的时候,md5()会返回false,当两个md5()都返回false时,false=false,则条件成立。
- PHP弱类型比较,当字符串和数字比较时会被强转,比较时忽略后面的字符串。比如判断1234567c == 123456时,PHP会比较前面的数字部分1234567 == 1234567,解决方法是全等 ===
实操