Understand the Purpose of a User-Agent String
In this step, you will learn what a User-Agent string is and why it's important in web requests.
The User-Agent string is a header sent by a client (like a web browser or a tool like Gobuster) to a web server. It typically contains information about the client's application type, operating system, software vendor, and software version. Web servers use this information to deliver content optimized for the client or to log client statistics.
For security tools like Gobuster, the default User-Agent string often reveals the tool's identity, which can trigger WAFs or intrusion detection systems (IDS). For example, Gobuster's default User-Agent might look something like gobuster/3.1.0.
Let's perform a basic Gobuster scan without any custom User-Agent to see its default behavior. We will scan a local web server that was set up in the background.
First, ensure the web server is running by checking its process:
ps aux | grep "python3 -m http.server 8080" | grep -v grep
You should see an output similar to this, indicating the server is running:
labex 1234 0.0 0.1 12345 6789 ? Sl HH:MM 0:00 python3 -m http.server 8080 --directory /tmp/web_root
Now, run a simple Gobuster scan against the local server on port 8080. We'll use a small wordlist for demonstration.
gobuster dir -u http://127.0.0.1:8080 -w /usr/share/wordlists/dirb/common.txt -q -x html,txt -t 10
-u http://127.0.0.1:8080: Specifies the target URL.
-w /usr/share/wordlists/dirb/common.txt: Specifies the wordlist to use.
-q: Quiet mode, only prints results.
-x html,txt: Specifies extensions to look for.
-t 10: Sets the number of concurrent threads to 10.
You will see output similar to this, showing discovered directories and files:
/admin (Status: 200)
/secret (Status: 200)
/backup (Status: 200)
While this scan works, the User-Agent used by Gobuster is its default one, which could be easily blocked by a WAF.