Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add secrets for phreaking service #55

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions config/gen_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ mkdir -p "passwords"
cd "passwords"
./gen_passwords.sh $TEAM_COUNT
)
(
cd "phreaking_secrets"
./gen_phreaking_secrets.sh $TEAM_COUNT
)

for i in $(seq 1 ${TEAM_COUNT}); do
mkdir -p "export/team$i"
Expand All @@ -37,6 +41,11 @@ EOF
systemctl enable wg-quick@game
systemctl start wg-quick@game

cat <<EOF > /services/phreaking/.env
COMPOSE_PROJECT_NAME=phreaking_service
$(cat "phreaking_secrets/team{$i}.phreaking.secrets.txt")
EOF

for service in \$(ls /services/); do
cd "/services/\$service"
if [ -f "/services/\$service/setup.sh" ]; then
Expand Down
7 changes: 7 additions & 0 deletions config/phreaking_secrets/gen_phreaking_secrets.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
for i in $(seq 1 $1); do
PHREAKING_SIM_KEY=$(openssl rand -hex 16)
PHREAKING_GRPC_PASS=$(openssl rand -hex 16)
echo "PHREAKING_SIM_KEY=$PHREAKING_SIM_KEY" > ./team$i.phreaking.secrets.txt
echo "PHREAKING_GRPC_PASS=$PHREAKING_GRPC_PASS" >> ./team$i.phreaking.secrets.txt
done
15 changes: 15 additions & 0 deletions config/phreaking_secrets/parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import sys

n = int(sys.argv[1])

parsed_env_secrets = []

for i in range(1, n + 1):
with open(f"./team{i}.phreaking.secrets.txt") as f:
lines = [line for line in f]
parsed_env_secrets.append(lines[0].replace("PHREAKING_", f"PHREAKING_{i}_"))
parsed_env_secrets.append(lines[1].replace("PHREAKING_", f"PHREAKING_{i}_"))


with open("checker.env", "w") as fp:
fp.writelines(parsed_env_secrets)