DorkAgent

repository·main·Indexed 43 days ago

https://github.com/yee-yore/dorkagent

An LLM-powered agent for automated Google Dorking, designed for bug hunting and penetration testing workflows. It supports integration with search engines like Serper and SerpApi, and LLM providers including OpenAI, Anthropic, and Gemini. Requires Python 3.11.x.

Tokens
1.8K
Snippets
7
Records
8
Agent score
6%

What's inside DorkAgent

  1. Customize Google Search Result Count

    main

    You can modify the number of results returned by the search engine by editing the tool source files within your environment's site-packages.

    For Serper

    Locate serper_dev_tool.py inside site-packages/crewai_tools/tools/serper_dev_tool/ and update the n_results attribute (range: 10 to 100).

    For SerpApi

    Locate serpapi_google_search_tool.py inside site-packages/crewai_tools/tools/serpapi_tool/. By default, it only forwards q and location. You must manually add a "num" key to the client.search({...}) dictionary within the _run() method to control the result count.

    # Serper example (in serper_dev_tool.py)
    n_results: int = 10 # min: 10, max: 100
    
    # SerpApi example (in serpapi_google_search_tool.py)
    # Add 'num' to the search dict in _run()
    results = self.client.search({
        "q": kwargs.get("search_query"),
        "num": 50 
    }).as_dict()
  2. Use concise single-line docstrings

    main

    All functions, classes, and modules should include a single-line docstring that is concise and descriptive. Avoid multi-line docstrings unless necessary for complex logic, but the standard for DorkAgent is a single-line summary.

    def adjust_depth(target_domains, depth):
        """Adjust domain search depth based on specified depth level"""
        pass
    
    class DorkAgent:
        """Main agent class for Google Dorking operations"""
        pass
  3. Follow naming conventions for Python code

    main

    Use the following naming patterns to maintain consistency with the DorkAgent codebase:

    • Functions: Use snake_case (e.g., send_notification).
    • Variables: Use snake_case (e.g., target_domain).
    • Constants: Use UPPERCASE_WITH_UNDERSCORES (e.g., MAX_RETRIES).
    • Classes: Use PascalCase (e.g., DorkAgent).
    • Files: Use lowercase with underscores (e.g., dorkagent_cli.py).
    def send_notification(message):  # Good
    
    target_domain = "example.com"    # Good
    
    MAX_RETRIES = 3                  # Good
    
    class DorkAgent:                # Good
    
    # File: dorkagent_cli.py         # Good
  4. Install and Run DorkAgent

    main

    DorkAgent is an LLM-powered agent for automated Google Dorking. To set it up, clone the repository and run the main script. The program handles auto-installation of required packages on its first run.

    Prerequisites

    • Python 3.11.x (specifically 3.11.9 is recommended).
    • Note on Python versions: Using newer versions (like 3.13+) may cause installation failures for crewai dependencies (e.g., tiktoken) because prebuilt wheels are not yet available. If you encounter tiktoken build errors, downgrade to Python 3.11.x.
    git clone https://github.com/yee-yore/DorkAgent.git
    cd DorkAgent
    python dorkagent.py
  5. Configure Search Engines and LLM API Keys

    main

    When running dorkagent.py for the first time, you will be prompted to select a search engine and an LLM provider. The tool will automatically save your keys to a .env file.

    Required Search Engine Keys

    You must provide one of the following depending on your runtime choice:

    • SERPER_API_KEY: For Serper (obtain from serper.dev)
    • SERPAPI_API_KEY: For SerpApi (obtain from serpapi.com)

    Required LLM Keys

    You must provide at least one LLM API key:

    • OPENAI_API_KEY: For OpenAI models (GPT-4, GPT-5, etc.)
    • ANTHROPIC_API_KEY: For Claude models
    • GEMINI_API_KEY: For Gemini models
  6. Follow Python import order conventions

    main

    When adding imports to the DorkAgent project, organize them into three distinct groups in the following order:

    1. Standard library imports.
    2. Third-party library imports (e.g., crewai, langchain_openai, dotenv).
    3. Local modules from the project itself.

    Each group should be separated by a newline.

    # 1. Standard library
    import sys, re, os, pyfiglet
    from datetime import datetime
    
    # 2. Third-party libraries
    from dotenv import load_dotenv
    from crewai import Crew, LLM, Task, Agent
    from langchain_openai import ChatOpenAI
    from termcolor import colored
    from prompt_toolkit import prompt
    from prompt_toolkit.completion import PathCompleter
    from crewai_tools import SerperDevTool, ScrapeWebsiteTool
    
    # 3. Local modules
    from local_module import function
  7. Customize Search Result Duration (tbs parameter)

    main

    To limit search results to a specific timeframe (e.g., the past week or month), use the tbs parameter in the search engine tools.

    For Serper

    In serper_dev_tool.py, modify the payload in _make_api_request using the tbs key:

    • qdr:w: Past week
    • qdr:m: Past month

    For SerpApi

    In serpapi_google_search_tool.py, add the "tbs" key to the client.search({...}) dictionary in the _run() method.

    # Serper payload example
    payload = json.dumps({"q": search_query, "num": self.n_results, "tbs": "qdr:m"})
    
    # SerpApi search dict example
    results = self.client.search({
        "q": kwargs.get("search_query"),
        "location": kwargs.get("location"),
        "tbs": "qdr:m",
    }).as_dict()
  8. Apply standard code formatting

    main

    Ensure proper spacing around operators and after colons. Avoid collapsing multiple statements onto a single line or omitting spaces in assignments.

    # Good example
    def verify_api_key(llm_type):
        """Verify API key validity"""
        required_keys = ["SERPER_API_KEY"]
    
        if llm_type == "openai":
            required_keys.append("OPENAI_API_KEY")
    
        return required_keys
    
    # Bad example
    def verify_api_key(llm_type):
        required_keys=["SERPER_API_KEY"]
        if llm_type=="openai": required_keys.append("OPENAI_API_KEY")
        return required_keys