题目来源: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传参:
- 请求方式修改为POST
- 消息头中加上Content-Type:application/x-www-form-urlencoded
- 在消息主体中加上需要上传的POST数据
- 在Reoeater模块右键点击change body encoding
payload:
passwd=1234567a
修改后直接发送包获得flag