搭建CTFd平臺
老規矩,看版本吧,是Ubuntu 16.04
root@cat:~/CTFd# cat /etc/issue
Ubuntu 16.04.3 LTS \n \l
先來安裝docker跟Docker-compose
wget -qO- https://get.docker.com/ | sh
sudo usermod -aG docker username ##你的用戶名
##安裝完成之後,可以看看docker版本
#使用dockers --version可以查看
root@cat:~/CTFd# docker --version
Docker version 19.03.1, build *******
curl -L https://github.com/docker/compose/releases/download/1.25.0-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
安裝完成之後記得查看一下,我這是後記錄的,可能跟安裝時有偏差,emma:
root@cat:~/CTFd# docker-compose verison
No such command: verison
Commands:
build Build or rebuild services
bundle Generate a Docker bundle from the Compose file
config Validate and view the Compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
exec Execute a command in a running container
help Get help on a command
images List images
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pull service images
push Push service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
top Display the running processes
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
然後咱們再來安裝一下CTFd,我是root,天下無敵......
git clone https://github.com/CTFd/CTFd.git && cd CTFd
docker-compose up -d
然後我們來查看一下容器:
root@cat:~/CTFd# docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------
ctfd_cache_1 docker-entrypoint.sh redis ... Up
ctfd_ctfd_1 /opt/CTFd/docker-entrypoint.sh Up 0.0.0.0:8000->8000/tcp
ctfd_db_1 docker-entrypoint.sh mysql ... Up
雖說搭建完了,但是,還是沒法在公網上訪問,接下來就映射一下(我也不知道咋搞,大佬勿噴,我就記錄下日常)
iptables -t nat -A DOCKER -p tcp --dport 8001 -j DNAT --to-destination IP地址:8000
不過,記得在服務器上加上這個端口
然後就到了激動人心的時候了:
這個地方自己配置下,然後,就,就沒有然後了呀
博客蒐集了網上很多教程,總結了下,太多了,就不都寫了,若有侵犯,聯繫刪,打擾了
搭建webug靶場
先從docker hub把webug靶場pull下來
root@cat:~# docker pull area39/webug
Using default tag: latest
latest: Pulling from area39/webug
a7344f52cb74: Pull complete
515c9bb51536: Pull complete
e1eabe0537eb: Pull complete
4701f1215c13: Pull complete
47e9dc58a04a: Pull complete
e2f5bef92572: Pull complete
d4ff2baf456b: Pull complete
8bcee2bcac01: Pull complete
bed1605ff912: Pull complete
c76295730308: Pull complete
c9546d0b81a1: Pull complete
9f15afb3efc0: Pull complete
Digest: sha256:6618efa0a7df17f92af86969397ea2098c01848f6dcecafe6cd82f25c8e4ef2f
Status: Downloaded newer image for area39/webug:latest
docker.io/area39/webug:latest
然後啓動這個鏡像:
root@cat:~# docker run -d -P area39/webug
6a751485b6cb389f21d3ba4c50538525ac56936e12862b44115093cd4444a630
然後咱們將端口映射到公網上的端口,記得要在服務器上開啓這個端口哦,這裏我不貼圖了,跟上面一樣:
root@cat:~# iptables -t nat -A DOCKER -p tcp --dport 32771 -j DNAT --to-destination IP地址:32771
我們看一下已經啓動的docker鏡像們
root@cat:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c232b4f6273f area39/webug "httpd-foreground" 7 minutes ago Up 7 minutes 0.0.0.0:32771->80/tcp beautiful_wing
cb227de9496d ctfd_ctfd "/opt/CTFd/docker-en…" 30 hours ago Up 30 hours 0.0.0.0:8000->8000/tcp ctfd_ctfd_1
8a4f65f5bc08 redis:4 "docker-entrypoint.s…" 30 hours ago Up 30 hours ctfd_cache_1
bd0fb8e68088 mariadb:10.4 "docker-entrypoint.s…" 30 hours ago Up 21 hours ctfd_db_1