Buuctf [MRCTF2020]Ez_bypass 1 WP解析

题目来源:MRCTF2020
题目名称:Ez_bypass 1

打开网页

查看源代码

I put something in F12 for you
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

此php文件分为两次第一次的强类型的比较,传参方式为GET,判断参数gg和id的md5值是否相同,因为是一个==所以属于是一个md5的弱比较可以将参数设置成为数组进行绕过部分字符串md5加密之后为0exxxx的格式,相当于0的xxxx次方,所以无论xxxx是什么,函数判断时都会认为相等

例如

a=QNKCDZO,加密后为0e830400451993494058024219903391

b=240610708,加密后为0e462097431906509019562988736854

所以既满足了a!=b,也满足了md5($a) == md5($b)

并且:md5函数不能处理数组,处理数组会报错,就会返回null,然后经过md5就相等了,传入的参数不同,gg和id的值就不同

payload:

/?gg[]=QNKCDZO1&id[]=240610708

有了回显,是一个warning的报错说明我们的GET的md5弱比较执行成功,接着审计剩下的代码

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

思路:

        is_numeric()函数,它的作用就是判断参数是否为数字或者是字符串数字,如果不是则返回false,这里!is_numeric所以这是不是数字或者不是字符串数字就返回true,并且这里是弱类型比较还需要等于1234567,php的弱类型比较1234567a==1234567返回的true,我们只需要使用post传参就可以了

Burpsuite传参:

  1. 请求方式修改为POST
  2. 消息头中加上Content-Type:application/x-www-form-urlencoded
  3. 在消息主体中加上需要上传的POST数据
  4. 在Reoeater模块右键点击change body encoding

payload:

        passwd=1234567a

修改后直接发送包获得flag

 

 

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值