# r0oth3x49/ghauri architecture

> Architecture diagram of the GitHub repository r0oth3x49/ghauri, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/r0oth3x49/ghauri
- Repository: https://github.com/r0oth3x49/ghauri

## Overview

##### Project Type and Purpose
- This is a security tool focused on SQL injection detection and exploitation.
- Its primary role is to automate testing against various DBMS backends (e.g., MySQL, MSSQL, Postgres, Oracle) by sending crafted HTTP requests and analyzing responses.
- The README lists a wide range of features and injection techniques, clearly showing it’s a feature-rich command-line security application.

##### File Structure and Extract Main Architectural Components
- The project is organized within a “ghauri” directory that houses multiple sub-modules:
- “core” module: Encompasses primary functions like extraction, injection, sending requests, testing, and updating. This drives the core exploitation logic.
- “dbms” module: Focused on fingerprinting the target database management systems to determine specifics (e.g., probably based on response signatures).
- “extractor” module: Likely contains more advanced or specialized routines for payload extraction and additional intelligence gathering (both “advance.py” and “common.py”).
- “scripts” module: Contains a command-line interface (CLI) script which acts as an entry point for the end user.
- There are also configuration files like setup.py and requirements.txt which signal that the project is built as a Python package.

##### Architectural Relationships and Data Flow
- The entry point (likely the “ghauri/ghauri.py” or “scripts/ghauri.py”) accepts command-line parameters and parses the user’s input.
- User input then flows into the core processing functions – the “core” module which orchestrates:
- Preparation of HTTP requests (using the “core/request.py”).
- Payload injection (via “core/inject.py”).
- Extraction of data from the response (handled in “core/extract.py” and further supplemented by the “extractor” module).
- The “common” directory provides support functions (configuration, utility functions, payload definitions, table formatting for output, session handling for storing state, etc.), which are used by almost every other module.
- The “dbms” module takes the parsed HTTP responses, analyzes them for DBMS-specific indicators and fingerprints the possible back-end system.
- Logging (via “logger/colored_logger.py”) records all events for debugging/info purposes.
- The flow is iterative: the tool may resume, flush sessions, or update its execution strategies based on feedback from previous requests. There’s also support for updating itself through a built-in update mechanism (in “core/update.py”).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Command-Line Layer"
        CLI["CLI Interface"]:::cli
    end

    subgraph "Core Processing"
        CORE["Core Engine (Injection, HTTP, Extraction & Update)"]:::core
    end

    subgraph "Support Modules"
        COMMON["Common Utilities (Configs, Payloads, Utils)"]:::utility
        DBMS["DBMS Fingerprinting"]:::dbms
        ADV["Advanced Extraction"]:::advanced
        LOGGER["Logger Module"]:::logger
    end

    CLI -->|"processes input"| CORE
    CORE -->|"utilizes"| COMMON
    CORE -->|"fingerprints target"| DBMS
    CORE -->|"performs extraction"| ADV
    CORE -->|"logs events to"| LOGGER

    click CLI "https://github.com/r0oth3x49/ghauri/blob/main/ghauri/scripts/ghauri.py"
    click CORE "https://github.com/r0oth3x49/ghauri/tree/main/ghauri/core"
    click COMMON "https://github.com/r0oth3x49/ghauri/tree/main/ghauri/common"
    click DBMS "https://github.com/r0oth3x49/ghauri/blob/main/ghauri/dbms/fingerprint.py"
    click ADV "https://github.com/r0oth3x49/ghauri/tree/main/ghauri/extractor"
    click LOGGER "https://github.com/r0oth3x49/ghauri/blob/main/ghauri/logger/colored_logger.py"

    classDef cli fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef utility fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef dbms fill:#FFFF66,stroke:#000,stroke-width:2px;
    classDef advanced fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef logger fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
