Skip to content

Commit

Permalink
feat: add Docker demo
Browse files Browse the repository at this point in the history
  • Loading branch information
XuCcc committed Feb 21, 2018
1 parent c81f210 commit 3a1051f
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 2 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
## Usage

1. New a Online Challenges with a random token.
2. Copy the token into [send.py](docker/send.py) and change the platfrom url.
2. Copy the token into [send.py](demo/send.py) and change the platfrom url.
3. Copy the `send.py` into your Online envirenment and run it.

* Dockerfile [demo](demo/README.md)

## Install

**Requires**: [CTFd >= 1.1.2](https://github.com/CTFd/CTFd/releases/tag/1.1.2)
Expand All @@ -19,6 +21,7 @@

## TODO

- [x] Useage demo
- [ ] Regenerate the flag when it accessed
- [ ] More detailed log file in Serve and Client
- [ ] Optimize Web UI
Expand Down
34 changes: 34 additions & 0 deletions demo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM ubuntu:16.04

RUN dpkg --add-architecture i386
RUN sed -i "s/http:\/\/archive.ubuntu.com/http:\/\/mirrors.aliyun.com/g" /etc/apt/sources.list
RUN apt-get update && apt-get -y dist-upgrade
RUN apt-get install -y xinetd libc6:i386 libncurses5:i386 libstdc++6:i386
RUN apt-get install -y python2.7 python-pip

RUN useradd -m ctf

COPY ./bin/* /home/ctf/
COPY ./xinetd.conf /etc/xinetd.d/ctf
COPY ./start.sh /root/
COPY ./send.py /root/
COPY ./requirements.txt /root/

RUN pip install -r /root/requirements.txt

# xinted 连接失败信息
RUN echo "Blocked by xinetd" > /etc/banner_fail

RUN chown -R root:ctf /home/ctf &&\
chmod -R 750 /home/ctf &&\
chmod 740 /home/ctf/flag

# flag 日志
RUN touch /root/log
RUN chmod 700 /root/*

WORKDIR /home/ctf

CMD ["/root/start.sh"]

EXPOSE 9999
14 changes: 14 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Docker demo

## Usage

* run `bash RUN.sh`

## Note

**Ensure your send.py and log file privileges are correct so ctfers can't read your challenge token and flag log**

```dockerfile
RUN touch /root/log
RUN chmod 700 /root/*
```
3 changes: 3 additions & 0 deletions demo/RUN.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
docker build -t "pwn" .
docker run -d -p 9999:9999 --name="pwn" pwn
Empty file added demo/bin/flag
Empty file.
Binary file added demo/bin/pwn
Binary file not shown.
File renamed without changes.
2 changes: 1 addition & 1 deletion docker/send.py → demo/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,6 @@ def job():

if __name__ == '__main__':
#TODO insert your detail information here
main('example url','examplt token')
main('example url','examplt token',flagfile='/home/ctf/flag',logfile='/root/log')
while True:
pass
5 changes: 5 additions & 0 deletions demo/start.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

/etc/init.d/xinetd start;
python /root/send.py;
sleep infinity;
12 changes: 12 additions & 0 deletions demo/xinetd.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
service ctf
{
disable = no
socket_type = stream
protocol = tcp
wait = no
user = ctf
bind = 0.0.0.0
server = /home/ctf/pwn
type = UNLISTED
port = 9999
}

0 comments on commit 3a1051f

Please sign in to comment.