forked from juice-shop/juice-shop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatacreator.js
405 lines (398 loc) · 14.9 KB
/
datacreator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
/*jslint node: true */
'use strict';
var models = require('../models/index'),
datacache = require('./datacache'),
challenges = datacache.challenges,
users = datacache.users,
products = datacache.products;
module.exports = function() {
createChallenges();
createUsers();
createProducts();
createBaskets();
createFeedback();
function createChallenges() {
models.Challenge.create({
name: 'scoreBoard',
description: 'Find the carefully hidden \'Score Board\' page.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.scoreBoardChallenge = challenge;
});
models.Challenge.create({
name: 'errorHandling',
description: 'Provoke an error that is not very gracefully handled.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.errorHandlingChallenge = challenge;
});
models.Challenge.create({
name: 'loginAdmin',
description: 'Log in with the administrator\'s user account.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.loginAdminChallenge = challenge;
});
models.Challenge.create({
name: 'loginJim',
description: 'Log in with Jim\'s user account.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.loginJimChallenge = challenge;
});
models.Challenge.create({
name: 'loginBender',
description: 'Log in with Bender\'s user account.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.loginBenderChallenge = challenge;
});
models.Challenge.create({
name: 'xss1',
description: 'XSS Tier 1: Perform a <i>reflected</i> XSS attack with <script>alert("XSS1")</script>.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.localXssChallenge = challenge;
});
models.Challenge.create({
name: 'xss2',
description: 'XSS Tier 2: Perform a <i>persisted</i> XSS attack with <script>alert("XSS2")</script> bypassing a <i>client-side</i> security mechanism.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.persistedXssChallengeUser = challenge;
});
models.Challenge.create({
name: 'xss3',
description: 'XSS Tier 3: Perform a <i>persisted</i> XSS attack with <script>alert("XSS3")</script> bypassing a <i>server-side</i> security mechanism.',
difficulty: 3,
solved: false
}).success(function (challenge) {
challenges.persistedXssChallengeFeedback = challenge;
});
models.Challenge.create({
name: 'xss4',
description: 'XSS Tier 4: Perform a <i>persisted</i> XSS attack with <script>alert("XSS4")</script> without using the frontend application at all.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.restfulXssChallenge = challenge;
});
models.Challenge.create({
name: 'unionSqlI',
description: 'Retrieve a list of all user credentials via SQL Injection',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.unionSqlInjectionChallenge = challenge;
});
models.Challenge.create({
name: 'adminCredentials',
description: 'Log in with the administrator\'s user credentials without previously changing them or applying SQL Injection.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.weakPasswordChallenge = challenge;
});
models.Challenge.create({
name: 'fiveStarFeedback',
description: 'Get rid of all 5-star customer feedback.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.feedbackChallenge = challenge;
});
models.Challenge.create({
name: 'forgedFeedback',
description: 'Post some feedback in another users name.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.forgedFeedbackChallenge = challenge;
});
models.Challenge.create({
name: 'redirect',
description: 'Wherever you go, there you are.',
difficulty: 3,
solved: false
}).success(function (challenge) {
challenges.redirectChallenge = challenge;
});
models.Challenge.create({
name: 'accessBasket',
description: 'Access someone else\'s basket.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.basketChallenge = challenge;
});
models.Challenge.create({
name: 'negativeOrder',
description: 'Place an order that makes you rich.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.negativeOrderChallenge = challenge;
});
models.Challenge.create({
name: 'confidentialDocument',
description: 'Access a confidential document.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.directoryListingChallenge = challenge;
});
models.Challenge.create({
name: 'forgottenBackup',
description: 'Access a forgotten backup file.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.forgottenBackupChallenge = challenge;
});
models.Challenge.create({
name: 'adminSection',
description: 'Access the administration section of the store.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.adminSectionChallenge = challenge;
});
models.Challenge.create({
name: 'csrf',
description: 'Change Bender\'s password into <i>slurmCl4ssic</i>.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.csrfChallenge = challenge;
});
models.Challenge.create({
name: 'changeProduct',
description: 'Change the link in the description of the <a href="/#/search?q=O-Saft">O-Saft product</a> to <i>http://kimminich.de</i>.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.changeProductChallenge = challenge;
});
models.Challenge.create({
name: 'vulnerableComponent',
description: '<a href="/#/contact">Inform the shop</a> about a vulnerable library it is using. (Mention the exact library name and version in your complaint.)',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.knownVulnerableComponentChallenge = challenge;
});
models.Challenge.create({
name: 'weirdCrypto',
description: '<a href="/#/contact">Inform the shop</a> about an algorithm or library it should definitely not use the way it does.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.weirdCryptoChallenge = challenge;
});
models.Challenge.create({
name: 'easterEgg1',
description: 'Find the hidden <a href="http://en.wikipedia.org/wiki/Easter_egg_(media)" target="_blank">easter egg</a>.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.easterEggLevelOneChallenge = challenge;
});
models.Challenge.create({
name: 'easterEgg2',
description: 'Apply some advanced cryptanalysis to find <i>the real</i> easter egg.',
difficulty: 3,
solved: false
}).success(function (challenge) {
challenges.easterEggLevelTwoChallenge = challenge;
});
models.Challenge.create({
name: 'forgedCoupon',
description: 'Forge a coupon code that gives you a discount of at least 80%.',
difficulty: 3,
solved: false
}).success(function (challenge) {
challenges.forgedCouponChallenge = challenge;
});
models.Challenge.create({
name: 'geocitiesTheme',
description: 'Travel back in time to the golden era of web design.',
difficulty: 2,
solved: false
}).success(function (challenge) {
challenges.geocitiesThemeChallenge = challenge;
});
models.Challenge.create({
name: 'christmasSpecial',
description: 'Order the Christmas special offer of 2014.',
difficulty: 1,
solved: false
}).success(function (challenge) {
challenges.christmasSpecialChallenge = challenge;
});
}
function createUsers() {
models.User.create({
email: '[email protected]',
password: 'admin123'
});
models.User.create({
email: '[email protected]',
password: 'ncc-1701'
});
models.User.create({
email: '[email protected]',
password: 'booze'
}).success(function (user) {
users.bender = user;
});
}
function createProducts() {
models.Product.create({
name: 'Apple Juice (1000ml)',
description: 'The all-time classic.',
price: 1.99,
image: 'apple_juice.jpg'
});
models.Product.create({
name: 'Orange Juice (1000ml)',
description: 'Made from oranges hand-picked by Uncle Dittmeyer.',
price: 2.99,
image: 'orange_juice.jpg'
});
models.Product.create({
name: 'Eggfruit Juice (500ml)',
description: 'Now with even more exotic flavour.',
price: 8.99,
image: 'eggfruit_juice.jpg'
});
models.Product.create({
name: 'Raspberry Juice (1000ml)',
description: 'Made from blended Raspberry Pi, water and sugar.',
price: 4.99,
image: 'raspberry_juice.jpg'
});
models.Product.create({
name: 'Lemon Juice (500ml)',
description: 'Sour but full of vitamins.',
price: 2.99,
image: 'lemon_juice.jpg'
});
models.Product.create({
name: 'Banana Juice (1000ml)',
description: 'Monkeys love it the most.',
price: 1.99,
image: 'banana_juice.jpg'
});
models.Product.create({
name: 'Lemon Juice (500ml)',
description: 'Sour but full of vitamins.',
price: 2.99,
image: 'lemon_juice.jpg'
});
models.Product.create({
name: 'OWASP Juice Shop T-Shirt (3XL)',
description: 'Real fans wear it 24/7!',
price: 24.99,
image: 'fan_shirt.jpg'
});
models.Product.create({
name: 'OWASP SSL Advanced Forensic Tool (O-Saft)',
description: 'O-Saft is an easy to use tool to show information about SSL certificate and tests the SSL connection according given list of ciphers and various SSL configurations. <a href="https://www.owasp.org/index.php/O-Saft" target="_blank">More...</a>',
price: 0.01,
image: 'owasp_osaft.jpg'
}).success(function (product) {
products.osaft = product;
});
models.Product.create({
name: 'Christmas Super-Surprise-Box (2014 Edition)',
description: 'Contains a random selection of 10 bottles (each 500ml) of our tastiest juices and an extra fan shirt (3XL) for an unbeatable price! Only available on Christmas 2014!',
price: 29.99,
image: 'undefined.jpg'
}).success(function (product) {
products.christmasSpecial = product;
models.sequelize.query('UPDATE Products SET deletedAt = \'2014-12-27 00:00:00.000 +00:00\' WHERE id = ' + product.id);
});
models.Product.create({
name: 'OWASP Juice Shop Sticker',
description: 'You want to put <a href="https://www.stickermule.com/de/marketplace/9680-juice-shop-logo" target="_blank">this</a> on your laptop. You definitely want that. Trust me.',
price: 2.99,
image: 'sticker.png'
});
}
function createBaskets() {
models.Basket.create({
UserId: 1
});
models.Basket.create({
UserId: 2
});
models.Basket.create({
UserId: 3
});
models.BasketItem.create({
BasketId: 1,
ProductId: 1,
quantity: 2
});
models.BasketItem.create({
BasketId: 1,
ProductId: 2,
quantity: 3
});
models.BasketItem.create({
BasketId: 1,
ProductId: 3,
quantity: 1
});
models.BasketItem.create({
BasketId: 2,
ProductId: 4,
quantity: 2
});
models.BasketItem.create({
BasketId: 3,
ProductId: 5,
quantity: 1
});
}
function createFeedback() {
models.Feedback.create({
UserId: 1,
comment: 'I love this shop! Best juice in town! Highly recommended!',
rating: 5
});
models.Feedback.create({
UserId: 2,
comment: 'Great shop! The O-Saft is highly recommended!',
rating: 4
});
models.Feedback.create({
comment: 'Why isn\'t there a T-Shirt for skinny people available?!',
rating: 2
});
models.Feedback.create({
comment: 'This is <b>the</b> store for juices of all kinds!',
rating: 4
});
models.Feedback.create({
comment: 'Never gonna buy my juice anywhere else from now on! Thanks for the great service!',
rating: 4
});
models.Feedback.create({
comment: 'Keep up the good work!',
rating: 3
});
models.Feedback.create({
UserId: 3,
comment: 'No real drinks available here!',
rating: 1
});
}
};