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

相关推荐
我命由我123454 分钟前
Android Studio 提示信息 ‘equals(““)‘ can be replaced with ‘isEmpty()‘
android·ide·android studio·安卓·android jetpack·android-studio·android runtime
Bryce李小白13 分钟前
Flutter实现Android原生相机拍照
android·数码相机·flutter
初学者-Study14 分钟前
Android基础(一) 运行HelloWorld
android·helloworld·模拟器运行
BUG创建者1 小时前
openlayer根据不同的状态显示不同的图层颜色
android·java·javascript
用户2018792831671 小时前
浅谈画框ImageView的background和src属性的差异
android
2501_915909062 小时前
iOS 加固工具实战解析,主流平台审核机制与工具应对策略
android·ios·小程序·https·uni-app·iphone·webview
马 孔 多 在下雨2 小时前
安卓服务与多线程
android
2501_915106324 小时前
iOS WebView 调试实战,第三方脚本加载失败与内容安全策略冲突问题排查指南
android·ios·小程序·https·uni-app·iphone·webview
消失的旧时光-19435 小时前
Android 键盘
android·键盘监听
Jackilina_Stone18 小时前
【faiss】用于高效相似性搜索和聚类的C++库 | 源码详解与编译安装
android·linux·c++·编译·faiss