Skip to content

Bostigger/subdomain-scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

subdomain scanner

20230829_154940.mp4

This is the overview of the architecture behind the subdomain fetching tool. The service is primarily built in Go with a React frontend. It interfaces with crt.sh to retrieve potential subdomains for a given domain and ensures uniqueness before presenting the results to the user.

Components:

  • Main function: Entry point of the project.
  • godotenv package: Loads assigned port from .env
  • Mux package: Used for routing and setting up the server.
  • Handler Functions:
    • Main handler (/{domain}): To capture and route the domain requests.
    • subDomainHandler: Processes the domain from the URL and passes it onward.
  • GetDomainList function: Contacts crt.sh to get subdomain list.
  • crtResponse struct: Structure for holding response from crt.sh.
  • Unique subdomain map: Ensures uniqueness of subdomains.
  • React Frontend: Provides UI to the user.
  • Middleware: Enables CORS to allow React frontend to communicate with the backend.

Flow:

  • Program starts and enters the Main function.
  • Mux sets the .env port and the /{domain} handler function.
  • On a request, the handler function invokes subDomainHandler.
  • subDomainHandler captures the domain from the URL and sends it to GetDomainList.
  • GetDomainList contacts crt.sh and gets the subdomain list.
  • The response from crt.sh is decoded into the crtResponse array.
  • To ensure uniqueness, a loop checks the crtResponse array against a map and only unique values are added to a new array.
  • The unique subdomain list is returned as a string array to subDomainHandler.
  • subDomainHandler encodes the response as JSON.
  • React frontend allows users to input domain and see results.

Detailed Flow:

  1. Entry Point (Main function): The service begins its execution here. Routing and server setup are configured via the Mux package and the .env is loaded
  2. Server Setup with Mux: Mux initializes the .env port for the server and sets up route handlers.
  3. Domain Request Handling: When a user inputs a domain in the React frontend, a request is sent to the go server, which gets routed to the subDomainHandler function via the /{domain} endpoint.
  4. Fetching Subdomains: The domain from the request is captured and sent to the GetDomainList function, which contacts crt.sh to retrieve all subdomains associated with that domain.
  5. Decoding and Ensuring Uniqueness: The response from crt.sh is decoded into an array of type crtResponse. To ensure that the subdomains are unique, a map is utilized. As we iterate over the crtResponse array, any new and unique subdomains are added to a separate array.
  6. Response Preparation: The list of unique subdomains is converted into a JSON response and sent back to the React frontend.
  7. Displaying Results: The React frontend processes the JSON response and displays the unique subdomains to the user.
  8. CORS: To ensure smooth communication between our frontend and backend, a middleware named EnableCors has been added. This allows the React app to fetch data from our backend without CORS-related issues.

Visual Architecture:

project-image


🛠️ Installation Steps:

1. Clone the project

git cone git@github.com:Bostigger/subdomain-scanner.git

2. Navigate into the cloned folder

cd subdomain-scanner

3. Install the required go packages

go mod tidy

4. Setup your .env with the port variable

PORT="eg.8000"

5. Build the project

go build main.go

6. Run the main.go file

go run main.go

7. Navigate into the web directory

cd web

8. Install necessary packages

npm install

9. Run the react frontend

npm start

10. All set!

Happy hacking...

💻 Built with

Technologies used in the project:

  • Golang
  • React
  • Tailwind css

About

A tool that enumerates subdomains written in Go and React front end

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors