You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Make sure you have an active account at GCP for which you have configured the credentials on the system where you will execute the steps below.
19
19
20
20
Please note that this setup relies on bash scripts that have been tested in MacOS and Linux. We have no intention of supporting vanilla Windows at the moment.
21
21
22
-
23
22
### Multi-user setup: shared state
24
23
25
24
If you want to host a multi-user setup, you will probably want to share the state file so that everyone can try related challenges. We have provided a starter to easily do so using a Terraform gcs backend.
@@ -51,42 +50,95 @@ The bucket name should be in the output. Please use that to configure the Terraf
51
50
6. Run `terraform plan`
52
51
7. Run `terraform apply`. Note: the apply will take 10 to 20 minutes depending on the speed of the GCP backplane.
53
52
8. Run `export USE_GKE_GCLOUD_AUTH_PLUGIN=True`
54
-
9. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`. Note if it errors on a missing plugin to support `kubectl`, then run `gcloud components install gke-gcloud-auth-plugin` and `gcloud container clusters get-credentials wrongsecrets-exercise-cluster` .
55
-
10. Run `./k8s-vault-gcp-start.sh`
53
+
9. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`. Note if it errors on a missing plugin to support `kubectl`, then run `gcloud components install gke-gcloud-auth-plugin` and `gcloud container clusters get-credentials wrongsecrets-exercise-cluster`.
54
+
10. Go to the values of the helm chart and replace the wrongsecrets.config with this:
55
+
56
+
```yaml
57
+
K8S_ENV: "azure"
58
+
```
59
+
60
+
and replace the value of wrongsecrets.env having the name 'K8S_ENV' with this:
56
61
57
-
### GKE ingres for shared deployment
62
+
```yaml
63
+
value: "azure"
64
+
```
58
65
59
-
By default the deployment uses a nodePort tunneled to localhost. For a larger audience deployment the wrongsecrets app can deployed with a GKE ingress, run `k8s-vault-gcp-ingress-start.sh`
60
-
Please note that the GKE ingress can take a few minues to deploy and is publicly available. A connection URL will be returned once the ingress is available. Note that, after the connection URL is returned, a first lookup might still take a minute, after which it is much faster.
66
+
11. Run `./build-and-deploy-gcp.sh`
61
67
62
68
Your GKE cluster should be visible in [EU-West4](https://console.cloud.google.com/kubernetes?referrer=search&project=wrongsecrets) by default. Want a different region? You can modify `terraform.tfvars` or input it directly using the `region` variable in plan/apply.
63
69
64
70
Are you done playing? Please run `terraform destroy` twice to clean up.
65
71
66
72
### Test it
67
73
68
-
Run `./k8s-vault-gcp-start.sh` and connect to [http://localhost:8080](http://localhost:8080) when it's ready to accept connections (you'll read the line `Forwarding from 127.0.0.1:8080 -> 8080` in your console). Now challenge 9 and 10 should be available as well.
74
+
When you have completed the installation steps, you can do `kubectl port-forward service/wrongsecrets-balancer 3000:3000` and then go to [http://localhost:3000](http://localhost:3000).
75
+
76
+
Want to know how well your cluster is holding up? Check with
77
+
78
+
```sh
79
+
kubectl top nodes
80
+
kubectl top pods
81
+
```
82
+
83
+
### Configuring CTFd
84
+
85
+
You can use the [Juiceshop CTF CLI](https://github.com/juice-shop/juice-shop-ctf) to generate CTFd configuration files.
juice-shop-ctf #choose ctfd and https://wrongsecrets-ctf.herokuapp.com as domain. No trailing slash! The key is 'test', by default feel free to enable hints. We do not support snippets or links/urls to code or hints.
92
+
```
93
+
94
+
Now visit the CTFd instance and setup your CTF. To test things locally before setting up a load balancer/ingress, you can use `kubectl port-forward -n ctfd $(kubectl get pods --namespace ctfd -l "app.kubernetes.io/name=ctfd,app.kubernetes.io/instance=ctfd" -o jsonpath="{.items[0].metadata.name}") 8000:8000` and go to `localhost:8000` to visit CTFd.
69
95
70
-
### Resume it
96
+
_!!NOTE:_ **The following can be dangerous if you use CTFd `>= 3.5.0` with wrongsecrets `< 1.5.11`. Check the `challenges.json` and make sure it's 1-indexed - a 0-indexed file will break CTFd!** _/NOTE!!_
71
97
72
-
When you stopped the `k8s-vault-gcp-start.sh` script and want to resume the port forward run: `k8s-vault-gcp-resume.sh`. This is because if you run the start script again it will replace the secret in the vault and not update the secret-challenge application with the new secret.
98
+
Then use the administrative backup function to import the zipfile you created with the juice-shop-ctf command.
99
+
After that you will still need to override the flags with their actual values if you do use the 2-domain configuration. For a guide on how to do this see the 2-domain setup steps in the general [README](../readme.md)
100
+
Want to setup your own? You can! Watch out for people finding your key though, so secure it properly: make sure the running container with the actual ctf-key is not exposed to the audience, similar to our heroku container.
101
+
102
+
Want to make the CTFD instance look pretty? Include the fragment located at [./k8s/ctfd_resources/index_fragment.html](/k8s/ctfd_resources/index_fragment.html) in your index.html via the admin panel.
103
+
104
+
If you want to share with others go to the [When you want to share your environment with others (experimental)](#when-you-want-to-share-your-environment-with-others-experimental) section.
105
+
106
+
### Configuring the application
107
+
108
+
In the front page of the application you can edit the description to reference the right urls and the desplayed image. Use the following:
2. Run `terraform destroy` to clean up the infrastructure.
80
-
3. Run `unset KUBECONFIG` to unset the KUBECONFIG env var.
81
-
4. Run `rm ~/.kube/wrongsecrets` to remove the kubeconfig file.
82
-
5. Run `rm terraform.tfstate*` to remove local state files.
122
+
2. Run `terraform destroy` to clean up the infrastructure. Note that you may need to repeat the destroy to fully clean up.
123
+
3. If you've used the shared state, `cd` to the `shared-state` folder and run `terraform destroy` there too.
124
+
4. Run `rm terraform.tf*` to remove local state files.
83
125
84
126
### A few things to consider
85
127
86
128
1. Does your worker node now have access as well?
87
-
2. Can you easily obtain the GCP IAM role of the Node?
88
-
3. Can you get the secrets in the SSM Parameter Store and Secret Manager easily? Which paths do you see?
89
-
4. You should see at the configuration details of the cluster that `databaseEncryption` is `DECRYPTED` (`gcloud container clusters describe wrongsecrets-exercise-cluster --region europe-west4`). What does that mean?
129
+
2. Can you easily obtain the AKS managed identity of the Node?
130
+
3. Can you get the secrets in the Key vault? Which paths do you see?
131
+
132
+
### When you want to share your environment with others (experimental)
133
+
134
+
We added additional scripts for adding a Load Balancer and ingress so that you can use your cloud setup with multiple people.
135
+
Do the following:
136
+
137
+
1. Follow the installation section first.
138
+
2. Run `./k8s-nginx-lb-script.sh` and the script will return the url at which you can reach the application. (Be aware this opens the url's to the internet in general, if you'd like to limit the access please do this using the security groups in Azure)
139
+
3. When you are done, before you do cleanup, first run `./k8s-nginx-lb-script-cleanup.sh`.
140
+
141
+
Note that you might have to do some manual cleanups after that.
0 commit comments