Operation and maintenance to build CTFd online shooting range

Posted by svanderclock on Tue, 09 Jun 2020 08:32:52 +0200

CentOS7.2 build ctfd shooting range platform

reference resources

First, there is a 2-core 4G memory 30G disk with no interface in CentOS 7.2

Then network bridging mode

Configure the yum source of CentOS7 to be Alibaba's

  • 1. Install git
yum provides git
yum -y install git
  • 2. Install pip (with pit)

CentOS default python2.7.5 environment, does not support pip

[root@localhost ~]# python -V
Python 2.7.5
[root@localhost ~]# pip -V
 -bash: pip: command not found
[root@localhost ~]# 
[root@localhost ~]# yum -y install python-pip
 Plug in loaded: fastestmirror
Loading mirror speeds from cached hostfile
 No package Python pip is available.
Error: no processing required
[root@localhost ~]#

Install python3

[root@localhost ~]# yum -y install python3

[root@localhost ~]# python3 -V
Python 3.6.8
[root@localhost ~]# 
[root@localhost ~]# pip3 -V
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
[root@localhost ~]# 

The version of pip3 is too low. It needs to be upgraded. Failure to upgrade will result in installation errors
Before upgrading pip3, replace the pypi image source with the domestic (ALI) source. Otherwise, there will be errors in upgrading pip3, and the error reporting network is not reachable

Because there is no. pip directory in ~ / directory, create

[root@localhost ~]# mkdir .pip
[root@localhost ~]# 
[root@localhost ~]# ls -a
.   anaconda-ks.cfg  .bash_logout   .bashrc  .pip             .tcshrc
..  .bash_history    .bash_profile  .cshrc   .python_history  .viminfo
[root@localhost ~]# cd .pip/
[root@localhost .pip]# ls
[root@localhost .pip]# 

Edit profile pip.conf

[root@localhost .pip]# vim pip.conf
[root@localhost .pip]# 
[root@localhost .pip]# cat pip.conf 
[global]
index-url = https://mirrors.aliyun.com/pypi/simple/

[install]
trusted-host=mirrors.aliyun.com

[root@localhost .pip]#

Upgrade pip3 at this time
pip3 install --upgrade pip

[root@localhost ~]# pip3 install --upgrade pip
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pip
  Downloading https://mirrors.aliyun.com/pypi/packages/43/84/23ed6a1796480a6f1a2d38f2802901d078266bda38388954d01d3f2e821d/pip-20.1.1-py2.py3-none-any.whl (1.5MB)
    100% |████████████████████████████████| 1.5MB 30.5MB/s 
Installing collected packages: pip
Successfully installed pip-20.1.1
[root@localhost ~]# 

Successfully upgraded pip3

Check the pip version again

[root@localhost ~]# pip -V
pip 20.1.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
[root@localhost ~]#
  • 3. Install Flask
    pip install Flask
[root@localhost ~]# pip install Flask
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting Flask
  Downloading https://mirrors.aliyun.com/pypi/packages/f2/28/2a03252dfb9ebf377f40fba6a7841b47083260bf8bd8e737b0c6952df83f/Flask-1.1.2-py2.py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 1.6 MB/s 
Collecting Werkzeug>=0.15
  Downloading https://mirrors.aliyun.com/pypi/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
     |████████████████████████████████| 298 kB 5.1 MB/s 
Collecting click>=5.1
  Downloading https://mirrors.aliyun.com/pypi/packages/d2/3d/fa76db83bf75c4f8d338c2fd15c8d33fdd7ad23a9b5e57eb6c5de26b430e/click-7.1.2-py2.py3-none-any.whl (82 kB)
     |████████████████████████████████| 82 kB 401 kB/s 
Collecting itsdangerous>=0.24
  Downloading https://mirrors.aliyun.com/pypi/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
Collecting Jinja2>=2.10.1
  Downloading https://mirrors.aliyun.com/pypi/packages/30/9e/f663a2aa66a09d838042ae1a2c5659828bb9b41ea3a6efa20a20fd92b121/Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
     |████████████████████████████████| 125 kB 24.4 MB/s 
Collecting MarkupSafe>=0.23
  Downloading https://mirrors.aliyun.com/pypi/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
Installing collected packages: Werkzeug, click, itsdangerous, MarkupSafe, Jinja2, Flask
Successfully installed Flask-1.1.2 Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 itsdangerous-1.1.0
[root@localhost ~]#
 
  • 4. Clone CTFd

View git version

[root@localhost ~]# git --version
git version 1.8.3.1
[root@localhost ~]#

Create CTFd directory

[root@localhost ~]# cd /usr/local/
[root@localhost local]# mkdir CTFd
[root@localhost local]# ls
bin  CTFd  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@localhost local]# cd CTFd/
[root@localhost CTFd]# pwd
/usr/local/CTFd
[root@localhost CTFd]#

Start cloning
git clone https://github.com/CTFd/CTFd.git

[root@localhost CTFd]# git clone https://github.com/CTFd/CTFd.git
//Cloning to 'CTFd'...
remote: Enumerating objects: 216, done.
remote: Counting objects: 100% (216/216), done.
remote: Compressing objects: 100% (132/132), done.
remote: Total 10336 (delta 112), reused 125 (delta 78), pack-reused 10120
//Among receiving objects: 100% (10336/10336), 14.90 MiB | 32.00 KiB/s, done.
//In delta processing: 100% (6417/6417), done.
[root@localhost CTFd]# ls
CTFd
[root@localhost CTFd]#
[root@localhost CTFd]# cd CTFd/
[root@localhost CTFd]# pwd
/usr/local/CTFd/CTFd
[root@localhost CTFd]# 
[root@localhost CTFd]# ls
CHANGELOG.md          Dockerfile  migrations        serve.py
conf                  docs        package.json      setup.cfg
CONTRIBUTING.md       export.py   populate.py       tests
CTFd                  import.py   prepare.sh        Vagrantfile
development.txt       LICENSE     README.md         webpack.config.js
docker-compose.yml    Makefile    requirements.txt  wsgi.py
docker-entrypoint.sh  manage.py   scripts           yarn.lock
[root@localhost CTFd]#
  • 4. Install CTFd

pip install -r requirements.txt

[root@localhost CTFd]# pip install -r requirements.txt 
Looking in indexes: https://mirrors.aliyun.com/pypi/simple/
Collecting Flask==1.1.1
  Downloading https://mirrors.aliyun.com/pypi/packages/9b/93/628509b8d5dc749656a9641f4caf13540e2cdec85276964ff8f43bbb1d3b/Flask-1.1.1-py2.py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 3.8 MB/s 
Collecting Werkzeug==0.16.0
  Downloading https://mirrors.aliyun.com/pypi/packages/ce/42/3aeda98f96e85fd26180534d36570e4d18108d62ae36f87694b476b83d6f/Werkzeug-0.16.0-py2.py3-none-any.whl (327 kB)
     |████████████████████████████████| 327 kB 13.4 MB/s 
Collecting Flask-SQLAlchemy==2.4.1
  Downloading https://mirrors.aliyun.com/pypi/packages/1e/65/226d95466c75e34e291a76890ed0e27af2e46ab913002847856f11d4d59d/Flask_SQLAlchemy-2.4.1-py2.py3-none-any.whl (17 kB)
Collecting Flask-Caching==1.4.0
  Downloading https://mirrors.aliyun.com/pypi/packages/63/c0/5dce9fe8372a7b57b60ec7650e1aeb1a2f861393b0c6e7e2dcb71d2f31ab/Flask_Caching-1.4.0-py2.py3-none-any.whl (16 kB)
Collecting Flask-Migrate==2.5.3
  Downloading https://mirrors.aliyun.com/pypi/packages/e5/64/c75f173ba5420f5174be6f04dfa8d8250d4808c12a9cd781e84c0b31684f/Flask_Migrate-2.5.3-py2.py3-none-any.whl (13 kB)
Collecting Flask-Script==2.0.6
  Downloading https://mirrors.aliyun.com/pypi/packages/00/a4/cd587b2b19f043b65bf33ceda2f6e4e6cdbd0ce18d01a52b9559781b1da6/Flask-Script-2.0.6.tar.gz (43 kB)
     |████████████████████████████████| 43 kB 1.8 MB/s 
Collecting SQLAlchemy==1.3.11
  Downloading https://mirrors.aliyun.com/pypi/packages/34/5c/0e1d7ad0ca52544bb12f9cb8d5cc454af45821c92160ffedd38db0a317f6/SQLAlchemy-1.3.11.tar.gz (6.0 MB)
     |████████████████████████████████| 6.0 MB 16.1 MB/s 
Collecting SQLAlchemy-Utils==0.36.0
  Downloading https://mirrors.aliyun.com/pypi/packages/8b/d7/d673a9a72158c45406c27c56d8b0d6c618b1627166b6527486e61902f585/SQLAlchemy-Utils-0.36.0.tar.gz (127 kB)
     |████████████████████████████████| 127 kB 4.1 MB/s 
Collecting passlib==1.7.2
  Downloading https://mirrors.aliyun.com/pypi/packages/11/b8/e9a78f3033228013ba8564adad8d0031bf9d39ea3acc3cdb9d55fabeb4ba/passlib-1.7.2-py2.py3-none-any.whl (507 kB)
     |████████████████████████████████| 507 kB 22.9 MB/s 
Collecting bcrypt==3.1.7
  Downloading https://mirrors.aliyun.com/pypi/packages/8b/1d/82826443777dd4a624e38a08957b975e75df859b381ae302cfd7a30783ed/bcrypt-3.1.7-cp34-abi3-manylinux1_x86_64.whl (56 kB)
     |████████████████████████████████| 56 kB 4.2 MB/s 
Collecting six==1.13.0
  Downloading https://mirrors.aliyun.com/pypi/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: itsdangerous==1.1.0 in /usr/local/lib/python3.6/site-packages (from -r requirements.txt (line 12)) (1.1.0)
Collecting requests>=2.20.0
  Downloading https://mirrors.aliyun.com/pypi/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 7.2 MB/s 
Collecting PyMySQL==0.9.3
  Downloading https://mirrors.aliyun.com/pypi/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl (47 kB)
     |████████████████████████████████| 47 kB 4.1 MB/s 
Collecting gunicorn==19.10.0
  Downloading https://mirrors.aliyun.com/pypi/packages/5f/54/c15f2c243c19074cbf06ce6c48732d99aec825487f87e57e86e9a22990f2/gunicorn-19.10.0-py2.py3-none-any.whl (113 kB)
     |████████████████████████████████| 113 kB 8.8 MB/s 
Collecting dataset==1.1.2
  Downloading https://mirrors.aliyun.com/pypi/packages/d5/02/a4c77a15d004f1307a579e577974fa9292a63e93abff3e40ad993cf597c7/dataset-1.1.2-py2.py3-none-any.whl (14 kB)
Collecting mistune==0.8.4
  Downloading https://mirrors.aliyun.com/pypi/packages/09/ec/4b43dae793655b7d8a25f76119624350b4d65eb663459eb9603d7f1f0345/mistune-0.8.4-py2.py3-none-any.whl (16 kB)
Collecting netaddr==0.7.19
  Downloading https://mirrors.aliyun.com/pypi/packages/ba/97/ce14451a9fd7bdb5a397abf99b24a1a6bb7a1a440b019bebd2e9a0dbec74/netaddr-0.7.19-py2.py3-none-any.whl (1.6 MB)
     |████████████████████████████████| 1.6 MB 25.7 MB/s 
Collecting redis==3.3.11
  Downloading https://mirrors.aliyun.com/pypi/packages/32/ae/28613a62eea0d53d3db3147f8715f90da07667e99baeedf1010eb400f8c0/redis-3.3.11-py2.py3-none-any.whl (66 kB)
     |████████████████████████████████| 66 kB 3.9 MB/s 
Collecting gevent==1.4.0
  Downloading https://mirrors.aliyun.com/pypi/packages/f2/ca/5b5962361ed832847b6b2f9a2d0452c8c2f29a93baef850bb8ad067c7bf9/gevent-1.4.0-cp36-cp36m-manylinux1_x86_64.whl (5.5 MB)
     |████████████████████████████████| 5.5 MB 26.4 MB/s 
Collecting python-dotenv==0.10.3
  Downloading https://mirrors.aliyun.com/pypi/packages/57/c8/5b14d5cffe7bb06bedf9d66c4562bf90330d3d35e7f0266928c370d9dd6d/python_dotenv-0.10.3-py2.py3-none-any.whl (16 kB)
Collecting flask-restx==0.1.1
  Downloading https://mirrors.aliyun.com/pypi/packages/09/f9/ab7ff10f586aacfee415a20a1181a4318e8b446328233908a79e1c5fff45/flask_restx-0.1.1-py2.py3-none-any.whl (2.6 MB)
     |████████████████████████████████| 2.6 MB 1.9 MB/s 
Collecting pathlib2==2.3.5
  Downloading https://mirrors.aliyun.com/pypi/packages/e9/45/9c82d3666af4ef9f221cbb954e1d77ddbb513faf552aea6df5f37f1a4859/pathlib2-2.3.5-py2.py3-none-any.whl (18 kB)
Collecting flask-marshmallow==0.10.1
  Downloading https://mirrors.aliyun.com/pypi/packages/68/4e/7456ef40aeb59e6332e7481705e2b2f27b01772710d9ea1839c2f6379dc2/flask_marshmallow-0.10.1-py2.py3-none-any.whl (9.7 kB)
Collecting marshmallow-sqlalchemy==0.17.0
  Downloading https://mirrors.aliyun.com/pypi/packages/63/b2/73d041a32d3e859c95d3c5ed3f5fca66b5877efaee247015679b9a146546/marshmallow_sqlalchemy-0.17.0-py2.py3-none-any.whl (13 kB)
Collecting boto3==1.13.9
  Downloading https://mirrors.aliyun.com/pypi/packages/34/0b/d6ccca67118f99ad80ca43c92282b25e31c647e8c65b2a65a91efdbb88d3/boto3-1.13.9-py2.py3-none-any.whl (128 kB)
     |████████████████████████████████| 128 kB 3.7 MB/s 
Collecting marshmallow==2.20.2
  Downloading https://mirrors.aliyun.com/pypi/packages/37/ee/ac9932793478432f0ba1bdc0451be244b4dc2b73c0036bd08c40bddfe2f2/marshmallow-2.20.2-py2.py3-none-any.whl (50 kB)
     |████████████████████████████████| 50 kB 5.3 MB/s 
Requirement already satisfied: click>=5.1 in /usr/local/lib/python3.6/site-packages (from Flask==1.1.1->-r requirements.txt (line 1)) (7.1.2)
Requirement already satisfied: Jinja2>=2.10.1 in /usr/local/lib/python3.6/site-packages (from Flask==1.1.1->-r requirements.txt (line 1)) (2.11.2)
Collecting alembic>=0.7
  Downloading https://mirrors.aliyun.com/pypi/packages/60/1e/cabc75a189de0fbb2841d0975243e59bde8b7822bacbb95008ac6fe9ad47/alembic-1.4.2.tar.gz (1.1 MB)
     |████████████████████████████████| 1.1 MB 15.9 MB/s 
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Collecting cffi>=1.1
  Downloading https://mirrors.aliyun.com/pypi/packages/f1/c7/72abda280893609e1ddfff90f8064568bd8bcb2c1770a9d5bb5edb2d1fea/cffi-1.14.0-cp36-cp36m-manylinux1_x86_64.whl (399 kB)
     |████████████████████████████████| 399 kB 19.3 MB/s 
Collecting chardet<4,>=3.0.2
  Downloading https://mirrors.aliyun.com/pypi/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133 kB)
     |████████████████████████████████| 133 kB 21.9 MB/s 
Collecting idna<3,>=2.5
  Downloading https://mirrors.aliyun.com/pypi/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 5.7 MB/s 
Collecting certifi>=2017.4.17
  Downloading https://mirrors.aliyun.com/pypi/packages/57/2b/26e37a4b034800c960a00c4e1b3d9ca5d7014e983e6e729e33ea2f36426c/certifi-2020.4.5.1-py2.py3-none-any.whl (157 kB)
     |████████████████████████████████| 157 kB 22.1 MB/s 
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1
  Downloading https://mirrors.aliyun.com/pypi/packages/e1/e5/df302e8017440f111c11cc41a6b432838672f5a70aa29227bf58149dc72f/urllib3-1.25.9-py2.py3-none-any.whl (126 kB)
     |████████████████████████████████| 126 kB 24.6 MB/s 
Collecting greenlet>=0.4.14; platform_python_implementation == "CPython"
  Downloading https://mirrors.aliyun.com/pypi/packages/bf/45/142141aa47e01a5779f0fa5a53b81f8379ce8f2b1cd13df7d2f1d751ae42/greenlet-0.4.15-cp36-cp36m-manylinux1_x86_64.whl (41 kB)
     |████████████████████████████████| 41 kB 261 kB/s 
Collecting pytz
  Downloading https://mirrors.aliyun.com/pypi/packages/4f/a4/879454d49688e2fad93e59d7d4efda580b783c745fd2ec2a3adf87b0808d/pytz-2020.1-py2.py3-none-any.whl (510 kB)
     |████████████████████████████████| 510 kB 29.3 MB/s 
Collecting jsonschema
  Downloading https://mirrors.aliyun.com/pypi/packages/c5/8f/51e89ce52a085483359217bc72cdbf6e75ee595d5b1d4b5ade40c7e018b8/jsonschema-3.2.0-py2.py3-none-any.whl (56 kB)
     |████████████████████████████████| 56 kB 4.9 MB/s 
Collecting aniso8601>=0.82
  Downloading https://mirrors.aliyun.com/pypi/packages/eb/e4/787e104b58eadc1a710738d4e418d7e599e4e778e52cb8e5d5ef6ddd5833/aniso8601-8.0.0-py2.py3-none-any.whl (43 kB)
     |████████████████████████████████| 43 kB 1.8 MB/s 
Collecting botocore<1.17.0,>=1.16.9
  Downloading https://mirrors.aliyun.com/pypi/packages/66/0f/d75516b712898401e90512e1ffc23dc76481d918ec98aad8a9af9c594809/botocore-1.16.22-py2.py3-none-any.whl (6.2 MB)
     |████████████████████████████████| 6.2 MB 2.4 MB/s 
Collecting s3transfer<0.4.0,>=0.3.0
  Downloading https://mirrors.aliyun.com/pypi/packages/69/79/e6afb3d8b0b4e96cefbdc690f741d7dd24547ff1f94240c997a26fa908d3/s3transfer-0.3.3-py2.py3-none-any.whl (69 kB)
     |████████████████████████████████| 69 kB 5.1 MB/s 
Collecting jmespath<1.0.0,>=0.7.1
  Downloading https://mirrors.aliyun.com/pypi/packages/07/cb/5f001272b6faeb23c1c9e0acc04d48eaaf5c862c17709d20e3469c6e0139/jmespath-0.10.0-py2.py3-none-any.whl (24 kB)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/local/lib64/python3.6/site-packages (from Jinja2>=2.10.1->Flask==1.1.1->-r requirements.txt (line 1)) (1.1.1)
Collecting Mako
  Downloading https://mirrors.aliyun.com/pypi/packages/a6/37/0e706200d22172eb8fa17d68a7ae22dec7631a0a92266634fb518a88a5b2/Mako-1.1.3-py2.py3-none-any.whl (75 kB)
     |████████████████████████████████| 75 kB 3.3 MB/s 
Collecting python-dateutil
  Downloading https://mirrors.aliyun.com/pypi/packages/d4/70/d60450c3dd48ef87586924207ae8907090de0b306af2bce5d134d78615cb/python_dateutil-2.8.1-py2.py3-none-any.whl (227 kB)
     |████████████████████████████████| 227 kB 18.6 MB/s 
Collecting python-editor>=0.3
  Downloading https://mirrors.aliyun.com/pypi/packages/c6/d3/201fc3abe391bbae6606e6f1d598c15d367033332bd54352b12f35513717/python_editor-1.0.4-py3-none-any.whl (4.9 kB)
Collecting pycparser
  Downloading https://mirrors.aliyun.com/pypi/packages/ae/e7/d9c3a176ca4b02024debf82342dab36efadfc5776f9c8db077e8f6e71821/pycparser-2.20-py2.py3-none-any.whl (112 kB)
     |████████████████████████████████| 112 kB 13.7 MB/s 
Collecting importlib-metadata; python_version < "3.8"
  Downloading https://mirrors.aliyun.com/pypi/packages/ad/e4/891bfcaf868ccabc619942f27940c77a8a4b45fd8367098955bb7e152fb1/importlib_metadata-1.6.0-py2.py3-none-any.whl (30 kB)
Collecting attrs>=17.4.0
  Downloading https://mirrors.aliyun.com/pypi/packages/a2/db/4313ab3be961f7a763066401fb77f7748373b6094076ae2bda2806988af6/attrs-19.3.0-py2.py3-none-any.whl (39 kB)
Collecting pyrsistent>=0.14.0
  Downloading https://mirrors.aliyun.com/pypi/packages/9f/0d/cbca4d0bbc5671822a59f270e4ce3f2195f8a899c97d0d5abb81b191efb5/pyrsistent-0.16.0.tar.gz (108 kB)
     |████████████████████████████████| 108 kB 15.0 MB/s 
Requirement already satisfied: setuptools in /usr/lib/python3.6/site-packages (from jsonschema->flask-restx==0.1.1->-r requirements.txt (line 22)) (39.2.0)
Collecting docutils<0.16,>=0.10
  Downloading https://mirrors.aliyun.com/pypi/packages/22/cd/a6aa959dca619918ccb55023b4cb151949c64d4d5d55b3f4ffd7eee0c6e8/docutils-0.15.2-py3-none-any.whl (547 kB)
     |████████████████████████████████| 547 kB 18.2 MB/s 
Collecting zipp>=0.5
  Downloading https://mirrors.aliyun.com/pypi/packages/b2/34/bfcb43cc0ba81f527bc4f40ef41ba2ff4080e047acb0586b56b3d017ace4/zipp-3.1.0-py3-none-any.whl (4.9 kB)
Using legacy setup.py install for Flask-Script, since package 'wheel' is not installed.
Using legacy setup.py install for SQLAlchemy, since package 'wheel' is not installed.
Using legacy setup.py install for SQLAlchemy-Utils, since package 'wheel' is not installed.
Using legacy setup.py install for pyrsistent, since package 'wheel' is not installed.
Building wheels for collected packages: alembic
  Building wheel for alembic (PEP 517) ... done
  Created wheel for alembic: filename=alembic-1.4.2-py2.py3-none-any.whl size=159543 sha256=20973e78f43c2af0634e9ee7978e3db2f3a925736a85c837830b3ba4a354d26d
  Stored in directory: /root/.cache/pip/wheels/16/31/2d/d9d8ac02e09ae9e002e1088a7c9019cab9e06dc15f512ca4f7
Successfully built alembic
Installing collected packages: Werkzeug, Flask, SQLAlchemy, Flask-SQLAlchemy, Flask-Caching, Mako, six, python-dateutil, python-editor, alembic, Flask-Migrate, Flask-Script, SQLAlchemy-Utils, passlib, pycparser, cffi, bcrypt, chardet, idna, certifi, urllib3, requests, PyMySQL, gunicorn, dataset, mistune, netaddr, redis, greenlet, gevent, python-dotenv, pytz, zipp, importlib-metadata, attrs, pyrsistent, jsonschema, aniso8601, flask-restx, pathlib2, marshmallow, flask-marshmallow, marshmallow-sqlalchemy, docutils, jmespath, botocore, s3transfer, boto3
  Attempting uninstall: Werkzeug
    Found existing installation: Werkzeug 1.0.1
    Uninstalling Werkzeug-1.0.1:
      Successfully uninstalled Werkzeug-1.0.1
  Attempting uninstall: Flask
    Found existing installation: Flask 1.1.2
    Uninstalling Flask-1.1.2:
      Successfully uninstalled Flask-1.1.2
    Running setup.py install for SQLAlchemy ... done
    Running setup.py install for Flask-Script ... done
    Running setup.py install for SQLAlchemy-Utils ... done
    Running setup.py install for pyrsistent ... done
Successfully installed Flask-1.1.1 Flask-Caching-1.4.0 Flask-Migrate-2.5.3 Flask-SQLAlchemy-2.4.1 Flask-Script-2.0.6 Mako-1.1.3 PyMySQL-0.9.3 SQLAlchemy-1.3.11 SQLAlchemy-Utils-0.36.0 Werkzeug-0.16.0 alembic-1.4.2 aniso8601-8.0.0 attrs-19.3.0 bcrypt-3.1.7 boto3-1.13.9 botocore-1.16.22 certifi-2020.4.5.1 cffi-1.14.0 chardet-3.0.4 dataset-1.1.2 docutils-0.15.2 flask-marshmallow-0.10.1 flask-restx-0.1.1 gevent-1.4.0 greenlet-0.4.15 gunicorn-19.10.0 idna-2.9 importlib-metadata-1.6.0 jmespath-0.10.0 jsonschema-3.2.0 marshmallow-2.20.2 marshmallow-sqlalchemy-0.17.0 mistune-0.8.4 netaddr-0.7.19 passlib-1.7.2 pathlib2-2.3.5 pycparser-2.20 pyrsistent-0.16.0 python-dateutil-2.8.1 python-dotenv-0.10.3 python-editor-1.0.4 pytz-2020.1 redis-3.3.11 requests-2.23.0 s3transfer-0.3.3 six-1.13.0 urllib3-1.25.9 zipp-3.1.0
[root@localhost CTFd]#
  • 5. Start CTFd

Before starting, make sure the firewall is fixed and the default port 4000 is released

[root@localhost CTFd]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since IV. 2020-06-04 10:38:56 CST; 1h 2min ago
 Main PID: 874 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─874 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

6 October 4:38:54 localhost.localdomain systemd[1]: Starting firewalld - dyna...
6 October 4:38:56 localhost.localdomain systemd[1]: Started firewalld - dynam...
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost CTFd]# 
[root@localhost CTFd]# firewall-cmd --list-ports
[root@localhost CTFd]# 
[root@localhost CTFd]# firewall-cmd --zone=public --add-port=4000/tcp --permanent
success
[root@localhost CTFd]# firewall-cmd --reload
success
[root@localhost CTFd]# firewall-cmd --list-ports
4000/tcp
[root@localhost CTFd]#

Let's see serve.py Document (know what it is, know why it is)

[root@localhost CTFd]# cat serve.py 
from CTFd import create_app
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--port", help="Port for debug server to listen on", default=4000)
parser.add_argument(
    "--profile", help="Enable flask_profiler profiling", action="store_true"
)
args = parser.parse_args()

app = create_app()

if args.profile:
    from flask_debugtoolbar import DebugToolbarExtension
    import flask_profiler

    app.config["flask_profiler"] = {
        "enabled": app.config["DEBUG"],
        "storage": {"engine": "sqlite"},
        "basicAuth": {"enabled": False},
        "ignore": ["^/themes/.*", "^/events"],
    }
    flask_profiler.init_app(app)
    app.config["DEBUG_TB_PROFILER_ENABLED"] = True
    app.config["DEBUG_TB_INTERCEPT_REDIRECTS"] = False

    toolbar = DebugToolbarExtension()
    toolbar.init_app(app)
    print(" * Flask profiling running at http://127.0.0.1:4000/flask-profiler/")

app.run(debug=True, threaded=True, host="127.0.0.1", port=args.port)
[root@localhost CTFd]#

Because you want to use it in the internal LAN, change the host to 0.0.0.0

vim serve.py
print(" * Flask profiling running at http://0.0.0.0:4000/flask-profiler/")

app.run(debug=True, threaded=True, host="0.0.0.0", port=args.port)
[root@localhost CTFd]#

Start starting next (recommended background start mode)

pyhton3 serve.py

[root@localhost CTFd]# python3 serve.py 
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
 * Loaded module, <module 'CTFd.plugins.challenges' from '/usr/local/CTFd/CTFd/CTFd/plugins/challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.dynamic_challenges' from '/usr/local/CTFd/CTFd/CTFd/plugins/dynamic_challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.flags' from '/usr/local/CTFd/CTFd/CTFd/plugins/flags/__init__.py'>
 * Serving Flask app "CTFd" (lazy loading)
 * Environment: development
 * Debug mode: on
INFO  [werkzeug]  * Running on http://0.0.0.0:4000/ (Press CTRL+C to quit)
INFO  [werkzeug]  * Restarting with stat
INFO  [alembic.runtime.migration] Context impl SQLiteImpl.
INFO  [alembic.runtime.migration] Will assume non-transactional DDL.
 * Loaded module, <module 'CTFd.plugins.challenges' from '/usr/local/CTFd/CTFd/CTFd/plugins/challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.dynamic_challenges' from '/usr/local/CTFd/CTFd/CTFd/plugins/dynamic_challenges/__init__.py'>
 * Loaded module, <module 'CTFd.plugins.flags' from '/usr/local/CTFd/CTFd/CTFd/plugins/flags/__init__.py'>
WARNI [werkzeug]  * Debugger is active!
INFO  [werkzeug]  * Debugger PIN: 329-498-992

This is the start-up

Background start mode (recommended)

[root@localhost CTFd]# pwd
/usr/local/CTFd/CTFd
[root@localhost CTFd]# 
[root@localhost CTFd]# nohup python3 serve.py &
[1] 5614
[root@localhost CTFd]# Nohup: ignore input and append output to“ nohup.out "

[root@localhost CTFd]#

6. Now browser to open http://IP:4000/

(just modified server.py The host in the configuration file is for LAN access. IP is the IP of CentOS7 virtual machine external network.)

You can register after accessing

Administration

Admin Username
admin

Admin Email

Admin Password
admin

Then step by step Next
Finally Finish

Then visit again
http://IP:4000/

At this time, you can Register/Login at the top right

At this time, log in to the account just registered

7. Go to CTFd to put questions

After creating an administrator account, click admin - > challenge in the upper right corner to add all the time. The first one is the name. Here is the editing status of one of my topics. This platform can use Markdown to edit topics.

Click Admin Panel at the top of the page
Then click on Challenges at the top of the page

Just put the questions directly after entering

__
Pure entertainment

Topics: pip Python git firewall