在GDK8中使用Docker搭建CTFD

主要步骤:

  1. sudo apt-get update
  2. sudo apt-get install \
     ca-certificates \
     curl \
     gnupg \
     lsb-release
  3. 添加 Docker 的官方GPG密钥。
    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  4. 设置稳定存储库。
    echo \
    "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
    $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
  5. sudo apt-get update
  6. 安装Docker引擎和容器。
    sudo apt-get install docker-ce docker-ce-cli containerd.io
  7. 运行“Hello World”测试Docker是否运行成功。
geduer@gdk8:~$ sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
93288797bd35: Pull complete
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (arm64v8)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/
  1. 安装docker-compose和pip。
    sudo apt install docker-compose
    sudo apt install python-pip
  2. 获取CTFD。
    root@gdk8:/home/geduer# git clone https://github.com/CTFd/CTFd.git
    Cloning into 'CTFd'...
    remote: Enumerating objects: 14046, done.
    remote: Counting objects: 100% (903/903), done.
    remote: Compressing objects: 100% (576/576), done.
    remote: Total 14046 (delta 498), reused 599 (delta 304), pack-reused 13143
    Receiving objects: 100% (14046/14046), 25.85 MiB | 801.00 KiB/s, done.
    Resolving deltas: 100% (8709/8709), done.
  3. 进入CTFD目录。
    cd CTFd/
  4. 部署CTFD。
    root@gdk8:/home/geduer/CTFd# docker-compose up -d
    Building ctfd
    Step 1/13 : FROM python:3.7-slim-buster
    ---> 3696725a24f4
    Step 2/13 : WORKDIR /opt/CTFd
    ---> Using cache
    ---> 6a9572150ef3
    Step 3/13 : RUN mkdir -p /opt/CTFd /var/log/CTFd /var/uploads
    ---> Using cache
    ---> 6ac9ee2a363b
    Step 4/13 : RUN apt-get update     && apt-get install -y --no-install-recommends         build-essential         python3-dev         libffi-dev         libssl-dev         git     && apt-get clean     && rm -rf /var/lib/apt/lists/*
    ---> Using cache
    ---> 60ba85a17547
    Step 5/13 : COPY requirements.txt /opt/CTFd/
    ---> Using cache
    ---> 4cbc15be3908
    Step 6/13 : RUN pip install -r requirements.txt --no-cache-dir
    ---> Running in d020cdef3c59
    Collecting alembic==1.4.3
    Downloading alembic-1.4.3-py2.py3-none-any.whl (159 kB)
    Collecting aniso8601==8.0.0
    Downloading aniso8601-8.0.0-py2.py3-none-any.whl (43 kB)
    Collecting attrs==20.3.0
    Downloading attrs-20.3.0-py2.py3-none-any.whl (49 kB)
    Collecting bcrypt==3.1.7
    Downloading bcrypt-3.1.7-cp35-abi3-manylinux2014_aarch64.whl (56 kB)
    Collecting boto3==1.13.9
    Downloading boto3-1.13.9-py2.py3-none-any.whl (128 kB)
    Collecting botocore==1.16.26
    Downloading botocore-1.16.26-py2.py3-none-any.whl (6.2 MB)
    Collecting certifi==2020.11.8
    Downloading certifi-2020.11.8-py2.py3-none-any.whl (155 kB)
    Collecting cffi==1.14.3
    Downloading cffi-1.14.3-cp37-cp37m-manylinux2014_aarch64.whl (205 kB)
    Collecting chardet==3.0.4
    Downloading chardet-3.0.4-py2.py3-none-any.whl (133 kB)
    Collecting click==7.1.2
    Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
    Collecting cmarkgfm==0.4.2
    Downloading cmarkgfm-0.4.2.tar.gz (133 kB)
    Collecting dataset==1.3.1
    Downloading dataset-1.3.1-py2.py3-none-any.whl (16 kB)
    Collecting docutils==0.15.2
    Downloading docutils-0.15.2-py3-none-any.whl (547 kB)
    Collecting flask==1.1.2
    Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
    Collecting flask-caching==1.8.0
    Downloading Flask_Caching-1.8.0-py2.py3-none-any.whl (28 kB)
    Collecting flask-marshmallow==0.10.1
    Downloading flask_marshmallow-0.10.1-py2.py3-none-any.whl (9.7 kB)
    Collecting flask-migrate==2.5.3
    Downloading Flask_Migrate-2.5.3-py2.py3-none-any.whl (13 kB)
    Collecting flask-restx==0.5.1
    Downloading flask_restx-0.5.1-py2.py3-none-any.whl (5.3 MB)
    Collecting flask-script==2.0.6
    Downloading Flask-Script-2.0.6.tar.gz (43 kB)
    Collecting flask-sqlalchemy==2.4.3
    Downloading Flask_SQLAlchemy-2.4.3-py2.py3-none-any.whl (17 kB)
    Collecting gevent==20.9.0
    Downloading gevent-20.9.0.tar.gz (5.8 MB)
    Installing build dependencies: started
    Installing build dependencies: finished with status 'done'
    Getting requirements to build wheel: started
    Getting requirements to build wheel: finished with status 'done'
    Preparing wheel metadata: started
    Preparing wheel metadata: finished with status 'done'
    Collecting greenlet==0.4.17
    Downloading greenlet-0.4.17.tar.gz (61 kB)
    Collecting gunicorn==20.0.4
    Downloading gunicorn-20.0.4-py2.py3-none-any.whl (77 kB)
    Collecting idna==2.10
    Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
    Collecting itsdangerous==1.1.0
    Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
    Collecting jinja2==2.11.3
    Downloading Jinja2-2.11.3-py2.py3-none-any.whl (125 kB)
    Collecting jmespath==0.10.0
    Downloading jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
    Collecting jsonschema==3.2.0
    Downloading jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
    Collecting mako==1.1.3
    Downloading Mako-1.1.3-py2.py3-none-any.whl (75 kB)
    Collecting markupsafe==1.1.1
    Downloading MarkupSafe-1.1.1-cp37-cp37m-manylinux2014_aarch64.whl (34 kB)
    Collecting marshmallow==2.20.2
    Downloading marshmallow-2.20.2-py2.py3-none-any.whl (50 kB)
    Collecting marshmallow-sqlalchemy==0.17.0
    Downloading marshmallow_sqlalchemy-0.17.0-py2.py3-none-any.whl (13 kB)
    Collecting maxminddb==1.5.4
    Downloading maxminddb-1.5.4.tar.gz (282 kB)
    Collecting passlib==1.7.2
    Downloading passlib-1.7.2-py2.py3-none-any.whl (507 kB)
    Collecting pybluemonday==0.0.8
    Downloading pybluemonday-0.0.8-cp37-cp37m-manylinux2014_aarch64.whl (1.9 MB)
    Collecting pycparser==2.20
    Downloading pycparser-2.20-py2.py3-none-any.whl (112 kB)
    Collecting pydantic==1.6.2
    Downloading pydantic-1.6.2-py36.py37.py38-none-any.whl (99 kB)
    Collecting pymysql==0.9.3
    Downloading PyMySQL-0.9.3-py2.py3-none-any.whl (47 kB)
    Collecting pyrsistent==0.17.3
    Downloading pyrsistent-0.17.3.tar.gz (106 kB)
    Collecting python-dateutil==2.8.1
    Downloading python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
    Collecting python-dotenv==0.13.0
    Downloading python_dotenv-0.13.0-py2.py3-none-any.whl (17 kB)
    Collecting python-editor==1.0.4
    Downloading python_editor-1.0.4-py3-none-any.whl (4.9 kB)
    Collecting python-geoacumen-city==0.0.1
    Downloading python_geoacumen_city-0.0.1-py3-none-any.whl (46.2 MB)
    Collecting pytz==2020.4
    Downloading pytz-2020.4-py2.py3-none-any.whl (509 kB)
    Collecting redis==3.5.2
    Downloading redis-3.5.2-py2.py3-none-any.whl (71 kB)
    Collecting requests==2.23.0
    Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
    Collecting s3transfer==0.3.3
    Downloading s3transfer-0.3.3-py2.py3-none-any.whl (69 kB)
    Collecting six==1.15.0
    Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
    Collecting sqlalchemy==1.3.17
    Downloading SQLAlchemy-1.3.17.tar.gz (6.0 MB)
    Collecting sqlalchemy-utils==0.36.6
    Downloading SQLAlchemy-Utils-0.36.6.tar.gz (131 kB)
    Collecting tenacity==6.2.0
    Downloading tenacity-6.2.0-py2.py3-none-any.whl (24 kB)
    Collecting urllib3==1.25.11
    Downloading urllib3-1.25.11-py2.py3-none-any.whl (127 kB)
    Collecting werkzeug==1.0.1
    Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
    Collecting wtforms==2.3.1
    Downloading WTForms-2.3.1-py2.py3-none-any.whl (169 kB)
    Collecting zope.event==4.5.0
    Downloading zope.event-4.5.0-py2.py3-none-any.whl (6.8 kB)
    Collecting zope.interface==5.2.0
    Downloading zope.interface-5.2.0-cp37-cp37m-manylinux2014_aarch64.whl (237 kB)
    Requirement already satisfied: setuptools in /usr/local/lib/python3.7/site-packages (from gevent==20.9.0->-r requirements.txt (line 63)) (57.5.0)
    Collecting importlib-metadata
    Downloading importlib_metadata-4.10.0-py3-none-any.whl (17 kB)
    Collecting zipp>=0.5
    Downloading zipp-3.6.0-py3-none-any.whl (5.3 kB)
    Collecting typing-extensions>=3.6.4
    Downloading typing_extensions-4.0.1-py3-none-any.whl (22 kB)
    WARNING: The candidate selected for download or install is a yanked version: 'sqlalchemy-utils' candidate (version 0.36.6 at https://files.pythonhosted.org/packages/aa/d3/f397b61a2eee34d023e7c1f2519b6e5a7058f3d857461eaa539cc38e1e85/SQLAlchemy-Utils-0.36.6.tar.gz#sha256=7a7fab14bed80df065412bbf71a0a9b0bfeb4b7c111c2d9bffe57283082f3a6b (from https://pypi.org/simple/sqlalchemy-utils/))
    Reason for being yanked: Wrong required python
    Building wheels for collected packages: cmarkgfm, flask-script, gevent, greenlet, maxminddb, pyrsistent, sqlalchemy, sqlalchemy-utils
    Building wheel for cmarkgfm (setup.py): started
    Building wheel for cmarkgfm (setup.py): still running...
    Building wheel for cmarkgfm (setup.py): finished with status 'done'
    Created wheel for cmarkgfm: filename=cmarkgfm-0.4.2-cp37-cp37m-linux_aarch64.whl size=142259 sha256=f0a5f16804c83a2e4b8c7300c0359e2bfc794fd0520118b0adff868d81eda639
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/db/f8/4c/98543d48d7800bc32789de2390ffa42d3b8b0b1b11482be751
    Building wheel for flask-script (setup.py): started
    Building wheel for flask-script (setup.py): finished with status 'done'
    Created wheel for flask-script: filename=Flask_Script-2.0.6-py3-none-any.whl size=14030 sha256=cd845e141580bf0c8406db4a7a5933c74e3762e1ea6f2f88ded8b1381df73b24
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/b5/fb/6b/01ea56e8a6486540ebe086676c8b3a823f1bbcc830df0cd4f0
    Building wheel for gevent (PEP 517): started
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): still running...
    Building wheel for gevent (PEP 517): finished with status 'done'
    Created wheel for gevent: filename=gevent-20.9.0-cp37-cp37m-linux_aarch64.whl size=1685900 sha256=02363f2abfbd21714a20fd0b3dd72cfe1e6d7d27d8f22a7e047b3698e56f44a3
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/e1/e1/e5/671f19af80d4ed3bab205a89f9007c91834fe58c57d78ba952
    Building wheel for greenlet (setup.py): started
    Building wheel for greenlet (setup.py): finished with status 'done'
    Created wheel for greenlet: filename=greenlet-0.4.17-cp37-cp37m-linux_aarch64.whl size=17902 sha256=0d096f42f7045a3464ff75d054bf84a6e23a2d0c27f3f4a719496e88bc4f1d5f
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/f2/c4/5d/bb1d89ddbfdd1c883f88dd4d6e78f06a1883fd2a75c8599a2b
    Building wheel for maxminddb (setup.py): started
    Building wheel for maxminddb (setup.py): finished with status 'done'
    Created wheel for maxminddb: filename=maxminddb-1.5.4-py3-none-any.whl size=14883 sha256=a5d8577d41c9121bc3aa2e5abab725e1905a90849499366bcb7018d49a635bd1
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/88/1a/59/ac41813b0e9e8029c24438ea75df969cce6c5ce987edfa91d2
    Building wheel for pyrsistent (setup.py): started
    Building wheel for pyrsistent (setup.py): finished with status 'done'
    Created wheel for pyrsistent: filename=pyrsistent-0.17.3-cp37-cp37m-linux_aarch64.whl size=71644 sha256=597667f41b007ab4a6c65584357d9b627111d00e8521fc3ee3a6ca875d20f0e6
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/a5/52/bf/71258a1d7b3c8cbe1ee53f9314c6f65f20385481eaee573cc5
    Building wheel for sqlalchemy (setup.py): started
    Building wheel for sqlalchemy (setup.py): finished with status 'done'
    Created wheel for sqlalchemy: filename=SQLAlchemy-1.3.17-cp37-cp37m-linux_aarch64.whl size=1196620 sha256=304985a918e0682e8b0aeaa18c5d021b7bf4488b02a0eea8fa595b23a7db725e
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/70/26/41/63f111cd9934f3e7942516328dafa1df0ad2eed214801bcf11
    Building wheel for sqlalchemy-utils (setup.py): started
    Building wheel for sqlalchemy-utils (setup.py): finished with status 'done'
    Created wheel for sqlalchemy-utils: filename=SQLAlchemy_Utils-0.36.6-py2.py3-none-any.whl size=93423 sha256=2fb0bbdc01a0bc523c65cf09c698fa4a024154b0d5924c83890544cfc9c5f3dc
    Stored in directory: /tmp/pip-ephem-wheel-cache-x0xtb4c4/wheels/ee/1c/08/f909098fa6951122800a79bad277864f309ed72024c7bbafed
    Successfully built cmarkgfm flask-script gevent greenlet maxminddb pyrsistent sqlalchemy sqlalchemy-utils
    Installing collected packages: six, markupsafe, zipp, werkzeug, urllib3, typing-extensions, python-dateutil, jmespath, jinja2, itsdangerous, docutils, click, sqlalchemy, python-editor, pyrsistent, pycparser, mako, importlib-metadata, flask, botocore, attrs, zope.interface, zope.event, s3transfer, pytz, maxminddb, marshmallow, jsonschema, idna, greenlet, flask-sqlalchemy, chardet, cffi, certifi, aniso8601, alembic, wtforms, tenacity, sqlalchemy-utils, requests, redis, python-geoacumen-city, python-dotenv, pymysql, pydantic, pybluemonday, passlib, marshmallow-sqlalchemy, gunicorn, gevent, flask-script, flask-restx, flask-migrate, flask-marshmallow, flask-caching, dataset, cmarkgfm, boto3, bcrypt
    Successfully installed alembic-1.4.3 aniso8601-8.0.0 attrs-20.3.0 bcrypt-3.1.7 boto3-1.13.9 botocore-1.16.26 certifi-2020.11.8 cffi-1.14.3 chardet-3.0.4 click-7.1.2 cmarkgfm-0.4.2 dataset-1.3.1 docutils-0.15.2 flask-1.1.2 flask-caching-1.8.0 flask-marshmallow-0.10.1 flask-migrate-2.5.3 flask-restx-0.5.1 flask-script-2.0.6 flask-sqlalchemy-2.4.3 gevent-20.9.0 greenlet-0.4.17 gunicorn-20.0.4 idna-2.10 importlib-metadata-4.10.0 itsdangerous-1.1.0 jinja2-2.11.3 jmespath-0.10.0 jsonschema-3.2.0 mako-1.1.3 markupsafe-1.1.1 marshmallow-2.20.2 marshmallow-sqlalchemy-0.17.0 maxminddb-1.5.4 passlib-1.7.2 pybluemonday-0.0.8 pycparser-2.20 pydantic-1.6.2 pymysql-0.9.3 pyrsistent-0.17.3 python-dateutil-2.8.1 python-dotenv-0.13.0 python-editor-1.0.4 python-geoacumen-city-0.0.1 pytz-2020.4 redis-3.5.2 requests-2.23.0 s3transfer-0.3.3 six-1.15.0 sqlalchemy-1.3.17 sqlalchemy-utils-0.36.6 tenacity-6.2.0 typing-extensions-4.0.1 urllib3-1.25.11 werkzeug-1.0.1 wtforms-2.3.1 zipp-3.6.0 zope.event-4.5.0 zope.interface-5.2.0
    WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
    WARNING: You are using pip version 21.2.4; however, version 21.3.1 is available.
    You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command.
    Removing intermediate container d020cdef3c59
    ---> 4e05e9baa7d4
    Step 7/13 : COPY . /opt/CTFd
    ---> 453c64e61e15
    Step 8/13 : RUN for d in CTFd/plugins/*; do         if [ -f "$d/requirements.txt" ]; then             pip install -r $d/requirements.txt --no-cache-dir;         fi;     done;
    ---> Running in 9c545e233480
    Removing intermediate container 9c545e233480
    ---> 9cd424406b4c
    Step 9/13 : RUN adduser     --disabled-login     -u 1001     --gecos ""     --shell /bin/bash     ctfd
    ---> Running in 69a9d681fa56
    Adding user `ctfd' ...
    Adding new group `ctfd' (1001) ...
    Adding new user `ctfd' (1001) with group `ctfd' ...
    Creating home directory `/home/ctfd' ...
    Copying files from `/etc/skel' ...
    Removing intermediate container 69a9d681fa56
    ---> 4af588b475d8
    Step 10/13 : RUN chmod +x /opt/CTFd/docker-entrypoint.sh     && chown -R 1001:1001 /opt/CTFd /var/log/CTFd /var/uploads
    ---> Running in 0da36c0d6f7d
    Removing intermediate container 0da36c0d6f7d
    ---> 6a069927db29
    Step 11/13 : USER 1001
    ---> Running in 452907b121ec
    Removing intermediate container 452907b121ec
    ---> db260c5112f0
    Step 12/13 : EXPOSE 8000
    ---> Running in a2d6853ed94f
    Removing intermediate container a2d6853ed94f
    ---> 48daf5c838a3
    Step 13/13 : ENTRYPOINT ["/opt/CTFd/docker-entrypoint.sh"]
    ---> Running in e692a24c3cf5
    Removing intermediate container e692a24c3cf5
    ---> 24f99988b9fe
    Successfully built 24f99988b9fe
    Successfully tagged ctfd_ctfd:latest
    WARNING: Image for service ctfd was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
    Pulling nginx (nginx:1.17)...
    1.17: Pulling from library/nginx
    8a7e1e68c24e: Pull complete
    c9439a7503ec: Pull complete
    0c69e1f095a8: Pull complete
    Digest: sha256:6fff55753e3b34e36e24e37039ee9eae1fe38a6420d8ae16ef37c92d1eb26699
    Status: Downloaded newer image for nginx:1.17
    Pulling cache (redis:4)...
    4: Pulling from library/redis
    bdc84a41f251: Pull complete
    698d3e76f19f: Pull complete
    ac4bbea6248c: Pull complete
    2aeaea3e9c04: Pull complete
    6fb4291f955c: Pull complete
    14ae5d3407b5: Pull complete
    Digest: sha256:2e03fdd159f4a08d2165ca1c92adde438ae4e3e6b0f74322ce013a78ee81c88d
    Status: Downloaded newer image for redis:4
    Creating ctfd_cache_1 ...
    Creating ctfd_db_1 ...
    Creating ctfd_cache_1
    Creating ctfd_db_1 ... done
    Creating ctfd_ctfd_1 ...
    Creating ctfd_ctfd_1 ... done
    Creating ctfd_nginx_1 ...
    Creating ctfd_nginx_1 ... done
  5. 查看CTFD是否运行。
    root@gdk8:/home/geduer/CTFd# docker ps
    CONTAINER ID   IMAGE             COMMAND                  CREATED       STATUS          PORTS                                       NAMES
    49aec3d1080d   nginx:1.17        "nginx -g 'daemon of…"   2 hours ago   Up 32 minutes   0.0.0.0:80->80/tcp, :::80->80/tcp           ctfd_nginx_1
    15b49ca150bc   ctfd_ctfd         "/opt/CTFd/docker-en…"   2 hours ago   Up 32 minutes   0.0.0.0:8000->8000/tcp, :::8000->8000/tcp   ctfd_ctfd_1
    51245c08dcad   mariadb:10.4.12   "docker-entrypoint.s…"   2 hours ago   Up 32 minutes                                               ctfd_db_1
    fe71962ac02c   redis:4           "docker-entrypoint.s…"   2 hours ago   Up 32 minutes                                               ctfd_cache_1
  6. 成功运行CTFD,此时就可以在上面去联系各种各样的CTF题目了!
  7. 创建名为CTFTraining的文件夹。
    mkdir CTFTraining
    cd CTFTraining
  8. 从GitHub上面获取一道CTF题目。
    git clone https://github.com/CTFTraining/0ctf_2016_unserialize.git
    cd  cd 0ctf_2016_unserialize/
  9. 执行下方命令。
root@gdk8:/home/geduer/CTFd/CTFTraining/0ctf_2016_unserialize# docker-compose up -d
Creating network "0ctf2016unserialize_default" with the default driver
Building web
Step 1/8 : FROM php:5.6-fpm-alpine
5.6-fpm-alpine: Pulling from library/php
e3c488b39803: Pull complete
05a63128803b: Pull complete
73bf4a12ae92: Pull complete
cf309e8a13c2: Pull complete
2290f763cb3e: Pull complete
40454187f965: Pull complete
f79f093cae6c: Pull complete
4441b3c1390f: Pull complete
c29712475e01: Pull complete
a398da3178e3: Pull complete
b97002fbd961: Pull complete
Digest: sha256:e3845c650c700234be3fb5b94865753d1a4534f8820d4dea1d0ee6d875efe02b
Status: Downloaded newer image for php:5.6-fpm-alpine
 ---> 60d87df578cf
Step 2/8 : LABEL Author="Virink <virink@outlook.com>"
 ---> Running in 334bf9425626
Removing intermediate container 334bf9425626
 ---> e6c8e79bf7c8
Step 3/8 : LABEL Blog="https://www.virzz.com"
 ---> Running in 04469f346358
Removing intermediate container 04469f346358
 ---> 191cb1aea882
Step 4/8 : COPY files /tmp/
 ---> 7d9429e7891f
Step 5/8 : RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories     && apk add --update --no-cache nginx mysql mysql-client     && docker-php-source extract     && docker-php-ext-install mysql     && docker-php-source delete     && mysql_install_db --user=mysql --datadir=/var/lib/mysql     && sh -c 'mysqld_safe &'  && sleep 5s     && mysqladmin -uroot password 'qwertyuiop'     && mysql -e "source /tmp/db.sql;" -uroot -pqwertyuiop     && mkdir /run/nginx     && mv /tmp/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint     && mv /tmp/nginx.conf /etc/nginx/nginx.conf     && mv /tmp/vhost.nginx.conf /etc/nginx/conf.d/default.conf     && mv /tmp/src/* /var/www/html     && chmod -R -w /var/www/html     && chmod -R 777 /var/www/html/upload     && chown -R www-data:www-data /var/www/html     && rm -rf /tmp/*     && rm -rf /etc/apk
 ---> Running in f3315dd50ecc
fetch http://mirrors.ustc.edu.cn/alpine/v3.8/main/aarch64/APKINDEX.tar.gz
fetch http://mirrors.ustc.edu.cn/alpine/v3.8/community/aarch64/APKINDEX.tar.gz
(1/11) Installing mariadb-common (10.2.32-r0)
(2/11) Installing libaio (0.3.111-r0)
(3/11) Installing linux-pam (1.3.0-r0)
(4/11) Installing pcre (8.42-r0)
(5/11) Installing libgcc (6.4.0-r9)
(6/11) Installing libstdc++ (6.4.0-r9)
(7/11) Installing mariadb (10.2.32-r0)
Executing mariadb-10.2.32-r0.pre-install
(8/11) Installing mysql (10.2.32-r0)
(9/11) Installing mariadb-client (10.2.32-r0)
(10/11) Installing mysql-client (10.2.32-r0)
(11/11) Installing nginx (1.14.2-r2)
Executing nginx-1.14.2-r2.pre-install
Executing busybox-1.28.4-r2.trigger
OK: 157 MiB in 40 packages
fetch http://mirrors.ustc.edu.cn/alpine/v3.8/main/aarch64/APKINDEX.tar.gz
fetch http://mirrors.ustc.edu.cn/alpine/v3.8/community/aarch64/APKINDEX.tar.gz
(1/25) Upgrading musl (1.1.19-r10 -> 1.1.19-r11)
(2/25) Installing m4 (1.4.18-r1)
(3/25) Installing libbz2 (1.0.6-r7)
(4/25) Installing perl (5.26.3-r0)
(5/25) Installing autoconf (2.69-r2)
(6/25) Installing pkgconf (1.5.3-r0)
(7/25) Installing dpkg-dev (1.18.24-r0)
(8/25) Installing dpkg (1.18.24-r0)
(9/25) Installing libmagic (5.32-r2)
(10/25) Installing file (5.32-r2)
(11/25) Installing binutils (2.30-r6)
(12/25) Installing gmp (6.1.2-r1)
(13/25) Installing isl (0.18-r0)
(14/25) Installing libgomp (6.4.0-r9)
(15/25) Installing libatomic (6.4.0-r9)
(16/25) Installing mpfr3 (3.1.5-r1)
(17/25) Installing mpc1 (1.0.3-r1)
(18/25) Installing gcc (6.4.0-r9)
(19/25) Installing musl-dev (1.1.19-r11)
(20/25) Installing libc-dev (0.7.1-r0)
(21/25) Installing g++ (6.4.0-r9)
(22/25) Installing make (4.2.1-r2)
(23/25) Installing re2c (1.0.2-r0)
(24/25) Installing .phpize-deps (0)
(25/25) Upgrading musl-utils (1.1.19-r10 -> 1.1.19-r11)
Executing busybox-1.28.4-r2.trigger
OK: 348 MiB in 63 packages
Configuring for:
PHP Api Version:         20131106
Zend Module Api No:      20131226
Zend Extension Api No:   220131226
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
expr: syntax error
sh: 0: unknown operand
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... aarch64-unknown-linux-musl
checking host system type... aarch64-unknown-linux-musl
checking target system type... aarch64-unknown-linux-musl
checking for PHP prefix... /usr/local
checking for PHP includes... -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib
checking for PHP extension directory... /usr/local/lib/php/extensions/no-debug-non-zts-20131226
checking for PHP installed headers prefix... /usr/local/include/php
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 1.0.2 (ok)
checking for gawk... no
checking for nawk... no
checking for awk... awk
checking if awk is broken... no
checking for MySQL support... yes, shared
checking for specified location of the MySQL UNIX socket... no
checking for the location of libz... no
checking for MySQL UNIX socket location... no
checking for ld used by cc... /usr/aarch64-alpine-linux-musl/bin/ld
checking if the linker (/usr/aarch64-alpine-linux-musl/bin/ld) is GNU ld... yes
checking for /usr/aarch64-alpine-linux-musl/bin/ld option to reload object files... -r
checking for BSD-compatible nm... /usr/bin/nm -B
checking whether ln -s works... yes
checking how to recognize dependent libraries... pass_all
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
checking the maximum length of command line arguments... 98304
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for objdir... .libs
checking for ar... ar
checking for ranlib... ranlib
checking for strip... strip
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC
checking if cc PIC flag -fPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking whether the cc linker (/usr/aarch64-alpine-linux-musl/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no

creating libtool
appending configuration tag "CXX" to libtool
configure: creating ./config.status
config.status: creating config.h
/bin/sh /usr/src/php/ext/mysql/libtool --mode=compile cc  -I. -I/usr/src/php/ext/mysql -DPHP_ATOM_INC -I/usr/src/php/ext/mysql/include -I/usr/src/php/ext/mysql/main -I/usr/src/php/ext/mysql -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2   -c /usr/src/php/ext/mysql/php_mysql.c -o php_mysql.lo
mkdir .libs
 cc -I. -I/usr/src/php/ext/mysql -DPHP_ATOM_INC -I/usr/src/php/ext/mysql/include -I/usr/src/php/ext/mysql/main -I/usr/src/php/ext/mysql -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H -fstack-protector-strong -fpic -fpie -O2 -c /usr/src/php/ext/mysql/php_mysql.c  -fPIC -DPIC -o .libs/php_mysql.o
/bin/sh /usr/src/php/ext/mysql/libtool --mode=link cc -DPHP_ATOM_INC -I/usr/src/php/ext/mysql/include -I/usr/src/php/ext/mysql/main -I/usr/src/php/ext/mysql -I/usr/local/include/php -I/usr/local/include/php/main -I/usr/local/include/php/TSRM -I/usr/local/include/php/Zend -I/usr/local/include/php/ext -I/usr/local/include/php/ext/date/lib  -fstack-protector-strong -fpic -fpie -O2 -DHAVE_CONFIG_H  -fstack-protector-strong -fpic -fpie -O2  -Wl,-O1 -Wl,--hash-style=both -pie -o mysql.la -export-dynamic -avoid-version -prefer-pic -module -rpath /usr/src/php/ext/mysql/modules  php_mysql.lo
cc -shared  .libs/php_mysql.o   -Wl,-O1 -Wl,--hash-style=both -Wl,-soname -Wl,mysql.so -o .libs/mysql.so
creating mysql.la
(cd .libs && rm -f mysql.la && ln -s ../mysql.la mysql.la)
/bin/sh /usr/src/php/ext/mysql/libtool --mode=install cp ./mysql.la /usr/src/php/ext/mysql/modules
cp ./.libs/mysql.so /usr/src/php/ext/mysql/modules/mysql.so
cp ./.libs/mysql.lai /usr/src/php/ext/mysql/modules/mysql.la
PATH="$PATH:/sbin" ldconfig -n /usr/src/php/ext/mysql/modules
----------------------------------------------------------------------
Libraries have been installed in:
   /usr/src/php/ext/mysql/modules

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------

Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/local/lib/php/extensions/no-debug-non-zts-20131226/
find . -name \*.gcno -o -name \*.gcda | xargs rm -f
find . -name \*.lo -o -name \*.o | xargs rm -f
find . -name \*.la -o -name \*.a | xargs rm -f
find . -name \*.so | xargs rm -f
find . -name .libs -a -type d|xargs rm -rf
rm -f libphp.la       modules/* libs/*
WARNING: Ignoring APKINDEX.08e24dc9.tar.gz: No such file or directory
WARNING: Ignoring APKINDEX.a90370d5.tar.gz: No such file or directory
(1/23) Purging .phpize-deps (0)
(2/23) Purging autoconf (2.69-r2)
(3/23) Purging m4 (1.4.18-r1)
(4/23) Purging dpkg-dev (1.18.24-r0)
(5/23) Purging perl (5.26.3-r0)
(6/23) Purging dpkg (1.18.24-r0)
(7/23) Purging file (5.32-r2)
(8/23) Purging g++ (6.4.0-r9)
(9/23) Purging gcc (6.4.0-r9)
(10/23) Purging binutils (2.30-r6)
(11/23) Purging libatomic (6.4.0-r9)
(12/23) Purging libgomp (6.4.0-r9)
(13/23) Purging libc-dev (0.7.1-r0)
(14/23) Purging musl-dev (1.1.19-r11)
(15/23) Purging make (4.2.1-r2)
(16/23) Purging pkgconf (1.5.3-r0)
(17/23) Purging re2c (1.0.2-r0)
(18/23) Purging libbz2 (1.0.6-r7)
(19/23) Purging libmagic (5.32-r2)
(20/23) Purging mpc1 (1.0.3-r1)
(21/23) Purging mpfr3 (3.1.5-r1)
(22/23) Purging isl (0.18-r0)
(23/23) Purging gmp (6.1.2-r1)
Executing busybox-1.28.4-r2.trigger
OK: 157 MiB in 40 packages
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
2021-12-28 10:47:59 547402951336 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1146: Table 'mysql.gtid_slave_pos' doesn't exist
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h f3315dd50ecc password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

211228 10:48:02 mysqld_safe Logging to '/var/lib/mysql/f3315dd50ecc.err'.
211228 10:48:02 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Removing intermediate container f3315dd50ecc
 ---> 6eaed645b106
Step 6/8 : EXPOSE 80
 ---> Running in a1ea131fd0fb
Removing intermediate container a1ea131fd0fb
 ---> ce22da73dd1c
Step 7/8 : VOLUME ["/var/log/nginx"]
 ---> Running in f78b0aeb225f
Removing intermediate container f78b0aeb225f
 ---> 0ee27746d212
Step 8/8 : CMD ["/bin/sh", "-c", "docker-php-entrypoint"]
 ---> Running in b0425ab0f24a
Removing intermediate container b0425ab0f24a
 ---> d82e342cd6d4
Successfully built d82e342cd6d4
Successfully tagged ctftraining/0ctf_2016_unserialize:latest
WARNING: Image for service web was built because it did not already exist. To rebuild this image you must use `docker-compose build` or `docker-compose up --build`.
Creating 0ctf2016unserialize_web_1 ...
Creating 0ctf2016unserialize_web_1 ... done
root@gdk8:/home/geduer/CTFd/CTFTraining/0ctf_2016_unserialize# docker-compose up --build
Building web
Step 1/8 : FROM php:5.6-fpm-alpine
 ---> 60d87df578cf
Step 2/8 : LABEL Author="Virink <virink@outlook.com>"
 ---> Using cache
 ---> e6c8e79bf7c8
Step 3/8 : LABEL Blog="https://www.virzz.com"
 ---> Using cache
 ---> 191cb1aea882
Step 4/8 : COPY files /tmp/
 ---> Using cache
 ---> 7d9429e7891f
Step 5/8 : RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories     && apk add --update --no-cache nginx mysql mysql-client     && docker-php-source extract     && docker-php-ext-install mysql     && docker-php-source delete     && mysql_install_db --user=mysql --datadir=/var/lib/mysql     && sh -c 'mysqld_safe &'  && sleep 5s     && mysqladmin -uroot password 'qwertyuiop'     && mysql -e "source /tmp/db.sql;" -uroot -pqwertyuiop     && mkdir /run/nginx     && mv /tmp/docker-php-entrypoint /usr/local/bin/docker-php-entrypoint     && mv /tmp/nginx.conf /etc/nginx/nginx.conf     && mv /tmp/vhost.nginx.conf /etc/nginx/conf.d/default.conf     && mv /tmp/src/* /var/www/html     && chmod -R -w /var/www/html     && chmod -R 777 /var/www/html/upload     && chown -R www-data:www-data /var/www/html     && rm -rf /tmp/*     && rm -rf /etc/apk
 ---> Using cache
 ---> 6eaed645b106
Step 6/8 : EXPOSE 80
 ---> Using cache
 ---> ce22da73dd1c
Step 7/8 : VOLUME ["/var/log/nginx"]
 ---> Using cache
 ---> 0ee27746d212
Step 8/8 : CMD ["/bin/sh", "-c", "docker-php-entrypoint"]
 ---> Using cache
 ---> d82e342cd6d4
Successfully built d82e342cd6d4
Successfully tagged ctftraining/0ctf_2016_unserialize:latest
0ctf2016unserialize_web_1 is up-to-date
Attaching to 0ctf2016unserialize_web_1
web_1  | tail: can't open '/var/log/nginx/error.log': No such file or directory
web_1  | tail: can't open '/var/log/nginx/access.log': No such file or directory
web_1  | 211228 10:48:20 mysqld_safe Logging to '/var/lib/mysql/0d7dac354119.err'.
web_1  | [28-Dec-2021 10:48:20] NOTICE: fpm is running, pid 9
web_1  | [28-Dec-2021 10:48:20] NOTICE: ready to handle connections
web_1  | 211228 10:48:20 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
web_1  | tail: /var/log/nginx/error.log has appeared; following end of new file
web_1  | tail: /var/log/nginx/access.log has appeared; following end of new file
^CGracefully stopping... (press Ctrl+C again to force)
Stopping 0ctf2016unserialize_web_1 ... done
root@gdk8:/home/geduer/CTFd/CTFTraining/0ctf_2016_unserialize# docker-compose up -d
Starting 0ctf2016unserialize_web_1 ...
Starting 0ctf2016unserialize_web_1 ... done
  1. 此时打开浏览器,输入127.0.0.1:8302,就可以开始做题了!
作者:admin  创建时间:2021-12-28 18:24
最后编辑:admin  更新时间:2024-07-05 11:40