考点:代码审计、弱类型比较
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');
}
代码审计
条件1:md5($id) === md5($gg) && $id !== $gg
“!==“”表示同类型下才能比较,说明左右两边的类型不同,且值不同,
md5下相同{md5(数组)=0},令id及gg为数组,及通过get传参,id[]=1&gg[]=2
条件2:passwd的值不为数字,且弱类型比较下值为1234567
弱类型会将字符串转化为数字
//当一个字符串欸当作一个数值来取值,其结果和类型如下:如果该字符串没有包 含'.','e','E'并 且其数值值在整形的范围之内 ;该字符串被当作int来取值,其他所有情况下都被作为float 来 取值,该字符串的开始部分决定了它的值,如果该字符串以合法的数值开始,则使用该数 值,否则其值为0。
故令passwd=1234567a
传参后得:flag