Skip to content

Commit 323e3e1

Browse files
committed
update
1 parent fdb8059 commit 323e3e1

File tree

9 files changed

+183
-1
lines changed

9 files changed

+183
-1
lines changed

web-nginx-php55/Dockerfile

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
FROM php:5.5-fpm-alpine
2+
3+
# 制作者信息
4+
LABEL auther_template="CTF-Archives"
5+
6+
# 安装必要的软件包
7+
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories &&\
8+
apk add --update --no-cache nginx bash
9+
10+
# 拷贝容器入口点脚本
11+
COPY ./service/docker-entrypoint.sh /docker-entrypoint.sh
12+
RUN chmod +x /docker-entrypoint.sh
13+
14+
# 复制nginx配置文件
15+
COPY ./config/nginx.conf /etc/nginx/nginx.conf
16+
17+
# 复制web项目源码
18+
COPY src /var/www/html
19+
20+
# 重新设置源码路径的用户所有权
21+
RUN chown -R www-data:www-data /var/www/html
22+
23+
# 设置shell的工作目录
24+
WORKDIR /var/www/html
25+
26+
EXPOSE 80
27+
28+
# 设置nginx日志保存目录
29+
VOLUME ["/var/log/nginx"]
30+
31+
# 设置容器入口点
32+
ENTRYPOINT [ "/docker-entrypoint.sh" ]

web-nginx-php55/README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# web-nginx-php55
2+
3+
部分容器逻辑参考自:[CTFTraining / base_image_nginx_php_73](https://github.com/CTFTraining/base_image_nginx_php_73),在此感谢 [陌竹 - mozhu1024](https://github.com/mozhu1024) 师傅做出的贡献
4+
5+
## 环境说明
6+
7+
提供 `Nginx` +`PHP 5.5.38` 的基础环境,默认暴露端口位于 80
8+
9+
> 请注意 !!!
10+
>
11+
> 需要注意的是,模板默认会将 flag 保存在 /flag 文件中,如果 PHP 项目中需要直接从环境变量中读取 flag 数据,请在./service/docker-entrypoint.sh 中修改相关操作语句
12+
13+
## 如何使用
14+
15+
直接将 PHP 项目放入 `./src` 目录即可
16+
17+
源码放置进 `./src` 目录之后,执行
18+
19+
```shell
20+
docker build .
21+
```
22+
23+
即可开始编译镜像
24+
25+
也可以在安放好相关项目文件之后,直接使用 `./docker/docker-compose.yml` 内的 `docker-compose` 文件实现一键启动测试容器
26+
27+
```shell
28+
cd ./docker
29+
docker-compose up -d
30+
```

web-nginx-php55/config/nginx.conf

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# daemon off;
2+
3+
worker_processes auto;
4+
5+
events {
6+
worker_connections 1024;
7+
}
8+
9+
http {
10+
include /etc/nginx/mime.types;
11+
default_type application/octet-stream;
12+
sendfile on;
13+
keepalive_timeout 65;
14+
15+
server {
16+
listen 80;
17+
server_name localhost;
18+
root /var/www/html;
19+
index index.php index.html index.htm;
20+
21+
location / {
22+
try_files $uri $uri/ /index.php?$args;
23+
}
24+
25+
location ~ \.php$ {
26+
try_files $uri =404;
27+
fastcgi_pass 127.0.0.1:9000;
28+
fastcgi_index index.php;
29+
include fastcgi_params;
30+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
31+
}
32+
33+
}
34+
}
+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3'
2+
services:
3+
test:
4+
build: ../
5+
environment:
6+
# 仅为测试用flag
7+
GZCTF_FLAG: "flag{a63b4d37-7681-4850-b6a7-0d7109febb19}"
8+
ports:
9+
# 设置了暴露端口
10+
- 8080:80
11+
restart: unless-stopped
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/sh
2+
3+
rm -f /docker-entrypoint.sh
4+
5+
# Configure Nginx
6+
mkdir mkdir /run/nginx
7+
touch /run/nginx/nginx.pid
8+
9+
# Get the user
10+
user=$(ls /home)
11+
12+
# Check the environment variables for the flag and assign to INSERT_FLAG
13+
# 需要注意,以下语句会将FLAG相关传递变量进行覆盖,如果需要,请注意修改相关操作
14+
if [ "$DASFLAG" ]; then
15+
INSERT_FLAG="$DASFLAG"
16+
export DASFLAG=no_FLAG
17+
DASFLAG=no_FLAG
18+
elif [ "$FLAG" ]; then
19+
INSERT_FLAG="$FLAG"
20+
export FLAG=no_FLAG
21+
FLAG=no_FLAG
22+
elif [ "$GZCTF_FLAG" ]; then
23+
INSERT_FLAG="$GZCTF_FLAG"
24+
export GZCTF_FLAG=no_FLAG
25+
GZCTF_FLAG=no_FLAG
26+
else
27+
INSERT_FLAG="flag{TEST_Dynamic_FLAG}"
28+
fi
29+
30+
# 将FLAG写入文件 请根据需要修改
31+
echo $INSERT_FLAG | tee /flag
32+
33+
chmod 744 /flag
34+
35+
php-fpm & nginx &
36+
37+
echo "Running..."
38+
39+
tail -F /var/log/nginx/access.log /var/log/nginx/error.log

web-nginx-php55/src/flag.php

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
$file_path = "/flag";
3+
if (file_exists($file_path)) {
4+
$flag = file_get_contents($file_path);
5+
}
6+
else{
7+
echo "error";
8+
}
9+
echo $flag;

web-nginx-php55/src/index.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<pre>
2+
3+
____ _____ _____ _ _ _
4+
/ ___|_ _| ___| / \ _ __ ___| |__ (_)_ _____ ___
5+
| | | | | |_ _____ / _ \ | '__/ __| '_ \| \ \ / / _ \/ __|
6+
| |___ | | | _|_____/ ___ \| | | (__| | | | |\ V / __/\__ \
7+
\____| |_| |_| /_/ \_\_| \___|_| |_|_| \_/ \___||___/
8+
9+
10+
</pre>
11+
12+
<h3> Webshell is in /shell.php ,Key is "cmd"</h3>
13+
<h3> flag is in /flag.php </h3>

web-nginx-php55/src/shell.php

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
if(isset($_REQUEST['cmd'])){
3+
echo "<pre>";
4+
$cmd = ($_REQUEST['cmd']);
5+
@eval($cmd);
6+
echo "</pre>";
7+
die;
8+
}
9+
else{
10+
show_source(__FILE__);
11+
phpinfo();
12+
}
13+
14+
?>

web-nginx-php73/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
> 请注意 !!!
1010
>
11-
> 需要注意的是,模板默认会将 flag 保存在 / flag 文件中,如果 PHP 项目中需要直接从环境变量中读取 flag 数据,请在./service/docker-entrypoint.sh 中修改相关操作语句
11+
> 需要注意的是,模板默认会将 flag 保存在 /flag 文件中,如果 PHP 项目中需要直接从环境变量中读取 flag 数据,请在./service/docker-entrypoint.sh 中修改相关操作语句
1212
1313
## 如何使用
1414

0 commit comments

Comments
 (0)