cyber-evangelists / go-google-dork

0 stars 0 forks source link

Develop Go Command Line Application for Google Dorking Automation #1

Closed husnain-ce closed 3 months ago

husnain-ce commented 3 months ago

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

  1. Search Queries: Accept dork queries as input.
  2. Execution: Perform Google searches using the provided dork queries.
  3. Result Handling: Parse and display search results.
  4. Error Handling: Implement proper error handling for network requests and search parsing.
  5. Rate Limiting: Ensure compliance with Google's TOS by implementing rate limiting.

Detailed Steps

  1. 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
  2. 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
  3. 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)
        }
    }
  4. 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
    }
  5. 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
    }
  6. Run the Application:

    • Build and run the application to perform Google Dorking.
    go run main.go "intitle:\"index of\""

Submission Guidelines

HamzaSajjad141 commented 3 months ago

Issue Resolved .

Check the source code : https://github.com/HamzaSajjad141/Web-Dorking

HamzaSajjad141 commented 3 months ago

Pushed sir !!

husnain-ce commented 3 months ago

Good work!