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

相关推荐
哲科软件7 小时前
跨平台开发的抉择:Flutter vs 原生安卓(Kotlin)的优劣对比与选型建议
android·flutter·kotlin
jyan_敬言13 小时前
【C++】string类(二)相关接口介绍及其使用
android·开发语言·c++·青少年编程·visual studio
程序员老刘13 小时前
Android 16开发者全解读
android·flutter·客户端
福柯柯14 小时前
Android ContentProvider的使用
android·contenprovider
不想迷路的小男孩14 小时前
Android Studio 中Palette跟Component Tree面板消失怎么恢复正常
android·ide·android studio
餐桌上的王子14 小时前
Android 构建可管理生命周期的应用(一)
android
菠萝加点糖14 小时前
Android Camera2 + OpenGL离屏渲染示例
android·opengl·camera
用户20187928316714 小时前
🌟 童话:四大Context徽章诞生记
android
yzpyzp15 小时前
Android studio在点击运行按钮时执行过程中输出的compileDebugKotlin 这个任务是由gradle执行的吗
android·gradle·android studio
aningxiaoxixi15 小时前
安卓之service
android