Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Commit

Permalink
Allow dynamic flag
Browse files Browse the repository at this point in the history
  • Loading branch information
glzjin committed Sep 28, 2019
1 parent 429d666 commit 672eb87
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM node:boron
FROM node:lts-alpine

COPY phaserquest/ /usr/src/app
COPY _files/ /tmp/

RUN apt-get update && \
apt-get -y upgrade && \
npm install && \
npm install pm2 -g && \
useradd -m ctf && \
RUN cd /usr/src/app && \
npm install -g cnpm --registry=https://registry.npm.taobao.org && \
cnpm install && \
cnpm install pm2 -g && \
addgroup -S ctf && adduser -S ctf -G ctf && \
mv /tmp/processes.yml /root/processes.yml && \
mv /tmp/flag /flag && \
mv /tmp/readflag /readflag && \
mv /tmp/start.sh /start.sh && \
chmod +x /start.sh && \
chmod 555 /readflag && \
chmod u+s /readflag && \
chmod 500 /flag && \
Expand All @@ -19,4 +21,6 @@ RUN apt-get update && \

WORKDIR /usr/src/app

EXPOSE 10081
EXPOSE 8081

ENTRYPOINT ["/start.sh"]
2 changes: 1 addition & 1 deletion _files/processes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ apps:
gid: 'ctf'
output: '/root/out'
error: '/root/error'
args: ["-p 10081","--mongoServer=mongo","--waitForDatabase=5000"]
args: ["-p 8081","--mongoServer=db","--waitForDatabase=5000"]
8 changes: 8 additions & 0 deletions _files/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

echo $FLAG > /flag

export FLAG=not_flag
FLAG=not_flag

pm2-runtime /root/processes.yml
21 changes: 18 additions & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
version: '2.0'

networks:
game_network:
driver: bridge
ipam:
config:
- subnet: 172.91.0.0/16

services:
mongo:
image: 'mongo:3.4.4'
ports:
- '127.0.0.1:27017:27017'
volumes:
- 'mongo:/data/db'
networks:
game_network:
aliases:
- db

phaserquest:
tty: true
Expand All @@ -19,6 +28,12 @@ services:
image: ctftraining/starctf_2019_996game
command: pm2-runtime /root/processes.yml
ports:
- '127.0.0.1:8081:10081'
- '127.0.0.1:8081:8081'
environment:
- FLAG=flag{test_flag}
networks:
game_network:
aliases:
- web
volumes:
mongo:

0 comments on commit 672eb87

Please sign in to comment.