题目运用的知识点
- md5()的绕过
- 弱比较
内容
右键查看内容
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
解题
代码审计题
可以看到题目需要我们传两个GET参数和一个POST参数
需要绕过两处:
(md5($id) === md5($gg) && $id !== $gg)=true
(!is_numeric($passwd) && $passwd==1234567)=true
第一处是一个MD5的绕过,我们构造PL/?id[]=1&gg[]=2
第二处有个is_numeric()函数,我们利用弱比较绕过,拿到FLAG
passwd=1234567a
关于MD5函数绕过思路
1.传md5值是0e开头的字符串,比如
QNKCDZO(0e830400451993494058024219903391) 和
s878926199a(0e545993274517709034328855841020)
因为php在利用”!=”或”==”来对哈希值进行比较,它把每一个以”0E”开头的哈希值都解释为0
2.传递数组 因为向md5函数传递数组会返回NULL
关于is_numeric()
is_numeric() 函数用于检测变量是否为数字或数字字符串。PHP 版本要求:PHP 4, PHP 5, PHP 7
语法
bool is_numeric ( mixed $var )
参数说明:
$var:要检测的变量。
返回值
如果指定的变量是数字和数字字符串则返回 TRUE,否则返回 FALSE,注意浮点型返回空值,即 FALSE。