MRCTF2020 Ez_bypass

网络安全·CTF · 2023-12-10 · 685 人浏览

代码审计

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');
}

知识点:MD5函数漏洞与弱比较绕过

PHP MD5函数报错

这个一般出现形式为:

if(md5($id) === md5($gg) && $id !== $gg)
{
    echo $flag;
}

由于大部分PHP函数都不能处理数组参数,md5()函数也是其中之一,当参数为数组时,它会返回NULL,使得===成立。

payload:?gg[]=a&id[]=b

PHP 字符串弱比较绕过

低版本的PHP中弱比较的范围十分宽泛,这也就导致了这个漏洞

//PHP 5.6.40
var_dump('123abc' == 123)
//结果为:bool(true)

payload:passwd=1234567a

注意

在使用BurpSuite发送POST请求时,需要添加请求头

Content-Type: application/x-www-form-urlencoded

否则会导致POST参数无法解析。

GET FLAG

Pasted image 20231210161125.png

PHP 绕过技巧 685 Views
本站已在互联网运行了 Theme Jasmine by Kent Liao