【学习笔记 44】 buu [MRCTF2020]Ez_bypass

0x00 知识点

  1. 绕过md5()函数
  2. 绕过is_numeric()函数
  3. 代码审计

0x01 知识点详解

  1. md5()函数怎么绕过?
    答:本题是将两参数传成数组,由于md5()函数无法操作数组,也就判断都为null,像个参数的md5值也就相同了。
  2. is_numeric()函数怎么绕过?
    答:is_numeric() 函数用于检测变量是否为数字或数字字符串。本题由于在这个函数之后还有一个弱类型比较,所以要用1234567a绕。1234567a是字符串,但是弱类型比较的时候,1在前,php会将其整体转成数字,就可以通过比较了。

解体思路

  1. 在这里插入图片描述
    打开是一串很乱的代码,查看源码后看到排序好的伪代码。
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');
}
}Please input first

整个代码中get传了两个参数,需要绕过md5()函数
post传了一个参数,需要绕过一个is_numeric()函数
所以就可以构造最后的payload

get:?id[]=1&gg[]=2
post:passwd=1234567a

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43553654/article/details/107757538