feroxbuster 2.13.1

A fast, simple, recursive content discovery tool.
Documentation
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
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
use super::utils::*;
use super::*;
use crate::{traits::FeroxSerialize, DEFAULT_CONFIG_NAME};
use regex::Regex;
use reqwest::Url;
use std::{collections::HashMap, fs::write};
use tempfile::TempDir;

/// creates a dummy configuration file for testing
fn setup_config_test() -> Configuration {
    let data = r#"
            wordlist = "/some/path"
            status_codes = [201, 301, 401]
            replay_codes = [201, 301]
            threads = 40
            timeout = 5
            proxy = "http://127.0.0.1:8080"
            replay_proxy = "http://127.0.0.1:8081"
            quiet = true
            silent = true
            auto_tune = true
            auto_bail = true
            verbosity = 1
            scan_limit = 6
            parallel = 14
            rate_limit = 250
            time_limit = "10m"
            output = "/some/otherpath"
            debug_log = "/yet/anotherpath"
            resume_from = "/some/state/file"
            redirects = true
            insecure = true
            collect_backups = true
            collect_extensions = true
            collect_words = true
            extensions = ["html", "php", "js"]
            dont_collect = ["png", "gif", "jpg", "jpeg"]
            methods = ["GET", "PUT", "DELETE"]
            data = [31, 32, 33, 34]
            url_denylist = ["http://dont-scan.me", "https://also-not.me"]
            scope = ["http://example.com", "https://other.com"]
            regex_denylist = ["/deny.*"]
            headers = {stuff = "things", mostuff = "mothings"}
            queries = [["name","value"], ["rick", "astley"]]
            no_recursion = true
            add_slash = true
            stdin = true
            dont_filter = true
            extract_links = false
            json = true
            save_state = false
            depth = 1
            limit_bars = 3
            protocol = "http"
            request_file = "/some/request/file"
            scan_dir_listings = true
            force_recursion = true
            filter_size = [4120]
            filter_regex = ["^ignore me$"]
            filter_similar = ["https://somesite.com/soft404"]
            filter_word_count = [994, 992]
            filter_line_count = [34]
            filter_status = [201]
            server_certs = ["/some/cert.pem", "/some/other/cert.pem"]
            client_cert = "/some/client/cert.pem"
            client_key = "/some/client/key.pem"
            backup_extensions = [".save"]
            unique = true
            response_size_limit = 8388608
        "#;
    let tmp_dir = TempDir::new().unwrap();
    let file = tmp_dir.path().join(DEFAULT_CONFIG_NAME);
    write(&file, data).unwrap();
    Configuration::parse_config(file).unwrap()
}

#[test]
/// test that all default config values meet expectations
fn default_configuration() {
    let config = Configuration::default();
    assert_eq!(config.wordlist, wordlist());
    assert_eq!(config.proxy, String::new());
    assert_eq!(config.target_url, String::new());
    assert_eq!(config.time_limit, String::new());
    assert_eq!(config.resume_from, String::new());
    assert_eq!(config.debug_log, String::new());
    assert_eq!(config.config, String::new());
    assert_eq!(config.replay_proxy, String::new());
    assert_eq!(config.status_codes, status_codes());
    assert_eq!(config.replay_codes, config.status_codes);
    assert!(config.replay_client.is_none());
    assert_eq!(config.threads, threads());
    assert_eq!(config.depth, depth());
    assert_eq!(config.timeout, timeout());
    assert_eq!(config.verbosity, 0);
    assert_eq!(config.scan_limit, 0);
    assert_eq!(config.limit_bars, 0);
    assert!(!config.silent);
    assert!(!config.quiet);
    assert_eq!(config.output_level, OutputLevel::Default);
    assert!(!config.dont_filter);
    assert!(!config.auto_tune);
    assert!(!config.auto_bail);
    assert_eq!(config.requester_policy, RequesterPolicy::Default);
    assert!(!config.no_recursion);
    assert!(!config.random_agent);
    assert!(!config.json);
    assert!(config.save_state);
    assert!(!config.stdin);
    assert!(!config.add_slash);
    assert!(!config.force_recursion);
    assert!(!config.redirects);
    assert!(config.extract_links);
    assert!(!config.insecure);
    assert!(!config.collect_extensions);
    assert!(!config.collect_backups);
    assert!(!config.collect_words);
    assert!(!config.scan_dir_listings);
    assert!(config.regex_denylist.is_empty());
    assert_eq!(config.queries, Vec::new());
    assert_eq!(config.filter_size, Vec::<u64>::new());
    assert_eq!(config.extensions, Vec::<String>::new());
    assert_eq!(config.methods, vec!["GET"]);
    assert_eq!(config.data, Vec::<u8>::new());
    assert_eq!(config.url_denylist, Vec::<Url>::new());
    assert_eq!(config.scope, Vec::<Url>::new());
    assert_eq!(config.dont_collect, ignored_extensions());
    assert_eq!(config.filter_regex, Vec::<String>::new());
    assert_eq!(config.filter_similar, Vec::<String>::new());
    assert_eq!(config.filter_word_count, Vec::<usize>::new());
    assert_eq!(config.filter_line_count, Vec::<usize>::new());
    assert_eq!(config.filter_status, Vec::<u16>::new());
    assert_eq!(config.headers, HashMap::new());
    assert_eq!(config.server_certs, Vec::<String>::new());
    assert_eq!(config.client_cert, String::new());
    assert_eq!(config.client_key, String::new());
    assert_eq!(config.backup_extensions, backup_extensions());
    assert_eq!(config.protocol, request_protocol());
    assert_eq!(config.request_file, String::new());
    assert!(!config.unique);
    assert_eq!(config.response_size_limit, 4194304); // 4MB
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_wordlist() {
    let config = setup_config_test();
    assert_eq!(config.wordlist, "/some/path");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_debug_log() {
    let config = setup_config_test();
    assert_eq!(config.debug_log, "/yet/anotherpath");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_status_codes() {
    let config = setup_config_test();
    assert_eq!(config.status_codes, vec![201, 301, 401]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_replay_codes() {
    let config = setup_config_test();
    assert_eq!(config.replay_codes, vec![201, 301]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_threads() {
    let config = setup_config_test();
    assert_eq!(config.threads, 40);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_depth() {
    let config = setup_config_test();
    assert_eq!(config.depth, 1);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_scan_limit() {
    let config = setup_config_test();
    assert_eq!(config.scan_limit, 6);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_parallel() {
    let config = setup_config_test();
    assert_eq!(config.parallel, 14);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_rate_limit() {
    let config = setup_config_test();
    assert_eq!(config.rate_limit, 250);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_timeout() {
    let config = setup_config_test();
    assert_eq!(config.timeout, 5);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_proxy() {
    let config = setup_config_test();
    assert_eq!(config.proxy, "http://127.0.0.1:8080");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_replay_proxy() {
    let config = setup_config_test();
    assert_eq!(config.replay_proxy, "http://127.0.0.1:8081");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_silent() {
    let config = setup_config_test();
    assert!(config.silent);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_force_recursion() {
    let config = setup_config_test();
    assert!(config.force_recursion);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_quiet() {
    let config = setup_config_test();
    assert!(config.quiet);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_json() {
    let config = setup_config_test();
    assert!(config.json);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_auto_bail() {
    let config = setup_config_test();
    assert!(config.auto_bail);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_auto_tune() {
    let config = setup_config_test();
    assert!(config.auto_tune);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_verbosity() {
    let config = setup_config_test();
    assert_eq!(config.verbosity, 1);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_limit_bars() {
    let config = setup_config_test();
    assert_eq!(config.limit_bars, 3);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_output() {
    let config = setup_config_test();
    assert_eq!(config.output, "/some/otherpath");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_redirects() {
    let config = setup_config_test();
    assert!(config.redirects);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_insecure() {
    let config = setup_config_test();
    assert!(config.insecure);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_no_recursion() {
    let config = setup_config_test();
    assert!(config.no_recursion);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_stdin() {
    let config = setup_config_test();
    assert!(config.stdin);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_dont_filter() {
    let config = setup_config_test();
    assert!(config.dont_filter);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_add_slash() {
    let config = setup_config_test();
    assert!(config.add_slash);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_extract_links() {
    let config = setup_config_test();
    assert!(!config.extract_links);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_collect_extensions() {
    let config = setup_config_test();
    assert!(config.collect_extensions);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_collect_backups() {
    let config = setup_config_test();
    assert!(config.collect_backups);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_collect_words() {
    let config = setup_config_test();
    assert!(config.collect_words);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_extensions() {
    let config = setup_config_test();
    assert_eq!(config.extensions, vec!["html", "php", "js"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_dont_collect() {
    let config = setup_config_test();
    assert_eq!(config.dont_collect, vec!["png", "gif", "jpg", "jpeg"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_methods() {
    let config = setup_config_test();
    assert_eq!(config.methods, vec!["GET", "PUT", "DELETE"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_data() {
    let config = setup_config_test();
    assert_eq!(config.data, vec![31, 32, 33, 34]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_regex_denylist() {
    let config = setup_config_test();
    assert_eq!(
        config.regex_denylist[0].as_str(),
        Regex::new("/deny.*").unwrap().as_str()
    );
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_url_denylist() {
    let config = setup_config_test();
    assert_eq!(
        config.url_denylist,
        vec![
            Url::parse("http://dont-scan.me").unwrap(),
            Url::parse("https://also-not.me").unwrap(),
        ]
    );
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_scope() {
    let config = setup_config_test();
    assert_eq!(
        config.scope,
        vec![
            Url::parse("http://example.com").unwrap(),
            Url::parse("https://other.com").unwrap(),
        ]
    );
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_regex() {
    let config = setup_config_test();
    assert_eq!(config.filter_regex, vec!["^ignore me$"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_similar() {
    let config = setup_config_test();
    assert_eq!(config.filter_similar, vec!["https://somesite.com/soft404"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_size() {
    let config = setup_config_test();
    assert_eq!(config.filter_size, vec![4120]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_word_count() {
    let config = setup_config_test();
    assert_eq!(config.filter_word_count, vec![994, 992]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_line_count() {
    let config = setup_config_test();
    assert_eq!(config.filter_line_count, vec![34]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_filter_status() {
    let config = setup_config_test();
    assert_eq!(config.filter_status, vec![201]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_save_state() {
    let config = setup_config_test();
    assert!(!config.save_state);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_time_limit() {
    let config = setup_config_test();
    assert_eq!(config.time_limit, "10m");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_scan_dir_listings() {
    let config = setup_config_test();
    assert!(config.scan_dir_listings);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_protocol() {
    let config = setup_config_test();
    assert_eq!(config.protocol, "http");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_request_file() {
    let config = setup_config_test();
    assert_eq!(config.request_file, String::new());
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_resume_from() {
    let config = setup_config_test();
    assert_eq!(config.resume_from, "/some/state/file");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_server_certs() {
    let config = setup_config_test();
    assert_eq!(
        config.server_certs,
        ["/some/cert.pem", "/some/other/cert.pem"]
    );
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_backup_extensions() {
    let config = setup_config_test();
    assert_eq!(config.backup_extensions, [".save"]);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_client_cert() {
    let config = setup_config_test();
    assert_eq!(config.client_cert, "/some/client/cert.pem");
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_client_key() {
    let config = setup_config_test();
    assert_eq!(config.client_key, "/some/client/key.pem");
}

#[test]
/// parse the test config and see that the values parsed are correct
fn config_reads_headers() {
    let config = setup_config_test();
    let mut headers = HashMap::new();
    headers.insert("stuff".to_string(), "things".to_string());
    headers.insert("mostuff".to_string(), "mothings".to_string());
    assert_eq!(config.headers, headers);
}

#[test]
/// parse the test config and see that the values parsed are correct
fn config_reads_queries() {
    let config = setup_config_test();
    let queries = vec![
        ("name".to_string(), "value".to_string()),
        ("rick".to_string(), "astley".to_string()),
    ];
    assert_eq!(config.queries, queries);
}

#[test]
fn config_default_not_random_agent() {
    let config = setup_config_test();
    assert!(!config.random_agent);
}

#[test]
#[should_panic]
/// test that an error message is printed and panic is called when report_and_exit is called
fn config_report_and_exit_works() {
    report_and_exit("some message");
}

#[test]
/// test as_str method of Configuration
fn as_str_returns_string_with_newline() {
    let config = Configuration::new().unwrap();
    let config_str = config.as_str();
    println!("{config_str}");
    assert!(config_str.starts_with("Configuration {"));
    assert!(config_str.ends_with("}\n"));
    assert!(config_str.contains("replay_codes:"));
    assert!(config_str.contains("client: Client {"));
    assert!(config_str.contains("user_agent: \"feroxbuster"));
}

#[test]
/// test as_json method of Configuration
fn as_json_returns_json_representation_of_configuration_with_newline() {
    let mut config = Configuration::new().unwrap();
    config.timeout = 12;
    config.depth = 2;
    let config_str = config.as_json().unwrap();
    let json: Configuration = serde_json::from_str(&config_str).unwrap();
    assert_eq!(json.config, config.config);
    assert_eq!(json.wordlist, config.wordlist);
    assert_eq!(json.replay_codes, config.replay_codes);
    assert_eq!(json.timeout, config.timeout);
    assert_eq!(json.depth, config.depth);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_unique() {
    let config = setup_config_test();
    assert!(config.unique);
}

#[test]
/// parse the test config and see that the value parsed is correct
fn config_reads_response_size_limit() {
    let config = setup_config_test();
    assert_eq!(config.response_size_limit, 8388608); // 8MB as set in setup_config_test
}