@@ -105,9 +105,17 @@ func Test_generatePayloads(t *testing.T) {
105
105
wantDurlsCount int
106
106
}{
107
107
{
108
- name : "Basic payload generation" ,
109
- target : server .URL + "/?param=test" ,
110
- options : options ,
108
+ name : "Basic payload generation" ,
109
+ target : server .URL + "/?param=test" ,
110
+ options : model.Options {
111
+ Concurrence : 1 ,
112
+ Format : "plain" ,
113
+ Silence : true ,
114
+ NoSpinner : true ,
115
+ CustomAlertType : "none" ,
116
+ IgnoreParams : []string {"param2" },
117
+ UseHeadless : true ,
118
+ },
111
119
policy : map [string ]string {"Content-Type" : "text/html" },
112
120
pathReflection : make (map [int ]string ),
113
121
params : map [string ]model.ParamResult {
@@ -118,6 +126,13 @@ func Test_generatePayloads(t *testing.T) {
118
126
ReflectedPoint : "Injected:inHTML" ,
119
127
Chars : []string {"'" , "\" " , "<" , ">" , "(" , ")" , "{" , "}" , "[" , "]" , " " , "\t " , "\n " , "\r " , "\f " , "\v " , "\\ " , "/" , "?" , "#" , "&" , "=" , "%" , ":" , ";" , "," , "@" , "$" , "*" , "+" , "-" , "_" , "." , "!" , "~" , "`" , "|" , "^" },
120
128
},
129
+ "param2" : {
130
+ Name : "param2" ,
131
+ Type : "URL" ,
132
+ Reflected : true ,
133
+ ReflectedPoint : "" ,
134
+ Chars : []string {},
135
+ },
121
136
},
122
137
wantQueryCount : 1 , // At least one query should be generated
123
138
wantDurlsCount : 0 ,
@@ -140,10 +155,98 @@ func Test_generatePayloads(t *testing.T) {
140
155
pathReflection : map [int ]string {
141
156
0 : "Injected:/inHTML" ,
142
157
},
143
- params : make (map [string ]model.ParamResult ),
158
+ params : map [string ]model.ParamResult {
159
+ "param" : {
160
+ Name : "param" ,
161
+ Type : "URL" ,
162
+ Reflected : true ,
163
+ ReflectedPoint : "Injected:inJS-single" ,
164
+ Chars : []string {},
165
+ },
166
+ },
144
167
wantQueryCount : 1 , // At least one query should be generated
145
168
wantDurlsCount : 0 ,
146
169
},
170
+ {
171
+ name : "Path reflection payload (body)" ,
172
+ target : server .URL + "/path" ,
173
+ options : model.Options {
174
+ Concurrence : 1 ,
175
+ Format : "plain" ,
176
+ Silence : true ,
177
+ NoSpinner : true ,
178
+ CustomAlertType : "none" ,
179
+ Data : "param=test" ,
180
+ },
181
+ policy : map [string ]string {"Content-Type" : "text/html" },
182
+ pathReflection : map [int ]string {
183
+ 0 : "Injected:/inHTML" ,
184
+ },
185
+ params : map [string ]model.ParamResult {
186
+ "param" : {
187
+ Name : "param" ,
188
+ Type : "URL" ,
189
+ Reflected : true ,
190
+ ReflectedPoint : "Injected:inJS-single" ,
191
+ Chars : []string {},
192
+ },
193
+ },
194
+ wantQueryCount : 1 , // At least one query should be generated
195
+ wantDurlsCount : 0 ,
196
+ },
197
+ {
198
+ name : "Reflected, but not chars" ,
199
+ target : server .URL ,
200
+ options : options ,
201
+ policy : map [string ]string {"Content-Type" : "text/html" },
202
+ pathReflection : make (map [int ]string ),
203
+ params : make (map [string ]model.ParamResult ),
204
+ wantQueryCount : 0 ,
205
+ wantDurlsCount : 0 ,
206
+ },
207
+ {
208
+ name : "inJS reflected parameter" ,
209
+ target : server .URL + "/path/?param=test" ,
210
+ options : options ,
211
+ policy : map [string ]string {"Content-Type" : "text/html" },
212
+ pathReflection : make (map [int ]string ),
213
+ params : map [string ]model.ParamResult {
214
+ "param" : {
215
+ Name : "param" ,
216
+ Type : "URL" ,
217
+ Reflected : true ,
218
+ ReflectedPoint : "Injected:inJS-single" ,
219
+ Chars : []string {"'" , "\" " , "<" , ">" , "(" , ")" , "{" , "}" , "[" , "]" , " " , "\t " , "\n " , "\r " , "\f " , "\v " , "\\ " , "/" , "?" , "#" , "&" , "=" , "%" , ":" , ";" , "," , "@" , "$" , "*" , "+" , "-" , "_" , "." , "!" , "~" , "`" , "|" , "^" },
220
+ },
221
+ },
222
+ wantQueryCount : 1 ,
223
+ wantDurlsCount : 0 ,
224
+ },
225
+ {
226
+ name : "inJS reflected parameter" ,
227
+ target : server .URL + "/path/" ,
228
+ options : model.Options {
229
+ Concurrence : 1 ,
230
+ Format : "plain" ,
231
+ Silence : true ,
232
+ NoSpinner : true ,
233
+ CustomAlertType : "none" ,
234
+ Data : "param=test" ,
235
+ },
236
+ policy : map [string ]string {"Content-Type" : "text/html" },
237
+ pathReflection : make (map [int ]string ),
238
+ params : map [string ]model.ParamResult {
239
+ "param" : {
240
+ Name : "param" ,
241
+ Type : "URL" ,
242
+ Reflected : true ,
243
+ ReflectedPoint : "Injected:inATTR-none" ,
244
+ Chars : []string {"'" , "\" " , "<" , ">" , "(" , ")" , "{" , "}" , "[" , "]" , " " , "\t " , "\n " , "\r " , "\f " , "\v " , "\\ " , "/" , "?" , "#" , "&" , "=" , "%" , ":" , ";" , "," , "@" , "$" , "*" , "+" , "-" , "_" , "." , "!" , "~" , "`" , "|" , "^" },
245
+ },
246
+ },
247
+ wantQueryCount : 1 ,
248
+ wantDurlsCount : 0 ,
249
+ },
147
250
}
148
251
149
252
for _ , tt := range tests {
@@ -255,7 +358,7 @@ func Test_updateSpinner(t *testing.T) {
255
358
256
359
func Test_Scan (t * testing.T ) {
257
360
// Create a mock server
258
- server := mockServer ()
361
+ server := mockServerForScanTest ()
259
362
defer server .Close ()
260
363
261
364
type args struct {
@@ -286,14 +389,14 @@ func Test_Scan(t *testing.T) {
286
389
{
287
390
name : "Basic scan with skip discovery" ,
288
391
args : args {
289
- target : server .URL + "/?param =test" ,
392
+ target : server .URL + "/?query =test" ,
290
393
options : model.Options {
291
394
Concurrence : 1 ,
292
395
Format : "plain" ,
293
396
Silence : true ,
294
397
NoSpinner : true ,
295
398
SkipDiscovery : true ,
296
- UniqParam : []string {"param " },
399
+ UniqParam : []string {"query " },
297
400
OnlyDiscovery : true , // To make test faster
298
401
},
299
402
sid : "1" ,
@@ -303,14 +406,14 @@ func Test_Scan(t *testing.T) {
303
406
{
304
407
name : "Basic scan with remote payloads" ,
305
408
args : args {
306
- target : server .URL + "/?param =test" ,
409
+ target : server .URL + "/?query =test" ,
307
410
options : model.Options {
308
411
Concurrence : 1 ,
309
412
Format : "plain" ,
310
413
Silence : true ,
311
414
NoSpinner : true ,
312
415
SkipDiscovery : true ,
313
- UniqParam : []string {"param " },
416
+ UniqParam : []string {"query " },
314
417
RemotePayloads : "portswigger,payloadbox" ,
315
418
},
316
419
sid : "1" ,
@@ -320,15 +423,16 @@ func Test_Scan(t *testing.T) {
320
423
{
321
424
name : "Basic scan with blind xss" ,
322
425
args : args {
323
- target : server .URL + "/?param =test" ,
426
+ target : server .URL + "/?query =test" ,
324
427
options : model.Options {
325
428
Concurrence : 1 ,
326
429
Format : "plain" ,
327
430
Silence : true ,
328
431
NoSpinner : true ,
329
432
SkipDiscovery : true ,
330
- UniqParam : []string {"param " },
433
+ UniqParam : []string {"query " },
331
434
BlindURL : "https://dalfox.hahwul.com" ,
435
+ Data : "query=1234" ,
332
436
},
333
437
sid : "1" ,
334
438
},
@@ -337,15 +441,16 @@ func Test_Scan(t *testing.T) {
337
441
{
338
442
name : "Basic scan with headless" ,
339
443
args : args {
340
- target : server .URL + "/?param =test" ,
444
+ target : server .URL + "/abcd/?query =test" ,
341
445
options : model.Options {
342
446
Concurrence : 1 ,
343
447
Format : "plain" ,
344
448
Silence : true ,
345
449
NoSpinner : true ,
346
450
SkipDiscovery : true ,
347
- UniqParam : []string {"param " },
451
+ UniqParam : []string {"query " },
348
452
UseHeadless : true ,
453
+ IgnoreReturn : "404" ,
349
454
},
350
455
sid : "1" ,
351
456
},
@@ -362,3 +467,35 @@ func Test_Scan(t *testing.T) {
362
467
})
363
468
}
364
469
}
470
+
471
+ func Test_initializeSpinner (t * testing.T ) {
472
+ type args struct {
473
+ options model.Options
474
+ }
475
+ tests := []struct {
476
+ name string
477
+ args args
478
+ }{
479
+ {
480
+ name : "No spinner" ,
481
+ args : args {
482
+ options : model.Options {
483
+ NoSpinner : true ,
484
+ },
485
+ },
486
+ },
487
+ {
488
+ name : "Spinner" ,
489
+ args : args {
490
+ options : model.Options {
491
+ NoSpinner : false ,
492
+ },
493
+ },
494
+ },
495
+ }
496
+ for _ , tt := range tests {
497
+ t .Run (tt .name , func (t * testing.T ) {
498
+ initializeSpinner (tt .args .options )
499
+ })
500
+ }
501
+ }
0 commit comments