BUU25 [MRCTF2020]Ez_bypass1

php 复制代码
<?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,错了好几次

相关推荐
砖厂小工4 小时前
用 GLM + OpenClaw 打造你的 AI PR Review Agent — 让龙虾帮你审代码
android·github
张拭心5 小时前
春节后,有些公司明确要求 AI 经验了
android·前端·人工智能
张拭心5 小时前
Android 17 来了!新特性介绍与适配建议
android·前端
Kapaseker7 小时前
Compose 进阶—巧用 GraphicsLayer
android·kotlin
黄林晴8 小时前
Android17 为什么重写 MessageQueue
android
阿巴斯甜1 天前
Android 报错:Zip file '/Users/lyy/develop/repoAndroidLapp/l-app-android-ble/app/bu
android
Kapaseker1 天前
实战 Compose 中的 IntrinsicSize
android·kotlin
xq95271 天前
Andorid Google 登录接入文档
android
黄林晴1 天前
告别 Modifier 地狱,Compose 样式系统要变天了
android·android jetpack
冬奇Lab2 天前
Android触摸事件分发、手势识别与输入优化实战
android·源码阅读