Skip to content

Commit 8f8249e

Browse files
committed
Upgrade to wrongsecrets 1.6.3
1 parent 8d64048 commit 8f8249e

File tree

7 files changed

+47
-20
lines changed

7 files changed

+47
-20
lines changed

build-an-deploy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ source ./scripts/check-available-commands.sh
1010
checkCommandsAvailable helm docker kubectl yq
1111

1212
version="$(uuidgen)"
13+
eval $(minikube docker-env)
1314
docker login
1415
WRONGSECRETS_IMAGE=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.wrongsecrets.image')
1516
WRONGSECRETS_TAG=$(cat helm/wrongsecrets-ctf-party/values.yaml| yq '.wrongsecrets.tag')
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
3+
source ./scripts/check-available-commands.sh
4+
checkCommandsAvailable helm docker kubectl yq minikube
5+
6+
minikube delete
7+
minikube start --cpus=6 --memory=8000MB --network-plugin=cni --cni=calico --driver=docker --kubernetes-version=1.25.6
8+
eval $(minikube docker-env)
9+
./build-an-deploy-container.sh
10+
11+
sleep 5
12+
13+
echo "let's go!"
14+
15+
kubectl port-forward service/wrongsecrets-balancer 3000:3000

build-and-deploy-minikube.sh

100644100755
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@ source ./scripts/check-available-commands.sh
44
checkCommandsAvailable helm docker kubectl yq minikube
55

66
minikube delete
7-
minikube start --cpus=6 --memory=8000MB --network-plugin=cni --cni=calico --driver=docker
7+
minikube start --cpus=6 --memory=8000MB --network-plugin=cni --cni=calico --driver=docker --kubernetes-version=1.25.6
88
eval $(minikube docker-env)
99
./build-an-deploy.sh
1010

11-
sleep 5
11+
sleep 15
1212

1313
echo "let's go!"
1414

15-
$(kubectl port-forward service/wrongsecrets-balancer 3000:3000)
16-
17-
$(kubectl logs -f -l app=wrongsecrets-balancer)
15+
kubectl port-forward service/wrongsecrets-balancer 3000:3000

helm/wrongsecrets-ctf-party/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ wrongsecrets:
108108
maxInstances: 500
109109
# -- Wrongsecrets Image to use
110110
image: jeroenwillemsen/wrongsecrets
111-
tag: 1.6.0-no-vault
111+
tag: 1.6.3-no-vault
112112
# -- Change the key when hosting a CTF event. This key gets used to generate the challenge flags. See: https://github.com/OWASP/wrongsecrets#ctf
113113
ctfKey: "[email protected]!9uR_K!NfkkTr"
114114
# -- Specify a custom Juice Shop config.yaml. See the JuiceShop Config Docs for more detail: https://pwning.owasp-juice.shop/part1/customization.html#yaml-configuration-file
@@ -200,7 +200,7 @@ virtualdesktop:
200200
maxInstances: 500
201201
# -- Juice Shop Image to use
202202
image: jeroenwillemsen/wrongsecrets-desktop-k8s
203-
tag: 1.6.0
203+
tag: 1.6.3
204204
repository: commjoenie/wrongSecrets
205205
resources:
206206
request:

readme.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,15 @@ For minikube, run:
110110

111111
```shell
112112

113-
minikube start --cpus=6 --memory=10000MB --network-plugin=cni --cni=calico --driver=docker
113+
minikube start --cpus=6 --memory=10000MB --network-plugin=cni --cni=calico --driver=docker --kubernetes-version=1.25.6
114114
eval $(minikube docker-env)
115115
./build-an-deploy-container.sh
116116
kubectl port-forward service/wrongsecrets-balancer 3000:3000
117117

118118
```
119119

120+
or use `build-and-deploy-container-minikube.sh` to do all of the above in one script.
121+
120122
Want to know whether your system is holding up? use
121123

122124
```shell
@@ -127,14 +129,17 @@ kubectl top pods
127129

128130
### Develop with Minikube
129131

132+
Please note that we are experiencing some issues with kubernetes.js and teams.js, these are being resolved.
133+
130134
```shell
131135

132-
minikube start --cpus=6 --memory=10000MB --network-plugin=cni --cni=calico --driver=docker
136+
minikube start --cpus=6 --memory=10000MB --network-plugin=cni --cni=calico --driver=docker --kubernetes-version=1.25.6
133137
eval $(minikube docker-env)
134138
./build-an-deploy.sh
135139
kubectl port-forward service/wrongsecrets-balancer 3000:3000
136140

137141
```
142+
or use `build-and-deploy-minikube.sh` to do all of the above in one script.
138143

139144

140145
### Play with AWS EKS:

wrongsecrets-balancer/src/kubernetes.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,14 +1303,18 @@ const getJuiceShopInstanceForTeamname = (teamname) => {
13031303
k8sAppsApi
13041304
.readNamespacedDeployment(`t-${teamname}-wrongsecrets`, `t-${teamname}`)
13051305
.then((res) => {
1306-
return {
1307-
readyReplicas: res.body.status.readyReplicas,
1308-
availableReplicas: res.body.status.availableReplicas,
1309-
passcodeHash: res.body.metadata.annotations['wrongsecrets-ctf-party/passcode'],
1310-
};
1306+
logger.info(JSON.stringify(res));
1307+
if(res.body.hasOwnProperty('metadata') && res.body.metadata.hasOwnProperty('annotations') ){
1308+
return {
1309+
readyReplicas: res.body.status.readyReplicas,
1310+
availableReplicas: res.body.status.availableReplicas,
1311+
passcodeHash: res.body.metadata.annotations['wrongsecrets-ctf-party/passcode'],
1312+
};
1313+
}
1314+
return;
13111315
})
13121316
.catch((error) => {
1313-
if (error.response.body.message.contains('No such container')) {
1317+
if (error.response.body.message.includes('No such container')) {
13141318
return;
13151319
}
13161320
throw new Error(error.response.body.message);

wrongsecrets-balancer/src/teams/teams.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ async function interceptAdminLogin(req, res, next) {
9292
* @param {import("express").NextFunction} next
9393
*/
9494
async function validateHMAC(req, res, next) {
95+
logger.info('validating hmac');
9596
try {
9697
const { team } = req.params;
9798
const { hmacvalue } = req.body;
@@ -147,12 +148,12 @@ async function joinIfTeamAlreadyExists(req, res, next) {
147148
const { team } = req.params;
148149
const { passcode } = req.body;
149150

150-
logger.debug(`Checking if team ${team} already has a WrongSecrets Deployment`);
151+
logger.info(`Checking if team ${team} already has a WrongSecrets Deployment`);
151152

152153
try {
153154
const { passcodeHash } = await getJuiceShopInstanceForTeamname(team);
154155

155-
logger.debug(`Team ${team} already has a WrongSecrets deployment`);
156+
logger.info(`Team ${team} already has a WrongSecrets deployment`);
156157

157158
if (passcode !== undefined && (await bcrypt.compare(passcode, passcodeHash))) {
158159
// Set cookie, (join team)
@@ -173,7 +174,7 @@ async function joinIfTeamAlreadyExists(req, res, next) {
173174
message: 'Team requires authentication to join',
174175
});
175176
} catch (error) {
176-
if (error.message === `deployments.apps "t-${team}-wrongsecrets" not found`) {
177+
if (error.message.includes(`deployments.apps "t-${team}-wrongsecrets" not found`) || error.message==="Cannot destructure property 'passcodeHash' of '(intermediate value)' as it is undefined.") {
177178
logger.info(`Team ${team} doesn't have a WrongSecrets deployment yet`);
178179
return next();
179180
} else {
@@ -193,11 +194,12 @@ async function joinIfTeamAlreadyExists(req, res, next) {
193194
* @param {import("express").NextFunction} next
194195
*/
195196
async function checkIfMaxJuiceShopInstancesIsReached(req, res, next) {
197+
logger.info("checking for max instances");
196198
const maxInstances = get('maxJuiceShopInstances');
197199

198200
// If max instances is set to negative numbers it's not capped
199201
if (maxInstances < 0) {
200-
logger.debug(`Skipping max instance check, max instances is set to '${maxInstances}'`);
202+
logger.info(`Skipping max instance check, max instances is set to '${maxInstances}'`);
201203
return next();
202204
}
203205

@@ -233,6 +235,8 @@ async function generatePasscode() {
233235
* @param {import("express").Response} res
234236
*/
235237
async function createTeam(req, res) {
238+
const { team } = req.params;
239+
logger.info(`creating new team for team '${team}'`)
236240
if (k8sEnv === 'aws') {
237241
logger.info(
238242
'We will create an AWS deployment see the helm chart/deployment for setting this to k8s'
@@ -242,7 +246,7 @@ async function createTeam(req, res) {
242246
logger.info(
243247
'We will create a K8s deployment see the helm chart/deployment for setting this to aws'
244248
);
245-
const { team } = req.params;
249+
246250
const { passcode, hash } = await generatePasscode();
247251
try {
248252
logger.info(`Creating Namespace for team '${team}'`);

0 commit comments

Comments
 (0)