Introduction
Web servers often host files and directories that are not directly linked from the main website. These hidden resources can include administrative portals, old backup files, configuration files containing passwords, or development endpoints. If an attacker discovers these hidden paths, it can lead to severe security breaches.
This is a good example of the difference between "not linked" and "not accessible." Many web servers expose resources simply because the file exists at a reachable path, even if no normal page links to it.
In this lab, you will step into the shoes of a security tester. You will learn how to use popular directory brute-forcing (fuzzing) tools, specifically ffuf and gobuster, to uncover hidden content on a target web server. By systematically requesting thousands of potential paths using a "wordlist," you can reveal the hidden structure of a web application.
A local test web server has been automatically started for you on port 8080. Your goal is to discover its hidden secrets!
Select a Fuzzing Wordlist
In this step, you will explore the concept of a wordlist. A wordlist (or dictionary) is simply a text file containing a list of common directory and file names. Fuzzing tools use these lists to guess the names of hidden resources on a web server by trying each word one by one.
Wordlists work because developers and administrators tend to reuse familiar naming patterns such as admin, backup, test, or config. Fuzzing turns that predictability into a discovery method.
For this lab, a custom wordlist has already been prepared for you. It contains common terms that developers often use when naming sensitive directories or files.
First, let's navigate to your project directory and view the contents of the provided wordlist. Use the cat command to print the file to your terminal.
cat ~/project/wordlists/common.txt
You should see an output similar to this:
admin
backup
api
config
notes
login
index
test
hidden
secret
These are the words our fuzzing tools will append to the target URL to check if a corresponding file or directory exists. In real-world scenarios, security professionals use massive wordlists containing millions of entries, such as those found in the popular "SecLists" repository. For this learning environment, we are using a smaller list to ensure the tools run quickly.
Execute Directory Brute-Force
In this step, you will use ffuf (Fuzz Faster U Fool) to discover hidden directories on the target web server. ffuf is a fast web fuzzer written in Go that is widely used in the cybersecurity industry.
At a high level, fuzzing here means systematic guessing with automation. You are not exploiting the application yet. You are mapping its reachable surface area by testing many candidate paths quickly.
The target web server is running locally on your machine at http://localhost:8080.
To use ffuf, you need to specify the wordlist using the -w flag and the target URL using the -u flag. The most important part of using ffuf is the FUZZ keyword. You place the word FUZZ in the URL exactly where you want the tool to inject the words from your wordlist.
Run the following command to start directory fuzzing:
ffuf -w ~/project/wordlists/common.txt -u http://localhost:8080/FUZZ
When the command finishes, you will see an output similar to this:
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.0.0-dev
________________________________________________
:: Method : GET
:: URL : http://localhost:8080/FUZZ
:: Wordlist : FUZZ: /home/labex/project/wordlists/common.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200,204,301,302,307,401,403,405,500
________________________________________________
admin [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 2ms]
api [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 2ms]
backup [Status: 301, Size: 0, Words: 1, Lines: 1, Duration: 2ms]
:: Progress: [10/10] :: Job [1/1] :: 0 req/sec :: Duration: [0:00:00] :: Errors: 0 ::
Notice that ffuf found admin, api, and backup. The server returned a 301 status code for these, which typically indicates a directory redirect (e.g., redirecting /admin to /admin/). You have successfully discovered hidden directories!
Fuzz for Specific File Extensions (.php, .txt)
In this step, you will use another popular tool called gobuster to search for specific files. While finding directories is useful, sensitive information is often stored in files like configuration scripts (.php) or text notes (.txt) located in the root directory.
gobuster has a specific mode called dir for directory and file brute-forcing. You can use the -x flag to tell gobuster to append specific file extensions to every word in your wordlist.
Run the following command to search for .php and .txt files on the target server:
gobuster dir -u http://localhost:8080 -w ~/project/wordlists/common.txt -x php,txt
Let's break down the command:
dir: Tells gobuster to use directory/file brute-forcing mode.-u: Specifies the target URL.-w: Specifies the wordlist.-x php,txt: Tells gobuster to try each word normally, and then try it with.phpand.txtappended (e.g.,admin,admin.php,admin.txt).
You should see an output similar to this:
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://localhost:8080
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /home/labex/project/wordlists/common.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.6
[+] Extensions: php,txt
[+] Timeout: 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/config.php (Status: 200) [Size: 15]
/notes.txt (Status: 200) [Size: 28]
/admin (Status: 301) [Size: 0] [--> /admin/]
/backup (Status: 301) [Size: 0] [--> /backup/]
Progress: 30 / 33 (90.91%)
/api (Status: 301) [Size: 0] [--> /api/]
===============================================================
Finished
===============================================================
Excellent! gobuster successfully discovered config.php and notes.txt by appending the extensions you provided. These files returned a 200 status code, meaning they were successfully accessed.
Filter Responses by Status Code
In this step, you will learn how to filter fuzzing results. When fuzzing large web applications, you might receive hundreds of responses with status codes like 403 (Forbidden) or 301 (Redirect). This can clutter your terminal and make it hard to find the actual accessible files, which usually return a 200 (OK) status code.
You can tell ffuf to only show results that match specific HTTP status codes using the -mc (Match Code) flag.
Let's use ffuf to look specifically for .php files, but this time we will filter the output so it only shows us files that return a 200 OK status code.
Run the following command:
ffuf -w ~/project/wordlists/common.txt -u http://localhost:8080/FUZZ.php -mc 200
Notice how we placed .php directly after the FUZZ keyword in the URL (/FUZZ.php). This tells ffuf to append .php to every word it tries. The -mc 200 flag ensures we only see successful hits.
The output will look like this:
/'___\ /'___\ /'___\
/\ \__/ /\ \__/ __ __ /\ \__/
\ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\
\ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/
\ \_\ \ \_\ \ \____/ \ \_\
\/_/ \/_/ \/___/ \/_/
v2.0.0-dev
________________________________________________
:: Method : GET
:: URL : http://localhost:8080/FUZZ.php
:: Wordlist : FUZZ: /home/labex/project/wordlists/common.txt
:: Follow redirects : false
:: Calibration : false
:: Timeout : 10
:: Threads : 40
:: Matcher : Response status: 200
________________________________________________
config [Status: 200, Size: 15, Words: 1, Lines: 2, Duration: 2ms]
:: Progress: [10/10] :: Job [1/1] :: 0 req/sec :: Duration: [0:00:00] :: Errors: 0 ::
By using -mc 200, the output is clean and only shows the config.php file, ignoring any other responses. Filtering is a crucial skill for efficiently analyzing fuzzing results.
Summary
Congratulations! You have successfully completed the Directory and File Fuzzing lab.
In this lab, you learned how web servers can inadvertently expose sensitive information through hidden directories and files. You gained hands-on experience with two industry-standard tools, ffuf and gobuster. You learned how to utilize wordlists to brute-force paths, how to target specific file extensions like .php and .txt, and how to filter your results by HTTP status codes to find exactly what you are looking for. These techniques are fundamental for web application security testing and vulnerability discovery.



