Projects STRLCPY wrongsecrets Commits 6878b1e2
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■
    .github/scripts/docker-create.sh
    skipped 6 lines
    7 7   # Display Help
    8 8   echo "A versatile script to create a docker image for testing. Call this script with no arguments to simply create a local image that you can use to test your changes. For more complex use see the below help section"
    9 9   echo
    10  - echo "Syntax: docker-create.sh [-h (help)|-t (test)|-p (publish)|-e (herokud)|-f (herokup)|-g (fly)|-n (notag) [tag={tag}|message={message}|buildarg={buildarg}|springProfile={springProfile}]"
     10 + echo "Syntax: docker-create.sh [-h (help)|-t (test)|-p (publish)|-e (herokud)|-f (herokup)|-g (fly)|-o (okteto)|-n (notag) [tag={tag}|message={message}|buildarg={buildarg}|springProfile={springProfile}]"
    11 11   echo "options: (All optional)"
    12 12   echo "tag= Write a custom tag that will be added to the container when it is build locally."
    13 13   echo "message= Write a message used for the actual tag-message in git"
    skipped 14 lines
    28 28   exit
    29 29   fi
    30 30  }
     31 + 
     32 +Okteto_redeploy(){
     33 + break_on_tag
     34 + echo "Rebuilding the Okteto environment: https://wrongsecrets-commjoen.cloud.okteto.net/"
     35 + echo "Check if all required binaries are installed"
     36 + source ../../scripts/check-available-commands.sh
     37 + checkCommandsAvailable okteto
     38 + echo "validating okteto k8 deployment to contain the right container with tag "${tag}" (should be part of '$(cat ../../okteto/k8s/secret-challenge-deployment.yml | grep image)')"
     39 + if [[ "$(cat ../../okteto/k8s/secret-challenge-deployment.yml | grep image)" != *"${tag}"* ]]; then
     40 + echo "tag ${tag} in ../../okteto/k8s/secret-challenge-deployment.yml not properly set, aborting"
     41 + exit
     42 + fi
     43 + cd ../../okteto
     44 + okteto destroy
     45 + okteto deploy
     46 +}
     47 + 
    31 48  heroku_check_container() {
    32 49   break_on_tag
    33 50   echo "validating dockerfile to contain tag "${tag}" (should be part of '$(head -n 1 ../../Dockerfile.web)')"
    skipped 56 lines
    90 107  # Set option to local if no option provided
    91 108  script_mode="local"
    92 109  # Parse provided options
    93  -while getopts ":htpefgn*" option; do
     110 +while getopts ":htpefgon*" option; do
    94 111   case $option in
    95 112   h) # display Help
    96 113   Help
    skipped 14 lines
    111 128   g) #Helper
    112 129   script_mode="fly_p"
    113 130   ;;
     131 + o) #okteto
     132 + script_mode="okteto"
     133 + ;;
    114 134   n) #notags
    115 135   disable_tagging_in_git="true"
    116 136   ;;
    skipped 10 lines
    127 147  ################################################
    128 148  for ARGUMENT in "$@";
    129 149  do
    130  - if [[ $ARGUMENT != "-h" && $ARGUMENT != "-t" && $ARGUMENT != "-p" && $ARGUMENT != "-e" && $ARGUMENT != "-f" && $ARGUMENT != "-g" ]]
     150 + if [[ $ARGUMENT != "-h" && $ARGUMENT != "-t" && $ARGUMENT != "-p" && $ARGUMENT != "-e" && $ARGUMENT != "-f" && $ARGUMENT != "-g" && $ARGUMENT != "-o" ]]
    131 151   then
    132 152   KEY=$(echo "$ARGUMENT" | cut -f1 -d=)
    133 153   KEY_LENGTH=${#KEY}
    skipped 54 lines
    188 208   Heroku_publish_prod
    189 209  elif [[ $script_mode == "fly_p" ]]; then
    190 210   Fly_publish
     211 +elif [[ $script_mode == "okteto" ]]; then
     212 + Okteto_redeploy
    191 213  fi
    192 214  
    193 215   
    skipped 80 lines
    274 296   echo "Creating containers"
    275 297   if [[ "$script_mode" == "publish" ]]; then
    276 298   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
     299 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
    277 300   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
     301 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
    278 302   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:$tag-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
     303 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/addo-example:latest-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
    279 304   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
     305 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-no-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --push ./../../.
    280 306   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
     307 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-local-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=local-vault" --push ./../../.
    281 308   docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:$tag-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
     309 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets:latest-k8s-vault --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=kubernetes-vault" --push ./../../.
    282 310   cd ../..
    283  - docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:$tag -f Dockerfile.webdesktop --push .
     311 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:$tag -f Dockerfile_webdesktop --push .
     312 + docker buildx build --platform linux/amd64,linux/arm64 -t jeroenwillemsen/wrongsecrets-desktop:latest -f Dockerfile_webdesktop --push .
    284 313   cd .github/scripts
    285 314   elif [[ "$script_mode" == "test" ]]; then
    286 315   docker buildx build -t jeroenwillemsen/wrongsecrets:$tag --build-arg "$buildarg" --build-arg "PORT=8081" --build-arg "argBasedVersion=$tag" --build-arg "spring_profile=without-vault" --load ./../../.
    skipped 84 lines
  • ■ ■ ■ ■ ■ ■
    Dockerfile.web
    1  -FROM jeroenwillemsen/wrongsecrets:jre18test2-no-vault
     1 +FROM jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
    2 2   
    3  -ARG argBasedVersion="1.5.2"
     3 +ARG argBasedVersion="1.5.3RC1"
    4 4  ARG CANARY_URLS="http://canarytokens.com/terms/about/s7cfbdakys13246ewd8ivuvku/post.jsp,http://canarytokens.com/terms/about/y0all60b627gzp19ahqh7rl6j/post.jsp"
    5 5  ARG CTF_ENABLED=false
    6 6  ARG HINTS_ENABLED=true
    skipped 26 lines
  • ■ ■ ■ ■ ■
    Dockerfile.webdesktop Dockerfile_webdesktop
    skipped 8 lines
    9 9   touch /var/run/docker.sock && \
    10 10   chown abc:abc /var/run/docker.sock && \
    11 11   echo "**** cleanup ****" && \
    12  - rm -rf \
    13  - /tmp/*
     12 + rm -rf /tmp/*
    14 13   
    15 14  WORKDIR /config/Desktop
    16 15   
    skipped 6 lines
  • ■ ■ ■ ■ ■ ■
    README.md
    skipped 9 lines
    10 10  secrets. These can help you to realize whether your secret management is ok. The challenge is to find all the different
    11 11  secrets by means of various tools and techniques.
    12 12   
    13  -Can you solve all the 23 challenges?
     13 +Can you solve all the 24 challenges?
    14 14  ![screenshot.png](screenshot.png)
    15 15   
    16 16  ## Support
    skipped 7 lines
    24 24   
    25 25  ## Basic docker exercises
    26 26   
    27  -_Can be used for challenges 1-4, 8, 12-23_
     27 +_Can be used for challenges 1-4, 8, 12-24_
    28 28   
    29 29  For the basic docker exercises you currently require:
    30 30   
    skipped 3 lines
    34 34  You can install it by doing:
    35 35   
    36 36  ```bash
    37  -docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:1.5.2-no-vault
     37 +docker run -p 8080:8080 jeroenwillemsen/wrongsecrets:latest-no-vault
    38 38  ```
    39 39   
    40 40  Now you can try to find the secrets by means of solving the challenge offered at:
    skipped 15 lines
    56 56  - [localhost:8080/challenge/21](http://localhost:8080/challenge/21)
    57 57  - [localhost:8080/challenge/22](http://localhost:8080/challenge/22)
    58 58  - [localhost:8080/challenge/23](http://localhost:8080/challenge/23)
     59 +- [localhost:8080/challenge/24](http://localhost:8080/challenge/24)
    59 60   
    60 61  Note that these challenges are still very basic, and so are their explanations. Feel free to file a PR to make them look
    61 62  better ;-).
    skipped 19 lines
    81 82   
    82 83  ## Basic K8s exercise
    83 84   
    84  -_Can be used for challenges 1-6, 8, 12-23_
     85 +_Can be used for challenges 1-6, 8, 12-24_
    85 86   
    86 87  ### Minikube based
    87 88   
    skipped 38 lines
    126 127  - [localhost:8080/challenge/5](http://localhost:8080/challenge/5)
    127 128  - [localhost:8080/challenge/6](http://localhost:8080/challenge/6)
    128 129   
     130 +### Okteto based
     131 + 
     132 +Don't want to go over the hassle of setting up K8S yourself? visit [https://wrongsecrets-commjoen.cloud.okteto.net](https://wrongsecrets-commjoen.cloud.okteto.net/). Please note that we are using the free Developer version here, so it might take a while for it to respond. Please: do not try to hack/Fuzz the application as this might bring it down and spoil the fun for others.
     133 + 
    129 134  ## Vault exercises with minikube
    130 135   
    131  -_Can be used for challenges 1-8, 12-23_
     136 +_Can be used for challenges 1-8, 12-24_
    132 137  Make sure you have the following installed:
    133 138   
    134 139  - minikube with docker (or comment out line 8 and work at your own k8s setup),
    skipped 13 lines
    148 153   
    149 154  ## Cloud Challenges
    150 155   
    151  -_Can be used for challenges 1-23_
     156 +_Can be used for challenges 1-24_
    152 157   
    153 158  **READ THIS**: Given that the exercises below contain IAM privilege escalation exercises,
    154 159  never run this on an account which is related to your production environment or can influence your account-over-arching
    skipped 215 lines
    370 375  containers, try the following:
    371 376   
    372 377  ```shell
    373  -docker run -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock jeroenwillemsen/wrongsecrets-desktop:1.5.2
     378 +docker run -p 3000:3000 -v /var/run/docker.sock:/var/run/docker.sock jeroenwillemsen/wrongsecrets-desktop:latest
    374 379  ```
    375 380   
    376 381  or use something more configurable:
    skipped 9 lines
    386 391   -e KEYBOARD=en-us-qwerty \
    387 392   -p 3000:3000 \
    388 393   -v /var/run/docker.sock:/var/run/docker.sock \
    389  - --shm-size="1gb" \
     394 + --shm-size="2gb" \
    390 395   --restart unless-stopped \
    391  - jeroenwillemsen/wrongsecrets-desktop:1.5.2
     396 + jeroenwillemsen/wrongsecrets-desktop:latest
    392 397  ```
    393 398   
    394 399  And then at [http://localhost:3000](http://localhost:3000).
    skipped 13 lines
  • ■ ■ ■ ■
    aws/k8s/secret-challenge-vault-deployment.yml
    skipped 36 lines
    37 37   volumeAttributes:
    38 38   secretProviderClass: "wrongsecrets-aws-secretsmanager"
    39 39   containers:
    40  - - image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
     40 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
    41 41   imagePullPolicy: IfNotPresent
    42 42   ports:
    43 43   - containerPort: 8080
    skipped 31 lines
  • ■ ■ ■ ■
    azure/k8s/secret-challenge-vault-deployment.yml.tpl
    skipped 34 lines
    35 35   volumeAttributes:
    36 36   secretProviderClass: "azure-wrongsecrets-vault"
    37 37   containers:
    38  - - image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
     38 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
    39 39   imagePullPolicy: IfNotPresent
    40 40   ports:
    41 41   - containerPort: 8080
    skipped 36 lines
  • ■ ■ ■ ■ ■ ■
    azure/k8s-vault-azure-start.sh
    skipped 52 lines
    53 53  source ../scripts/install-vault.sh
    54 54   
    55 55  echo "Add secrets manager driver to repo"
    56  -helm repo add csi-secrets-store-provider-azure https://raw.githubusercontent.com/Azure/secrets-store-csi-driver-provider-azure/master/charts
     56 +helm repo add csi-secrets-store-provider-azure https://azure.github.io/secrets-store-csi-driver-provider-azure/charts
    57 57   
    58 58  helm list --namespace kube-system | grep 'csi-secrets-store' &>/dev/null
    59 59  if [ $? == 0 ]; then
    60 60   echo "CSI driver is already installed"
    61 61  else
    62 62   echo "Installing CSI driver"
    63  - helm install -n kube-system csi csi-secrets-store-provider-azure/csi-secrets-store-provider-azure
     63 + helm install csi csi-secrets-store-provider-azure/csi-secrets-store-provider-azure
    64 64  fi
    65 65   
    66 66  echo "Add Azure pod identity to repo"
    skipped 33 lines
  • ■ ■ ■ ■ ■
    fly.toml
    skipped 8 lines
    9 9   dockerfile = "Dockerfile"
    10 10   
    11 11  [build.args]
    12  - argBasedVersion="1.5.2"
     12 + argBasedVersion="1.5.3RC1"
    13 13   spring_profile="without-vault"
    14  - argBasedEnv="Fly(Docker)"
    15 14   
    16 15  [env]
    17 16   K8S_ENV="Fly(Docker)"
    skipped 32 lines
  • ■ ■ ■ ■ ■ ■
    gcp/README.md
    skipped 19 lines
    20 20   
    21 21  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.
    22 22   
    23  -First, create an s3 bucket:
     23 +First, create an storage bucket:
    24 24   
    25 25  1. Navigate to the 'shared-state' directory `cd shared-state`
    26 26  2. Change the `project_id` in the `terraform.tfvars` file to your project id
    skipped 17 lines
    44 44  5. Run `terraform init` (if required, use tfenv to select TF 0.14.0 or higher )
    45 45  6. Run `terraform plan`
    46 46  7. Run `terraform apply`. Note: the apply will take 10 to 20 minutes depending on the speed of the GCP backplane.
    47  -8. When creation is done, run `gcloud container clusters get-credentials wrongsecrets-exercise-cluster --region YOUR_REGION`
     47 +8. 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` .
    48 48  9. Run `./k8s-vault-gcp-start.sh`
    49 49   
    50 50  ### GKE ingres for shared deployment
    skipped 32 lines
  • ■ ■ ■ ■
    gcp/k8s/secret-challenge-vault-deployment.yml.tpl
    skipped 36 lines
    37 37   volumeAttributes:
    38 38   secretProviderClass: "wrongsecrets-gcp-secretsmanager"
    39 39   containers:
    40  - - image: jeroenwillemsen/wrongsecrets:1.5.2-k8s-vault
     40 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
    41 41   imagePullPolicy: IfNotPresent
    42 42   ports:
    43 43   - containerPort: 8080
    skipped 33 lines
  • ■ ■ ■ ■
    gcp/k8s-vault-gcp-start.sh
    skipped 10 lines
    11 11  echo "This script is based on the steps defined in https://learn.hashicorp.com/tutorials/vault/kubernetes-minikube. Vault is awesome!"
    12 12   
    13 13  export GCP_PROJECT=$(gcloud config list --format 'value(core.project)' 2>/dev/null)
    14  -export USE_GKE_GCLOUD_AUTH_PLUGIN=True
     14 +#export USE_GKE_GCLOUD_AUTH_PLUGIN=True
    15 15   
    16 16  kubectl get configmaps | grep 'secrets-file' &>/dev/null
    17 17  if [ $? == 0 ]; then
    skipped 57 lines
  • ■ ■ ■ ■
    k8s/secret-challenge-deployment.yml
    skipped 27 lines
    28 28   runAsGroup: 2000
    29 29   fsGroup: 2000
    30 30   containers:
    31  - - image: jeroenwillemsen/wrongsecrets:jre18test2-no-vault
     31 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
    32 32   imagePullPolicy: IfNotPresent
    33 33   ports:
    34 34   - containerPort: 8080
    skipped 23 lines
  • ■ ■ ■ ■
    k8s/secret-challenge-vault-deployment.yml
    skipped 29 lines
    30 30   runAsNonRoot: true
    31 31   serviceAccountName: vault
    32 32   containers:
    33  - - image: jeroenwillemsen/wrongsecrets:jre18test2-k8s-vault
     33 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-k8s-vault
    34 34   imagePullPolicy: IfNotPresent
    35 35   ports:
    36 36   - containerPort: 8080
    skipped 27 lines
  • ■ ■ ■ ■ ■ ■
    okteto/k8s/secret-challenge-deployment.yml
     1 +apiVersion: apps/v1
     2 +kind: Deployment
     3 +metadata:
     4 + labels:
     5 + app: secret-challenge
     6 + name: secret-challenge
     7 + namespace: commjoen
     8 +spec:
     9 + progressDeadlineSeconds: 600
     10 + replicas: 1
     11 + revisionHistoryLimit: 10
     12 + selector:
     13 + matchLabels:
     14 + app: secret-challenge
     15 + strategy:
     16 + rollingUpdate:
     17 + maxSurge: 25%
     18 + maxUnavailable: 25%
     19 + type: RollingUpdate
     20 + template:
     21 + metadata:
     22 + labels:
     23 + app: secret-challenge
     24 + name: secret-challenge
     25 + spec:
     26 + securityContext:
     27 + runAsUser: 2000
     28 + runAsGroup: 2000
     29 + fsGroup: 2000
     30 + containers:
     31 + - image: jeroenwillemsen/wrongsecrets:1.5.3RC1-no-vault
     32 + imagePullPolicy: IfNotPresent
     33 + ports:
     34 + - containerPort: 8080
     35 + protocol: TCP
     36 + name: secret-challenge
     37 + resources: {}
     38 + terminationMessagePath: /dev/termination-log
     39 + terminationMessagePolicy: File
     40 + env:
     41 + - name: K8S_ENV
     42 + value: Okteto(k8s)
     43 + - name: SPECIAL_K8S_SECRET
     44 + valueFrom:
     45 + configMapKeyRef:
     46 + name: secrets-file
     47 + key: funny.entry
     48 + - name: SPECIAL_SPECIAL_K8S_SECRET
     49 + valueFrom:
     50 + secretKeyRef:
     51 + name: funnystuff
     52 + key: funnier
     53 + dnsPolicy: ClusterFirst
     54 + restartPolicy: Always
     55 + schedulerName: default-scheduler
     56 + terminationGracePeriodSeconds: 30
     57 + 
  • ■ ■ ■ ■ ■ ■
    okteto/k8s/secrets-config.yml
     1 +apiVersion: v1
     2 +data:
     3 + funny.entry: "thisIsK8SConfigMap"
     4 +kind: ConfigMap
     5 +metadata:
     6 + creationTimestamp: "2020-10-29T19:29:38Z"
     7 + name: secrets-file
     8 + namespace: commjoen
     9 + resourceVersion: "4228"
     10 + selfLink: /api/v1/namespaces/default/configmaps/secrets-file
     11 + uid: d777ebfa-2a53-4bca-b1e3-4907eca16552
     12 + 
  • ■ ■ ■ ■ ■ ■
    okteto/k8s/secrets-secret.yml
     1 +apiVersion: v1
     2 +data:
     3 + funnier: dGhpcyBpcyBhcGFzc3dvcmQ=
     4 +kind: Secret
     5 +metadata:
     6 + creationTimestamp: "2020-10-29T20:49:16Z"
     7 + managedFields:
     8 + - apiVersion: v1
     9 + fieldsType: FieldsV1
     10 + fieldsV1:
     11 + f:data:
     12 + .: {}
     13 + f:funnier.entry: {}
     14 + f:type: {}
     15 + manager: kubectl-create
     16 + operation: Update
     17 + time: "2020-10-29T20:49:16Z"
     18 + name: funnystuff
     19 + namespace: commjoen
     20 + resourceVersion: "6559"
     21 + selfLink: /api/v1/namespaces/default/secrets/funnystuff
     22 + uid: baee7f4a-5161-4777-a512-3d236d3573d4
     23 +type: Opaque
     24 + 
  • ■ ■ ■ ■ ■ ■
    okteto/k8s/secrets-service.yml
     1 +apiVersion: v1
     2 +kind: Service
     3 +metadata:
     4 + name: wrongsecrets
     5 +spec:
     6 + type: LoadBalancer
     7 + ports:
     8 + - name: http
     9 + port: 8080
     10 + selector:
     11 + app: secret-challenge
  • ■ ■ ■ ■ ■ ■
    okteto/okteto.yml
     1 +name: okteto
     2 + 
     3 +# The build section defines how to build the images of your development environment
     4 +# More info: https://www.okteto.com/docs/reference/manifest/#build
     5 +# build:
     6 +# my-service:
     7 +# context: .
     8 + 
     9 + 
     10 +# The deploy section defines how to deploy your development environment
     11 +# More info: https://www.okteto.com/docs/reference/manifest/#deploy
     12 +deploy:
     13 + - kubectl apply -f k8s
     14 + 
     15 +dev:
     16 + 
     17 + 
     18 +# The dependencies section defines other git repositories to be deployed as part of your development environment
     19 +# More info: https://www.okteto.com/docs/reference/manifest/#dependencies
     20 +# dependencies:
     21 +# - https://github.com/okteto/sample
     22 +# The dev section defines how to activate a development container
     23 +# More info: https://www.okteto.com/docs/reference/manifest/#dev
     24 +# dev:
     25 +# sample:
     26 +# image: okteto/dev:latest
     27 +# command: bash
     28 +# workdir: /usr/src/app
     29 +# sync:
     30 +# - .:/usr/src/app
     31 +# environment:
     32 +# - name=$USER
     33 +# forward:
     34 +# - 8080:80
     35 + 
     36 + 
  • ■ ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/RuntimeEnvironment.java
    skipped 27 lines
    28 28   private static final Map<Environment, List<Environment>> envToOverlappingEnvs = Map.of(
    29 29   FLY_DOCKER, List.of(DOCKER, FLY_DOCKER),
    30 30   HEROKU_DOCKER, List.of(DOCKER, HEROKU_DOCKER),
    31  - DOCKER, List.of(DOCKER, HEROKU_DOCKER),
     31 + DOCKER, List.of(DOCKER, HEROKU_DOCKER, FLY_DOCKER),
    32 32   GCP, List.of(DOCKER, K8S, VAULT),
    33 33   AWS, List.of(DOCKER, K8S, VAULT),
    34 34   AZURE, List.of(DOCKER, K8S, VAULT),
    35 35   VAULT, List.of(DOCKER, K8S),
    36  - K8S, List.of(DOCKER)
     36 + K8S, List.of(DOCKER),
     37 + OKTETO_K8S, List.of(K8S, DOCKER, OKTETO_K8S)
    37 38   );
    38 39   
    39 40   public enum Environment {
    40  - DOCKER("Docker"), HEROKU_DOCKER("Heroku(Docker)"), FLY_DOCKER("Fly(Docker)"), GCP("gcp"), AWS("aws"), AZURE("azure"), VAULT("k8s-with-vault"), K8S("k8s");
     41 + DOCKER("Docker"), HEROKU_DOCKER("Heroku(Docker)"), FLY_DOCKER("Fly(Docker)"), GCP("gcp"), AWS("aws"), AZURE("azure"), VAULT("k8s-with-vault"), K8S("k8s"), OKTETO_K8S("Okteto(k8s)");
    41 42   
    42 43   private final String id;
    43 44   
    skipped 46 lines
  • ■ ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/Challenge.java
    skipped 22 lines
    23 23   
    24 24   public abstract String getTech();
    25 25   
     26 + public abstract boolean isLimittedWhenOnlineHosted();
     27 + 
    26 28   public boolean solved(String answer) {
    27 29   var correctAnswer = answerCorrect(answer);
    28 30   if (correctAnswer) {
    skipped 18 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/ChallengeUI.java
    skipped 2 lines
    3 3  import lombok.Getter;
    4 4  import org.owasp.wrongsecrets.RuntimeEnvironment;
    5 5   
     6 +import java.util.ArrayList;
    6 7  import java.util.Comparator;
    7 8  import java.util.List;
    8 9  import java.util.regex.Pattern;
    skipped 46 lines
    55 56   }
    56 57   
    57 58   public String getHint() {
     59 + List<RuntimeEnvironment.Environment> limittedEnvs = List.of(RuntimeEnvironment.Environment.HEROKU_DOCKER, RuntimeEnvironment.Environment.FLY_DOCKER, RuntimeEnvironment.Environment.OKTETO_K8S);
     60 + if (limittedEnvs.contains(runtimeEnvironment.getRuntimeEnvironment()) && challenge.isLimittedWhenOnlineHosted()) {
     61 + return challenge.getHint() + "_limitted";
     62 + }
    58 63   return challenge.getHint();
    59 64   }
    60 65   
    skipped 27 lines
  • ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/ChallengesAPIController.java
    skipped 75 lines
    76 76   case DOCKER, HEROKU_DOCKER, FLY_DOCKER -> "Docker";
    77 77   case GCP, AWS, AZURE -> "Cloud";
    78 78   case VAULT -> "Vault";
    79  - case K8S -> "Kubernetes";
     79 + case K8S, OKTETO_K8S -> "Kubernetes";
    80 80   };
    81 81   }
    82 82   
    skipped 45 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/cloud/CloudChallenge.java
    skipped 39 lines
    40 40   return getData(super.getReason());
    41 41   }
    42 42   
     43 + @Override
     44 + public boolean isLimittedWhenOnlineHosted() {
     45 + return false;
     46 + }
     47 + 
    43 48   private String getData(String defaultAWsPath) {
    44 49   RuntimeEnvironment.Environment env = runtimeEnvironment.getRuntimeEnvironment();
    45 50   return switch (env) {
    skipped 7 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge1.java
    skipped 43 lines
    44 44   public String getTech() {
    45 45   return ChallengeTechnology.Tech.GIT.id;
    46 46   }
     47 + 
     48 + @Override
     49 + public boolean isLimittedWhenOnlineHosted() {
     50 + return false;
     51 + }
    47 52  }
    48 53   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge12.java
    skipped 52 lines
    53 53   return ChallengeTechnology.Tech.DOCKER.id;
    54 54   }
    55 55   
     56 + @Override
     57 + public boolean isLimittedWhenOnlineHosted() {
     58 + return false;
     59 + }
     60 + 
    56 61   private String getActualData() {
    57 62   try {
    58 63   return Files.readString(Paths.get(dockerMountPath, "yourkey.txt"));
    skipped 7 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge13.java
    skipped 58 lines
    59 59   return ChallengeTechnology.Tech.CICD.id;
    60 60   }
    61 61   
     62 + @Override
     63 + public boolean isLimittedWhenOnlineHosted() {
     64 + return false;
     65 + }
     66 + 
    62 67   private boolean isKeyCorrect(String base64EncodedKey) {
    63 68   if (Strings.isEmpty(base64EncodedKey) || Strings.isEmpty(plainText) || Strings.isEmpty(cipherText)) {
    64 69   log.info("Checking secret with values {}, {}, {}", base64EncodedKey, plainText, cipherText);
    skipped 26 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge14.java
    skipped 64 lines
    65 65   return ChallengeTechnology.Tech.PASSWORD_MANAGER.id;
    66 66   }
    67 67   
     68 + @Override
     69 + public boolean isLimittedWhenOnlineHosted() {
     70 + return false;
     71 + }
     72 + 
    68 73   private String findAnswer() {
    69 74   if (Strings.isEmpty(keepassxPassword)) {
    70 75   log.info("Checking secret with values {}", keepassxPassword);
    skipped 24 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge15.java
    skipped 59 lines
    60 60   return ChallengeTechnology.Tech.GIT.id;
    61 61   }
    62 62   
     63 + @Override
     64 + public boolean isLimittedWhenOnlineHosted() {
     65 + return false;
     66 + }
     67 + 
    63 68   private String quickDecrypt(String cipherText) {
    64 69   try {
    65 70   final byte[] keyData = Base64.getDecoder().decode(encryptionKey);
    skipped 29 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge16.java
    skipped 52 lines
    53 53   return ChallengeTechnology.Tech.FRONTEND.id;
    54 54   }
    55 55   
     56 + @Override
     57 + public boolean isLimittedWhenOnlineHosted() {
     58 + return false;
     59 + }
     60 + 
    56 61   public String getActualData() {
    57 62   try {
    58 63   return Files.readString(Paths.get(dockerMountPath, "secondkey.txt"));
    skipped 7 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge17.java
    skipped 52 lines
    53 53   return ChallengeTechnology.Tech.DOCKER.id;
    54 54   }
    55 55   
     56 + @Override
     57 + public boolean isLimittedWhenOnlineHosted() {
     58 + return false;
     59 + }
     60 + 
    56 61   public String getActualData() {
    57 62   try {
    58 63   return Files.readString(Paths.get(dockerMountPath, "thirdkey.txt"));
    skipped 7 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge18.java
    skipped 75 lines
    76 76   public String getTech() {
    77 77   return ChallengeTechnology.Tech.CRYPTOGRAPHY.id;
    78 78   }
     79 + 
     80 + @Override
     81 + public boolean isLimittedWhenOnlineHosted() {
     82 + return false;
     83 + }
    79 84  }
    80 85   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge19.java
    skipped 49 lines
    50 50   public String getTech() {
    51 51   return ChallengeTechnology.Tech.BINARY.id;
    52 52   }
     53 + 
     54 + @Override
     55 + public boolean isLimittedWhenOnlineHosted() {
     56 + return false;
     57 + }
    53 58  }
    54 59   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge2.java
    skipped 47 lines
    48 48   public String getTech() {
    49 49   return ChallengeTechnology.Tech.GIT.id;
    50 50   }
     51 + 
     52 + @Override
     53 + public boolean isLimittedWhenOnlineHosted() {
     54 + return false;
     55 + }
    51 56  }
    52 57   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge20.java
    skipped 49 lines
    50 50   public String getTech() {
    51 51   return ChallengeTechnology.Tech.BINARY.id;
    52 52   }
     53 + 
     54 + @Override
     55 + public boolean isLimittedWhenOnlineHosted() {
     56 + return false;
     57 + }
    53 58  }
    54 59   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge21.java
    skipped 49 lines
    50 50   public String getTech() {
    51 51   return ChallengeTechnology.Tech.BINARY.id;
    52 52   }
     53 + 
     54 + @Override
     55 + public boolean isLimittedWhenOnlineHosted() {
     56 + return false;
     57 + }
    53 58  }
    54 59   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge22.java
    skipped 48 lines
    49 49   public String getTech() {
    50 50   return ChallengeTechnology.Tech.BINARY.id;
    51 51   }
     52 + 
     53 + @Override
     54 + public boolean isLimittedWhenOnlineHosted() {
     55 + return false;
     56 + }
    52 57  }
    53 58   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge23.java
    skipped 48 lines
    49 49   return ChallengeTechnology.Tech.FRONTEND.id;
    50 50   }
    51 51   
     52 + @Override
     53 + public boolean isLimittedWhenOnlineHosted() {
     54 + return false;
     55 + }
     56 + 
    52 57   public String getActualData() {
    53 58   return new String(Base64.decode(Hex.decode(Base64.decode("NTYzMjY4MzU1MTMyMzk3NDYyNTc1Njc1NjQ0ODRlNDI2MzMxNDI2ODYzMzM0ZTdhNjQzMjM5Nzk1YTQ1NDY3OTVhNTU0YTY4NWE0NDRkMzA0ZTU2Mzg2Yg=="))));
    54 59   
    skipped 3 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge24.java
    skipped 46 lines
    47 47   return ChallengeTechnology.Tech.CRYPTOGRAPHY.id;
    48 48   }
    49 49   
     50 + @Override
     51 + public boolean isLimittedWhenOnlineHosted() {
     52 + return false;
     53 + }
     54 + 
    50 55   public String getActualData() {
    51 56   return "00010203 04050607 08090A0B 0C0D0E0F 10111213 14151617 18191A1B 1C1D1E1F 20212223 24252627 28292A2B 2C2D2E2F 30313233 34353637 38393A3B 3C3D3E3F";
    52 57   
    skipped 3 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge3.java
    skipped 47 lines
    48 48   public String getTech() {
    49 49   return ChallengeTechnology.Tech.DOCKER.id;
    50 50   }
     51 + 
     52 + @Override
     53 + public boolean isLimittedWhenOnlineHosted() {
     54 + return false;
     55 + }
    51 56  }
    52 57   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge4.java
    skipped 49 lines
    50 50   return ChallengeTechnology.Tech.DOCKER.id;
    51 51   }
    52 52   
     53 + @Override
     54 + public boolean isLimittedWhenOnlineHosted() {
     55 + return false;
     56 + }
     57 + 
    53 58  }
    54 59   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/docker/Challenge8.java
    skipped 55 lines
    56 56   return ChallengeTechnology.Tech.LOGGING.id;
    57 57   }
    58 58   
     59 + @Override
     60 + public boolean isLimittedWhenOnlineHosted() {
     61 + return true;
     62 + }
     63 + 
    59 64   private String generateRandomString(int length) {
    60 65   StringBuilder builder = new StringBuilder(length);
    61 66   for (int i = 0; i < length; i++) {
    skipped 6 lines
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/kubernetes/Challenge5.java
    skipped 46 lines
    47 47   public String getTech() {
    48 48   return "Configmaps";
    49 49   }
     50 + 
     51 + @Override
     52 + public boolean isLimittedWhenOnlineHosted() {
     53 + return true;
     54 + }
    50 55  }
    51 56   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/kubernetes/Challenge6.java
    skipped 46 lines
    47 47   public String getTech() {
    48 48   return "Secrets";
    49 49   }
     50 + 
     51 + @Override
     52 + public boolean isLimittedWhenOnlineHosted() {
     53 + return true;
     54 + }
    50 55  }
    51 56   
  • ■ ■ ■ ■ ■
    src/main/java/org/owasp/wrongsecrets/challenges/kubernetes/Challenge7.java
    skipped 51 lines
    52 52   public String getTech() {
    53 53   return "Vault";
    54 54   }
     55 + 
     56 + @Override
     57 + public boolean isLimittedWhenOnlineHosted() {
     58 + return false;
     59 + }
    55 60  }
    56 61   
  • ■ ■ ■ ■ ■ ■
    src/main/resources/explanations/challenge5_hint_limitted.adoc
     1 +You can solve this challenge by the following steps:
     2 + 
     3 +1. Check the status of the configmap in Git
     4 +- Can you see where in git we stored the `secrets-config.yml`? If not, just do a search.
     5 +- Take a look at the `Data` field: what can you find there?
     6 + 
     7 +PLEASE NOTE: The following options will only work when you have access to the K8s API. In this hosted version of WrongSecrets you do not have that access. When you are running a CTF: ask the organizer for access to the K8s API.
     8 + 
     9 + 
     10 +2. Ask nicely using Kubectl:
     11 +- Make sure you have Kubectl installed as defined in the README.MD & make sure kubectl is configured to send commands to the right cluster.
     12 +- Do `kubectl get configmap`. Here you see all the configmaps active in the namespace you are in, which is for this app normally `default` (unless otherwise specified by your administrator/trainer).
     13 +- Now do `kubectl get configmap secrets-file -o Yaml`. Can you see the secret?
     14 +3. Exec into the pod and get the data:
     15 +- Make sure you have Kubectl installed as defined in the README.MD & make sure kubectl is configured to send commands to the right cluster.
     16 +- Do `kubectl get pods`. Here you see all the Pods active in the namespace you are in, which is for this app normally `default` (unless otherwise specified by your administrator/trainer).
     17 +- Now for your instance of the WrongSecrets pod, do `kubectl exec -it secret-challenge-<rest of the name of the pod from the prev.step> -- /bin/sh`.
     18 +- Now do `env | grep SPECIAL_K8S_SECRET` and there is your secret.
     19 + 
     20 + 
     21 +Note: `kubectl get <item> -A` gives you an overview of all the items over all the namespaces you have access to. It's important *not* to give people access to every namespace in your cluster, as this might mean leaking important config/items to them.
     22 + 
  • ■ ■ ■ ■ ■ ■
    src/main/resources/explanations/challenge6_hint_limitted.adoc
     1 +You can solve this challenge by the following steps:
     2 + 
     3 +1. Check the status of the secret in Git:
     4 +- Can you see where in git we stored the `secrets-secret.yml`? If not, just do a search.
     5 +- Take a look at the `Data` field: what can you find there?
     6 + 
     7 +PLEASE NOTE: The following options will only work when you have access to the K8s API. In this hosted version of WrongSecrets you do not have that access. When you are running a CTF: ask the organizer access to the targetted K8s API.
     8 + 
     9 +2. Ask nicely using Kubectl:
     10 +- Make sure you have Kubectl installed as defined in the README.MD & make sure kubectl is configured to send commands to the right cluster.
     11 +- Now do `kubectl get secrets` . Here you see all the configmaps active in the namespace you are in, which is for this app normally `default` (unless otherwise specified by your administrator/trainer).
     12 +- Now do `kubectl get secret funnystuff -o Yaml` . Can you see the secret?
     13 +3. Exec into the pod and get the data:
     14 +- Make sure you have Kubectl installed as defined in the README.MD & make sure kubectl is configured to send commands to the right cluster.
     15 +- Now do `kubectl get pods`. Here you see all the Pods active in the namespace you are in, which is for this app normally `default` (unless otherwise specified by your administrator/trainer).
     16 +- Now for your instance of the WrongSecrets pod, do `kubectl exec -it secret-challenge-<rest of the name of the pod from the prev.step> -- /bin/sh`.
     17 +- Now do `env | grep SPECIAL_SPECIAL_K8S_SECRET` and there is your secret.
     18 + 
     19 + 
     20 +Note: `kubectl get <item> -A` gives you an overview of all the items over all the namespaces you have access to. It's important *not* to give people access to every namespace in your cluster, as this might mean leaking important config/items to them.
     21 + 
  • ■ ■ ■ ■ ■ ■
    src/main/resources/explanations/challenge8_hint_limitted.adoc
     1 +You can solve this challenge by the following steps:
     2 + 
     3 +1. Get the secret from the logging
     4 + - Are you using the docker container? Use `docker logs <containerID>` to get the logs and find the value for challenge8
     5 + - Are you using K8s? Find the Pod (`kubectl get pods | grep secret`) and then do `kubectl logs -f <nameOfThePod>` to get the logs and find the value for challenge 8.
     6 + 
     7 +PLEASE NOTE: you are running this challenge on a hosted version of WrongSecrets. If you are not hosting it yourself, you might not have accesss to the defined outputs above. When you are running a CTF: ask the organizer access to the logging.
     8 + 
  • ■ ■ ■ ■ ■ ■
    src/test/java/org/owasp/wrongsecrets/challengeUILimittedTest.java
     1 +package org.owasp.wrongsecrets;
     2 + 
     3 +import org.junit.jupiter.api.Test;
     4 +import org.junit.jupiter.api.extension.ExtendWith;
     5 +import org.springframework.beans.factory.annotation.Autowired;
     6 +import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
     7 +import org.springframework.boot.test.context.SpringBootTest;
     8 +import org.springframework.test.context.junit.jupiter.SpringExtension;
     9 +import org.springframework.test.web.servlet.MockMvc;
     10 + 
     11 +import static org.hamcrest.Matchers.containsString;
     12 +import static org.springframework.security.test.web.servlet.request.SecurityMockMvcRequestPostProcessors.csrf;
     13 +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
     14 +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
     15 +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
     16 + 
     17 +@ExtendWith(SpringExtension.class)
     18 +@SpringBootTest(
     19 + properties = {"K8S_ENV=Heroku(Docker)"},
     20 + classes = WrongSecretsApplication.class
     21 +)
     22 +@AutoConfigureMockMvc
     23 +public class challengeUILimittedTest {
     24 + @Autowired
     25 + private MockMvc mvc;
     26 + 
     27 + @Test
     28 + void shouldProvideExplanationWithLimmitForChallenge8GivenChallengeIsLimittedWhenHosted() throws Exception {
     29 + mvc.perform(get("/challenge/8").with(csrf()))
     30 + .andExpect(status().isOk())
     31 + .andExpect(content().string(containsString("PLEASE NOTE: you are running this challenge on a hosted version of WrongSecrets")));
     32 + }
     33 +}
     34 + 
Please wait...
Page is in error, reload to recover