forked from DeveshChande/ctf-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·84 lines (74 loc) · 2.79 KB
/
setup.sh
File metadata and controls
executable file
·84 lines (74 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# Welcome Screen
display_banner () {
banner="__ _____ ____ _____ ____ _____ __ ____ _____ ____ ____ _____ _____
\ \ / /_ _/ ___| ____| _ \ / _ \ \ / / | _ \| ____/ ___| _ \| ____| ____|
\ \ / / | | | | _| | |_) | | | \ V / | | | | _|| | | |_) | _| | _|
\ V / | | |___| |___| _ <| |_| || | | |_| | |__| |___| _ <| |___| |___
\_/ |___\____|_____|_| \_\\___/ |_| |____/|_____\____|_| \_\_____|_____|"
echo -e "$banner\n"
}
# Verify Root Context
verify_user_context () {
if [ "$EUID" -ne 0 ]; then
echo -e "This script requires the utility of packages that assume root privileges. Please run as root or use sudo.\n"
exit 1
fi
}
# Install Dependencies
install_dependencies () {
packages=(
ca-certificates
curl
git
)
apt update
for package in "${packages[@]}"; do
echo "Installing $package..."
apt install -y "$package"
done
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get update
dependencies=(
docker-ce
docker-ce-cli
containerd.io
docker-buildx-plugin
docker-compose-plugin
)
for dependency in "${dependencies[@]}"; do
echo "Installing $dependency..."
apt install -y "$dependency"
done
}
# Install core CTFd infrastructure
fetch_core_ctfd () {
git clone https://github.com/CTFd/CTFd.git
}
# Install CTFd plugins
fetch_ctfd_plugins () {
git clone https://github.com/YWxleGlz/CTFd-Plugins.git
mv CTFd-Plugins/CTFd-Unique_flags CTFd/plugins/unique_flags
git clone https://github.com/Bigyls/CTFdDockerContainersPlugin.git CTFd/plugins/containers
}
deploy_ctfd () {
cd CTFd
openssl genrsa -out ./conf/nginx/private.key 4096
openssl req -new -key ./conf/nginx/private.key -out ./conf/nginx/certificate.csr -subj "/C=US/ST=MA/L=Boston/O=Northeastern University/OU=Khoury College of Computer Sciences/CN=Casual CTF"
openssl x509 -req -days 365 -in ./conf/nginx/certificate.csr -signkey ./conf/nginx/private.key -out ./conf/nginx/self-signed-cert.crt
sudo docker build -t challenge-base-template:latest -f ../dockerfiles/Dockerfile .
docker compose up
}
display_banner
verify_user_context
install_dependencies
fetch_core_ctfd
fetch_ctfd_plugins
deploy_ctfd
# Command to run in Docker container is /usr/sbin/sshd -D (this will execute the ssh server and keep it running in the foreground indefinitely)