# guitmz/ezuri architecture

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

- Interactive diagram: https://gitdiagram.com/guitmz/ezuri
- Repository: https://github.com/guitmz/ezuri

## Overview

##### Project Type and Purpose
- This project is a Linux ELF runtime crypter – essentially, it encrypts an ELF executable to obfuscate its content and then provides a loader (or “stub”) to decrypt and run it in memory.

##### Analyzing the File Structure
- Top-Level Go Files: Files such as ezuri.go, aes.go, and utils.go indicate that the core logic for encryption (likely AES-based, given the aes.go file) and utility functions is centralized in these modules.
- The “stub” directory: Contains a main.go file. This is likely the runtime stub that is either appended to the encrypted binary or provided as a separate component that handles decryption and execution.
- GitHub configuration: The .github directory and its workflow files suggest that continuous integration/delivery features exist, though these are peripheral to the runtime architecture.
- go.mod and LICENSE: Standard Go module and licensing files indicate the dependencies and project licensing, respectively.

##### Key Components
a. Input Component: (e.g., Original Linux ELF Binary) – The file that needs to be encrypted.
b. Core Crypter Module (ezuri.go): The main application that orchestrates the encryption process.
c. AES Encryption Module (aes.go): Handles cryptographic operations – an essential building block that performs the actual encryption.
d. Utility Functions (utils.go): Support functions that might manage file handling, argument parsing, or other operations.
e. Stub/Loader (stub/main.go): This component is responsible for the runtime decryption and execution. It “unpacks” the crypter’s output so that the encrypted ELF can be decrypted in memory and executed.
f. External Dependencies/References: Although not part of the code directly, reference links in the README (e.g., f0wl’s unpacker and related research) can be noted as external influences or complementary tools.

##### Relationships and Interactions
- A directional flow starting with the original executable entering the crypter.
- The crypter (ezuri.go) uses the AES logic (aes.go) and utility functions (utils.go) to encrypt the input.
- The output is either a self-contained binary that incorporates the “stub” or two separate bundled components (the encrypted payload and the stub loader).
- The stub then takes over at runtime: upon execution, it uses internal logic (mirroring the encryption in reverse) to decrypt the in-memory ELF and execute it.

##### Architectural Patterns/Principles
- Separation of concerns is clear between the encryption engine (core modules) and the runtime stub/loader.

##### Relevant Technologies and Frameworks
- Go Language: Highlight that all critical components are written in Go.
- AES Cryptography: The algorithm implemented in aes.go is key, so label that technological detail.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Input Component
    A["Original Linux ELF Binary"]:::input

    %% Encryption Process Subgraph
    subgraph "Encryption Process"
        E["Encryption Orchestrator (ezuri.go)"]:::crypter
        AES["AES Module (aes.go)"]:::encryption
        U["Utility Functions (utils.go)"]:::utility
    end

    %% Runtime Process Subgraph
    subgraph "Runtime Process"
        S["Runtime Stub/Loader (stub/main.go)"]:::stub
        D["Decrypted ELF Execution"]:::runtime
    end

    %% External Dependency
    X["External Unpacker/Research"]:::external

    %% Data Flow Connections
    A -->|"encrypts"| E
    E -->|"calls_AES"| AES
    E -->|"calls_Util"| U
    E -->|"binds_to"| S
    S -->|"decrypts"| D
    E -.->|"influencedBy"| X

    %% Click Events
    click E "https://github.com/guitmz/ezuri/blob/master/ezuri.go"
    click AES "https://github.com/guitmz/ezuri/blob/master/aes.go"
    click U "https://github.com/guitmz/ezuri/blob/master/utils.go"
    click S "https://github.com/guitmz/ezuri/blob/master/stub/main.go"

    %% Styles
    classDef input fill:#ffebcc,stroke:#333,stroke-width:2px;
    classDef crypter fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef encryption fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef utility fill:#ccffcc,stroke:#333,stroke-width:2px;
    classDef stub fill:#ccccff,stroke:#333,stroke-width:2px;
    classDef runtime fill:#e6e6fa,stroke:#333,stroke-width:2px;
    classDef external fill:#f0e68c,stroke:#333,stroke-width:2px;
```
