# wangyihang/githacker architecture

> Architecture diagram of the GitHub repository wangyihang/githacker, 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/wangyihang/githacker
- Repository: https://github.com/wangyihang/githacker

## Overview

##### Main Components
- Command-line Interface (CLI) Layer: This is how users interact with GitHacker. It includes both direct invocation (via “githacker --help”, etc.) and Docker-based usage.
- Core Exploitation Engine:
– Multi-thread Manager: Orchestrates the concurrent downloading of repository files.
– Network / HTTP Client: Responsible for sending requests, handling responses, and brute forcing file names when directory listings are unavailable.
– Vulnerability Exploitation Logic: Implements the logic needed to detect and download various git objects (source files, commit logs, branches, remotes, etc.).
- Utilities & Helper Modules:
– Modules in “utils” (diff.py, gen.py, test.py): Aid in generating test repositories, comparing results, and automating tests.
- Testing Infrastructure:
– “test/docker” subdirectories: Include Docker Compose files and web server configuration (Apache/Nginx) setups, which simulate environments for verifying correct exploitation.
- Output/Reporting:
– “templates” directory: Contains HTML templates for result output.
– File system-based output folder (as configured by the user via the “--output-folder” parameter).
- Deployment Environment:
– Docker: The provided Dockerfile and documented recommended Docker usage indicate an isolated, disposable runtime environment emphasizing security.

##### Relationships and Interactions
- User Input ⇨ CLI: The user issues commands which trigger GitHacker’s operations.
- CLI ⇨ Core Exploitation Engine: Commands route through a main controller that initializes multi-threading and network tasks.
- Multi-thread Manager ⇨ HTTP Client Module: Initiates parallel HTTP requests to retrieve git objects from the target URL.
- Exploitation Logic ⇨ File Downloader: Processes responses and saves files locally (or inside the Docker container’s volume mount) while following the Git repository layout.
- Utilities ⇨ Test & Verification Flow: Testing scripts simulate exploitation on locally configured Docker environments and help in drawing comparisons with expected outputs via diff analysis.
- Core Modules ⇨ Output Handler: The processed results (e.g., downloaded git data) are formatted using the templates and stored/reported in the user-specified output folder.

##### Architectural Patterns and Design Principles
- Modularity: The structure is clearly divided into the core functional GitHacker module, utility scripts, and testing configurations.
- Separation of Concerns: There is a clear split between the exploitation logic, I/O utilities, and the testing components.
- Multi-threading: Concurrency is a key design principle, enabling the tool to quickly download large numbers of files.
- Containerization: Emphasis on Docker for safe execution indicates the design considers isolation and security.

##### Relevant Technologies and Frameworks
- Python 3: Core language.
- Git (as an external dependency) for repository interactions.
- Docker & docker-compose: To simulate environments and secure execution.
- Utility libraries as specified in “requirements.txt” (though not explicitly listed, they support HTTP requests, threading, etc.).

##### Detail and Clarity
- Be as detailed as possible: Do not simply lump everything together. Each component (e.g., “HTTP Client” or “Brute-force Module”) should be represented separately if they provide distinct functionality.
- Interdependencies: For instance, demonstrate how the multi-threaded architecture accelerates requests and the importance of safe execution via Docker.

## Diagram (Mermaid)

```mermaid
graph TD
  subgraph "CLI Layer"
    CLI["User/CLI Interface"]:::cli
  end

  subgraph "Controller"
    MC["Main Controller"]:::core
  end

  subgraph "Core Exploitation Engine"
    MTM["Multi-thread Manager"]:::core
    HTTP["HTTP Client / Network Module"]:::core
    EL["Exploitation Logic"]:::core
    FD["File Downloader & Output Handler"]:::core
  end

  subgraph "Output & Reporting"
    TR["Templates/Reporting"]:::output
  end

  subgraph "Utilities & Helper Modules"
    DIFF["diff.py"]:::utility
    GEN["gen.py"]:::utility
    TEST["test.py"]:::utility
  end

  subgraph "Testing Infrastructure"
    APACHE["Apache Test Env"]:::testing
    NGINX["Nginx Test Env"]:::testing
    PHP["PHP LFI Test Env"]:::testing
  end

  subgraph "Deployment Environment"
    DOCKER["Docker Environment (Containerized Execution)"]:::deployment
    DC["Docker Compose"]:::deployment
  end

  %% Connections
  CLI -->|"triggers"| MC
  MC -->|"initiates"| MTM
  MTM -->|"sends_requests"| HTTP
  HTTP -->|"handles_responses"| EL
  EL -->|"downloads_files"| FD
  FD -->|"formats_results"| TR

  MC -->|"uses_docker"| DOCKER
  DOCKER -->|"includes_compose"| DC

  DIFF -->|"verifies_results"| APACHE
  GEN  -->|"simulates_env"| NGINX
  TEST -->|"compares_output"| PHP
  TEST -->|"compares_output"| TR

  %% Styles
  classDef cli fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
  classDef core fill:#ccffcc,stroke:#008800,stroke-width:2px;
  classDef utility fill:#ccccff,stroke:#0000cc,stroke-width:2px;
  classDef testing fill:#ffffcc,stroke:#cccc00,stroke-width:2px;
  classDef output fill:#ccffff,stroke:#00cccc,stroke-width:2px;
  classDef deployment fill:#ffccff,stroke:#cc00cc,stroke-width:2px;

  %% Click Events
  click CLI "https://github.com/wangyihang/githacker/blob/master/GitHacker/__init__.py"
  click MTM "https://github.com/wangyihang/githacker/blob/master/GitHacker/__init__.py"
  click DIFF "https://github.com/wangyihang/githacker/blob/master/utils/diff.py"
  click GEN "https://github.com/wangyihang/githacker/blob/master/utils/gen.py"
  click TEST "https://github.com/wangyihang/githacker/blob/master/utils/test.py"
  click APACHE "https://github.com/wangyihang/githacker/tree/master/test/docker/apache-index-disabled"
  click NGINX "https://github.com/wangyihang/githacker/tree/master/test/docker/nginx-index-enabled"
  click PHP "https://github.com/wangyihang/githacker/tree/master/test/docker/php-lfi"
  click TR "https://github.com/wangyihang/githacker/blob/master/templates/index.html"
  click DOCKER "https://github.com/wangyihang/githacker/tree/master/Dockerfile"
  click DC "https://github.com/wangyihang/githacker/blob/master/test/docker/docker-compose.yml"
```
