-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
497 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
FROM node:9 as installer | ||
FROM node:10 as installer | ||
COPY . /juice-shop-ctf | ||
WORKDIR /juice-shop-ctf | ||
RUN chown -R node . | ||
USER node | ||
ARG DEV_BUILD=false | ||
RUN if [ ${DEV_BUILD} = true ]; then npm i && npm test && npm run e2e; else npm install --production --unsafe-perm; fi | ||
RUN if [ ${DEV_BUILD} = true ]; then npm i && npm lint && npm test && npm run e2e; else npm install --production --unsafe-perm; fi | ||
|
||
FROM node:9-alpine | ||
ARG BUILD_DATE | ||
|
@@ -16,7 +16,7 @@ LABEL maintainer="Bjoern Kimminich <[email protected]>" \ | |
org.opencontainers.image.vendor="Open Web Application Security Project" \ | ||
org.opencontainers.image.documentation="http://help.owasp-juice.shop/part1/ctf.html" \ | ||
org.opencontainers.image.licenses="MIT" \ | ||
org.opencontainers.image.version="5.0.1" \ | ||
org.opencontainers.image.version="6.0.0" \ | ||
org.opencontainers.image.url="http://owasp-juice.shop" \ | ||
org.opencontainers.image.source="https://github.com/bkimminich/juice-shop-ctf.git" \ | ||
org.opencontainers.image.revision=$VCS_REF \ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const Promise = require('bluebird') | ||
const calculateScore = require('../calculateScore') | ||
const calculateHintCost = require('../calculateHintCost') | ||
const hmacSha1 = require('../hmac') | ||
const options = require('../options') | ||
|
||
function createCtfd2Export (challenges, { insertHints, insertHintUrls, ctfKey }) { | ||
function insertChallenge (data, challenge) { | ||
const score = calculateScore(challenge.difficulty) | ||
data.challenges['results'].push( | ||
{ | ||
'id': challenge.id, | ||
'name': challenge.name, | ||
'description': challenge.description.replace(/"/g, '""') + ' (Difficulty Level: ' + challenge.difficulty + ')', | ||
'max_attempts': 0, | ||
'value': score, | ||
'category': challenge.category, | ||
'type': 'standard', | ||
'state': 'visible' | ||
} | ||
) | ||
} | ||
|
||
function insertKey ({ flagKeys }, { id, name }) { | ||
flagKeys['results'].push( | ||
{ | ||
'id': id, | ||
'challenge_id': id, | ||
'type': 'static', | ||
'content': hmacSha1(ctfKey, name), | ||
'data': null | ||
} | ||
) | ||
} | ||
|
||
function insertTextHint ({ hints }, challenge) { | ||
hints['results'].push( | ||
{ | ||
'id': challenge.id, | ||
'type': 'standard', | ||
'challenge_id': challenge.id, | ||
'content': challenge.hint, | ||
'cost': calculateHintCost(challenge, insertHints) | ||
} | ||
) | ||
} | ||
|
||
function insertHintUrl ({ hints }, challenge) { | ||
hints['results'].push( | ||
{ | ||
'id': 10000 + challenge.id, | ||
'type': 'standard', | ||
'challenge_id': challenge.id, | ||
'content': challenge.hintUrl, | ||
'cost': calculateHintCost(challenge, insertHintUrls) | ||
} | ||
) | ||
} | ||
|
||
return new Promise((resolve, reject) => { | ||
try { | ||
const data = { | ||
challenges: { 'results': [] }, | ||
hints: { 'results': [] }, | ||
flagKeys: { 'results': [] } | ||
} | ||
for (const key in challenges) { | ||
if (challenges.hasOwnProperty(key)) { | ||
const challenge = challenges[key] | ||
insertChallenge(data, challenge) | ||
insertKey(data, challenge) | ||
if (challenge.hint && insertHints !== options.noTextHints) { | ||
insertTextHint(data, challenge) | ||
} | ||
if (challenge.hintUrl && insertHintUrls !== options.noHintUrls) { | ||
insertHintUrl(data, challenge) | ||
} | ||
} | ||
} | ||
resolve(data) | ||
} catch (error) { | ||
reject(new Error('Failed to generate challenge data! ' + error.message)) | ||
} | ||
}) | ||
} | ||
|
||
module.exports = createCtfd2Export |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const Promise = require('bluebird') | ||
const fs = require('fs') | ||
Promise.promisifyAll(fs) | ||
const path = require('path') | ||
const dateFormat = require('dateformat') | ||
const Zip = require('node-zip') | ||
const zip = new Zip() | ||
|
||
function writeToCtfd3Zip ({ challenges, hints, flagKeys }, desiredFileName) { | ||
return new Promise((resolve, reject) => { | ||
const fileName = desiredFileName || 'OWASP_Juice_Shop.' + dateFormat(new Date(), 'yyyy-mm-dd') + '.CTFd2.zip' | ||
zip.file('db/alembic_version.json', '{"count": 1, "results": [{"version_num": "8369118943a1"}], "meta": {}}') | ||
zip.file('db/challenges.json', JSON.stringify(challenges)) | ||
zip.file('db/hints.json', JSON.stringify(hints)) | ||
zip.file('db/flags.json', JSON.stringify(flagKeys)) | ||
fs.writeFileAsync(fileName, zip.generate({ base64: false, compression: 'DEFLATE' }), 'binary').then(() => { | ||
resolve(path.resolve(fileName).green) | ||
}).catch(({ message }) => { | ||
reject(new Error('Failed to write output to file! ' + message)) | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = writeToCtfd3Zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "juice-shop-ctf-cli", | ||
"version": "5.0.2", | ||
"version": "6.0.0", | ||
"description": "Capture-the-Flag (CTF) environment setup tools for OWASP Juice Shop", | ||
"author": "Bjoern Kimminich <[email protected]> (https://www.owasp.org/index.php/User:Bjoern_Kimminich)", | ||
"contributors": [ | ||
|
@@ -21,6 +21,7 @@ | |
"capture the flag", | ||
"ctf", | ||
"ctfd", | ||
"fbctf", | ||
"cli" | ||
], | ||
"preferGlobal": true, | ||
|
@@ -53,7 +54,7 @@ | |
"yargs": "~12.0.5", | ||
"dateformat": "~3.0.3", | ||
"inquirer": "~6.2.0", | ||
"joi": "~14.2.0", | ||
"joi": "~14.3.1", | ||
"jssha": "~2.3.1", | ||
"js-yaml": "~3.12.0", | ||
"node-zip": "~1.1.1", | ||
|
@@ -62,7 +63,7 @@ | |
"request-promise": "~4.2.2" | ||
}, | ||
"devDependencies": { | ||
"ava": "~1.0.1", | ||
"ava": "~1.1.0", | ||
"chai": "~4.2.0", | ||
"chai-as-promised": "~7.1.1", | ||
"chai-spies": "~1.0.0", | ||
|
Oops, something went wrong.