Step-by-Step Guide to Finding Hidden Paths and Subdomains with Gobuster

Mahak PandeyMahak Pandey
4 min read

Introduction

In the world of cybersecurity, visibility is key. Many potential vulnerabilities lie hidden behind unadvertised directories, files, or subdomains. Uncovering these hidden elements is crucial for a thorough security assessment. Enter Gobuster, a powerful tool designed to make this process efficient and effective.

In this blog post, we’ll dive into what Gobuster is, how it works, and why it’s an essential tool for penetration testers and security professionals. We’ll also walk through installation, basic usage, and provide examples of common scenarios where Gobuster shines.

What is Gobuster?

Gobuster is an open-source, command-line tool written in Go, designed for brute-forcing URLs (directories and files) and DNS subdomains. It's known for its speed and versatility, making it a favorite in the offensive security community.

Key Features:

  • Fast and Efficient: Utilizes Go's concurrency model to handle large wordlists without significant performance hits.

  • Versatile Protocol Support: Works with HTTP, HTTPS, and DNS.

  • Customizable Options: Supports custom headers, filters, and various brute-forcing strategies.

  • Output Management: Easily save and filter results.

Why Use Gobuster?

  • Speed: Thanks to its Go foundation, Gobuster can quickly handle large-scale wordlist attacks.

  • Flexibility: Whether you’re looking for hidden directories on a web server or subdomains within a domain, Gobuster can do it.

  • Simplicity: Its straightforward command-line interface is user-friendly, even for beginners.

  • Effectiveness: Quickly identifies potential entry points that could be missed by other tools.

Installation Guide

Installing Gobuster is straightforward. You’ll need to have Go installed on your system. Follow these steps to get Gobuster up and running:

  1. Install Go: Download and install Go from the official site.

  2. Install Gobuster:

     bashCopy codego install github.com/OJ/gobuster/v3@latest
    
  3. Verify Installation:

     bashCopy codegobuster -h
    

    This command should display the help menu, confirming Gobuster is installed correctly.

Basic Usage

Gobuster supports several modes of operation. Let’s explore the primary ones: directory/file brute-forcing and DNS subdomain enumeration.

1. Directory and File Brute-Forcing

This mode helps find hidden directories and files on a web server.

Command Example:

bashCopy codegobuster dir -u http://example.com -w /path/to/wordlist.txt -o results.txt -t 50

Explanation:

  • -u: The URL to target.

  • -w: Path to your wordlist file.

  • -o: Output file to save results.

  • -t: Number of concurrent threads (higher numbers can increase speed but also load on the server).

Common Use Case: Discovering hidden admin panels, backup files, or sensitive directories that aren’t linked from the main website.

2. DNS Subdomain Enumeration

This mode is used to find subdomains of a target domain by brute-forcing with a wordlist.

Command Example:

bashCopy codegobuster dns -d example.com -w /path/to/wordlist.txt -o dns_results.txt

Explanation:

  • -d: Domain to target.

  • -w: Path to your wordlist.

  • -o: Output file to save results.

Common Use Case: Uncovering subdomains that may host different parts of an organization’s infrastructure, potentially with weaker security.

Advanced Options

Gobuster offers several advanced options to refine your scans and manage the results more effectively:

  • Custom Headers: Use -H to add custom headers, which can be useful for bypassing WAFs or providing authentication tokens.

      bashCopy codegobuster dir -u http://example.com -w /path/to/wordlist.txt -H "Authorization: Bearer <token>"
    
  • Status Code Filters: Use -s to filter results by HTTP status codes.

      bashCopy codegobuster dir -u http://example.com -w /path/to/wordlist.txt -s "200,204,301,302"
    
  • Timeout Settings: Use -to to set request timeouts, which can be critical in slow or unstable network environments.

      bashCopy codegobuster dir -u http://example.com -w /path/to/wordlist.txt -to 5s
    

Practical Examples

To illustrate Gobuster’s power, let’s look at a couple of practical scenarios:

Example 1: Finding Hidden Web Directories

Imagine you’re conducting a security assessment of a web application. You want to ensure there are no exposed directories that could be accessed by unauthorized users.

Command:

bashCopy codegobuster dir -u http://targetsite.com -w /usr/share/wordlists/dirb/common.txt -o hidden_dirs.txt -t 100

Output:

bashCopy code/admin                 (Status: 200)
/backup                (Status: 403)
/old_site              (Status: 301)
/secret                (Status: 200)

Result: You’ve discovered potentially sensitive directories that need further investigation or securing.

Example 2: Discovering Subdomains

You’re tasked with finding all active subdomains of a company’s domain, which could reveal overlooked security risks.

Command:

bashCopy codegobuster dns -d company.com -w /usr/share/wordlists/dns/subdomains-top1million-5000.txt -o subdomains.txt

Output:

Copy codewww.company.com
api.company.com
dev.company.com
test.company.com

Result: You’ve identified several subdomains, including a development and a test environment, which might be less secure than the main site.

Conclusion

Gobuster is a powerful tool that enhances your ability to uncover hidden elements within web servers and domains. Whether you’re hunting for hidden directories, files, or subdomains, Gobuster provides a fast and effective solution.

By incorporating Gobuster into your penetration testing toolkit, you can gain deeper insights into the security posture of your targets, helping you to identify and address potential vulnerabilities before they are exploited by malicious actors.

Further Resources

  • Gobuster GitHub Repository: GitHub - OJ/gobuster

  • Wordlists: Commonly used wordlists for Gobuster can be found in repositories like SecLists.

Stay tuned for more posts on cybersecurity tools and techniques. If you have any questions or suggestions for future topics, feel free to reach out!

11
Subscribe to my newsletter

Read articles from Mahak Pandey directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Mahak Pandey
Mahak Pandey

Hey, I am currently a 4th year student majoring in Computer science & Information Technology. I have a strong academic background with coursework in software development, database management, Operating System, OOPS and cybersecurity, and I’ve maintained a CGPA of 9.28. I am proficient in Java, HTML, CSS, Figma, JavaScript, Learning React and core Knowledge Of MERN STack. Additionally, I have hands-on experience with version control systems like Git, and I am familiar with Visual studio code IDE, working experience with Blender for 3D modeling and rendering, Figma for UI design and Prototyping, Canva for Designing assets. Here to share knowledge i've learned and learning. I recently publish the "Cyber Security" Book as a Co-Author. I like to learn and build in public. If you want to connect with me do follow my socials.