题目:
<?php
error_reporting(0);
require __DIR__.'/lib.php';
if(isset($_GET['time'])){
if(!is_numeric($_GET['time'])){
echo 'The time must be number.';
}else if($_GET['time'] < 60 * 60 * 24 * 30 * 2){
echo 'This time is too short.';
}else if($_GET['time'] > 60 * 60 * 24 * 30 * 3){
echo 'This time is too long.';
}else{
sleep((int)$_GET['time']);
echo $flag;
}
echo '<hr>';
}
highlight_file(__FILE__);
答案:
解析:
php中当字符串与整型做比较时会把字符串转为整型0x4f1a00会作为16进制整形符合第一个和第二个if绕过,第三个if犯了一个错误就是用int把参数转为整型,这样会使字符串为0(请参考字符串转整形规则,在php官方文档可以看到,比如 (int)'123a',转为整型为123,a123转为整型为0)所以我们会直接的到flag。