Recursive Fuzzing

Overview

Recursive fuzzing is an automated technique for exploring nested directory structures in web applications. It extends traditional directory fuzzing by dynamically discovering and probing directories as they are found.

How Recursive Fuzzing Works

1. Initial Fuzzing

2. Directory Discovery and Expansion

3. Iterative Depth

Visual analogy:

Benefits of Recursive Fuzzing

Recursive Fuzzing with ffuf

Let's use ffuf to demonstrate recursive fuzzing:

m4cc18@htb[/htb]$ ffuf -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -ic -v -u http://IP:PORT/FUZZ -e .html -recursion 

Output:


        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://IP:PORT/FUZZ
 :: Wordlist         : FUZZ: /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt
 :: Extensions       : .html 
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

[Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 0ms]
| URL | http://IP:PORT/level1
| --> | /level1/
    * FUZZ: level1

[INFO] Adding a new job to the queue: http://IP:PORT/level1/FUZZ

[INFO] Starting queued job on target: http://IP:PORT/level1/FUZZ

[Status: 200, Size: 96, Words: 6, Lines: 2, Duration: 0ms]
| URL | http://IP:PORT/level1/index.html
    * FUZZ: index.html

[Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 0ms]
| URL | http://IP:PORT/level1/level2
| --> | /level1/level2/
    * FUZZ: level2

[INFO] Adding a new job to the queue: http://IP:PORT/level1/level2/FUZZ

[Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 0ms]
| URL | http://IP:PORT/level1/level3
| --> | /level1/level3/
    * FUZZ: level3

[INFO] Adding a new job to the queue: http://IP:PORT/level1/level3/FUZZ

[INFO] Starting queued job on target: http://IP:PORT/level1/level2/FUZZ

[Status: 200, Size: 96, Words: 6, Lines: 2, Duration: 0ms]
| URL | http://IP:PORT/level1/level2/index.html
    * FUZZ: index.html

[INFO] Starting queued job on target: http://IP:PORT/level1/level3/FUZZ

[Status: 200, Size: 126, Words: 8, Lines: 2, Duration: 0ms]
| URL | http://IP:PORT/level1/level3/index.html
    * FUZZ: index.html

:: Progress: [441088/441088] :: Job [4/4] :: 100000 req/sec :: Duration: [0:00:06] :: Errors: 0 ::

Be Responsible

While recursive fuzzing is a powerful technique, it can also be resource-intensive, especially on large web applications. Excessive requests can overwhelm the target server, potentially causing performance issues or triggering security mechanisms.

To mitigate these risks, ffuf provides options for fine-tuning the recursive fuzzing process:

Fuzzing files recursively

This is how a fuzz command to recursively fuzz files would look like

m4cc18@htb[/htb]$ ffuf -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-medium.txt -ic -u http://IP:PORT/FUZZ -e .html -recursion -recursion-depth 2 -rate 500

Exercise

TARGET: 94.237.48.51:36742

Challenge 1

Recursively fuzz the "recursive_fuzz" path on the target system (ie http://IP:PORT/recursive_fuzz/) to find the flag.

1. Try a recursive file fuzz

Using the above command as an example, lets try using ffuf to recursively fuzz files within recursive_fuzz/

┌──(macc㉿kaliLab)-[~]
└─$ ffuf -w ~/SecLists/Discovery/Web-Content/DirBuster-2007_directory-list-2.3-medium.txt -ic -u http://94.237.51.125:54884/recursive_fuzz/FUZZ -e .html -recursion -recursion-depth 5 -t 500 -timeout 5

Output:

...
level1                  [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 76ms]
[INFO] Adding a new job to the queue: http://94.237.48.51:36742/recursive_fuzz/level1/FUZZ
...

[INFO] Starting queued job on target: http://94.237.51.125:54884/recursive_fuzz/level1/FUZZ

                        [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 116ms]
index.html              [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 117ms]
...
level2                  [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 76ms]
[INFO] Adding a new job to the queue: http://94.237.48.51:36742/recursive_fuzz/level1/level2/FUZZ
...

[INFO] Starting queued job on target: http://94.237.51.125:54884/recursive_fuzz/level1/level2/FUZZ

                        [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 112ms]
index.html              [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 113ms]
...
level3                  [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 112ms]
:: Progress: [37026/441092] :: Job [3/3] :: 4370 req/sec :: Duration: [0:00:08] :: Errors: 0 [INFO] Adding a new job to the queue: http://94.237.51.125:54884/recursive_fuzz/level1/level2/level3/FUZZ
...

[INFO] Starting queued job on target: http://94.237.51.125:54884/recursive_fuzz/level1/level2/level3/FUZZ

index.html              [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 113ms]
                        [Status: 200, Size: 111, Words: 8, Lines: 2, Duration: 113ms]
...

threatcon_level2        [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 120ms]
:: Progress: [35682/441092] :: Job [4/4] :: 4393 req/sec :: Duration: [0:00:08] :: Errors: 0 [INFO] Adding a new job to the queue: http://94.237.51.125:54884/recursive_fuzz/level1/level2/level3/threatcon_level2/FUZZ
...

[INFO] Starting queued job on target: http://94.237.51.125:54884/recursive_fuzz/level1/level2/level3/threatcon_level2/FUZZ

                        [Status: 200, Size: 146, Words: 10, Lines: 2, Duration: 116ms]
index.html              [Status: 200, Size: 146, Words: 10, Lines: 2, Duration: 116ms]

2. Curl the flag

To get the flag, lets try a curl command that sends a GET request to the newly found path to the index.html file:

┌──(macc㉿kaliLab)-[~]
└─$ curl http://94.237.51.125:54884/recursive_fuzz/level1/level2/level3/threatcon_level2/

Output:

<html><head><title>Level 4 Directory</title></head><body><h1>This is Recursive Fuzz Level 4 - HTB{d33p3r_d1rector1es_ar3_c00l}</h1></body></html>

flag: HTB