Create a Go-based command-line tool to automate Google Dorking inspired by the functionality of the evildork repository. This tool will search Google for specific dork queries and return relevant information.
Requirements
Search Queries: Accept dork queries as input.
Execution: Perform Google searches using the provided dork queries.
Result Handling: Parse and display search results.
Error Handling: Implement proper error handling for network requests and search parsing.
Rate Limiting: Ensure compliance with Google's TOS by implementing rate limiting.
Detailed Steps
Set Up the Project:
Initialize a new Go module.
Create necessary files and directories.
mkdir google-dorking
cd google-dorking
go mod init google-dorking
Install Required Packages:
Use goquery for HTML parsing and colly for web scraping.
go get -u github.com/PuerkitoBio/goquery
go get -u github.com/gocolly/colly
Define Main Function:
Create a main function to accept dork queries and initiate the search.
package main
import (
"fmt"
"os"
"time"
"github.com/gocolly/colly"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: go run main.go <dork-query>")
return
}
dork := os.Args[1]
fmt.Printf("Executing Google Dork: %s\n", dork)
results, err := performGoogleDork(dork)
if err != nil {
fmt.Printf("Error: %v\n", err)
return
}
for _, result := range results {
fmt.Println(result)
}
}
Perform Google Dork:
Implement the performGoogleDork function to perform Google search and retrieve results.
package main
import (
"fmt"
"github.com/gocolly/colly"
)
func performGoogleDork(dork string) ([]string, error) {
var results []string
c := colly.NewCollector()
c.OnHTML("h3", func(e *colly.HTMLElement) {
title := e.Text
link := e.ChildAttr("a", "href")
if link != "" {
results = append(results, fmt.Sprintf("%s - %s", title, link))
}
})
searchURL := fmt.Sprintf("https://www.google.com/search?q=%s", dork)
err := c.Visit(searchURL)
if err != nil {
return nil, err
}
// Rate limiting to avoid being blocked by Google
time.Sleep(2 * time.Second)
return results, nil
}
Error Handling and Rate Limiting:
Implement proper error handling and rate limiting to comply with Google’s TOS.
package main
import (
"errors"
"fmt"
"net/url"
"time"
"github.com/gocolly/colly"
)
func performGoogleDork(dork string) ([]string, error) {
var results []string
c := colly.NewCollector(
colly.AllowedDomains("www.google.com", "google.com"),
colly.UserAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36"),
)
c.OnHTML("h3", func(e *colly.HTMLElement) {
title := e.Text
link := e.ChildAttr("a", "href")
parsedURL, err := url.Parse(link)
if err == nil && parsedURL.Host != "" {
results = append(results, fmt.Sprintf("%s - %s", title, link))
}
})
searchURL := fmt.Sprintf("https://www.google.com/search?q=%s", url.QueryEscape(dork))
err := c.Visit(searchURL)
if err != nil {
return nil, err
}
// Rate limiting to avoid being blocked by Google
time.Sleep(5 * time.Second)
if len(results) == 0 {
return nil, errors.New("no results found or blocked by Google")
}
return results, nil
}
Run the Application:
Build and run the application to perform Google Dorking.
go run main.go "intitle:\"index of\""
Submission Guidelines
Push the complete source code in a GitHub repository.
Include a README file with instructions on how to install and run the application.
Objective
Create a Go-based command-line tool to automate Google Dorking inspired by the functionality of the evildork repository. This tool will search Google for specific dork queries and return relevant information.
Requirements
Detailed Steps
Set Up the Project:
Install Required Packages:
goquery
for HTML parsing andcolly
for web scraping.Define Main Function:
Perform Google Dork:
performGoogleDork
function to perform Google search and retrieve results.Error Handling and Rate Limiting:
Run the Application:
Submission Guidelines