Bootstrap

BUU25 [MRCTF2020]Ez_bypass1

<?php
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'); } }
?>

 用数组绕过

在 PHP 中,当 URL 中出现 gg[]=1&id[]=2 这样的参数时,PHP 会将 $id 和 $gg 当作数组来处理。具体来说,$id 是一个包含元素 2 的数组,$gg 是一个包含元素 1 的数组,即 $id = [2]$gg = [1]

当将数组作为参数传递给 md5() 函数时,PHP 会尝试将数组转换为字符串。在这种情况下,PHP 会将数组转换为一个固定的字符串 "Array",因为所有的数组在转换为字符串时都会得到这个结果。

因此,md5($id) 和 md5($gg) 实际上计算的都是字符串 "Array" 的 MD5 哈希值,它们是相等的,即 md5($id) === md5($gg) 这个条件为 true

$id 和 $gg 是两个不同的数组,$id 包含元素 2$gg 包含元素 1,它们的元素不同,所以 $id !== $gg 这个条件也为 true

所以绕过

注意这里是passwd不是password,错了好几次 

 

;