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,错了好几次

相关推荐
00后程序员张4 小时前
从审核被拒到稳定过审,iOS 上架技术优化
android·ios·小程序·https·uni-app·iphone·webview
不会写DN7 小时前
PHP 中的文件读写与上传
android·开发语言·php
冬奇Lab9 小时前
Android 15音频子系统(七):音量控制系统深度解析
android·音视频开发
方白羽13 小时前
Android NFC 功能集成-读卡器模式
android·app·客户端
进击的cc13 小时前
Android Kotlin:委托属性深度解析
android·kotlin
进击的cc13 小时前
Android Kotlin:Kotlin数据类与密封类
android·kotlin
恋猫de小郭14 小时前
你的蓝牙设备可能正在泄漏你的隐私? Bluehood 如何追踪附近设备并做隐私分析
android·前端·ios
私人珍藏库14 小时前
[Android] 卫星地图 共生地球 v1.1.22
android·app·工具·软件·多功能
冰珊孤雪15 小时前
Android Studio Panda革命性升级:内存诊断、构建标准化与AI调试全解析
android·前端
_李小白15 小时前
【OSG学习笔记】Day 23: ClipNode(动态裁剪)
android·笔记·学习