# kyleavery/aceldr architecture

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

- Interactive diagram: https://gitdiagram.com/kyleavery/aceldr
- Repository: https://github.com/kyleavery/aceldr

## Overview

##### Main Components

a) Core Loader Components:
- Independent Code Module (src/ace.c)
- Assembly Components (src/asm/)
- Hook Management System (src/hooks/)
- Memory Management and Utilities (src/util.c)

b) Integration Components:
- Cobalt Strike Integration (bin/AceLdr.cna)
- Profile Configuration (example.profile)
- Support Scripts (scripts/)

##### Key Architectural Elements

Layer 1 - Integration Layer:
**[Cobalt Strike Interface (AceLdr.cna)] --> [Profile Configuration]**

Layer 2 - Core Loader Layer:
**[Position Independent Code]**
- ↓
**[Memory Management & Encryption]**
- ↓
**[Hook Management System]**

Layer 3 - System Interaction Layer:
**[Assembly Components] <--> [WinAPI Hooks]**

##### Specific Features to Highlight

Create dedicated sections showing:

a) Memory Protection Mechanisms:
- Dynamic Memory Encryption Flow
- Heap Management (hooks/heap.c)
- Return Address Spoofing (src/retaddr.c)

b) Execution Flow:
- Sleep Obfuscation (hooks/delay.c)
- Code Encryption (FOLIAGE implementation)
- RC4 Encryption using SystemFunction032

##### Component Relationships

Key interactions:
**[Cobalt Strike] ←→ [AceLdr Loader]**
- ↓
**[Memory Management]**
- ↓
**[Hook System] ←→ [WinAPI]**
- ↓
**[Assembly Components]**

##### Important Details

a) Security Features:
- Memory encryption/decryption flows
- Return address spoofing paths
- Sleep obfuscation mechanism

b) Integration Points:
- Cobalt Strike shellcode generation
- Profile configuration
- Support script functionality

##### Technical Specifications

- Supported Windows APIs
- Memory protection mechanisms
- Encryption algorithms (RC4)
- Hook points (InternetConnectA, NtWaitForSingleObject, RtlAllocateHeap)

Remember to emphasize the security-focused nature of the project by highlighting the various evasion techniques and their interaction points with the Windows API and memory management system.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Integration
        CS[Cobalt Strike Interface]
        PC[Profile Configuration]
        CS --> PC
    end

    subgraph Core_Loader
        PIC[Position Independent Code]
        MME[Memory Management & Encryption]
        HMS[Hook Management System]
        PIC --> MME
        MME --> HMS
    end

    subgraph System_Interaction
        AC[Assembly Components]
        WH[WinAPI Hooks]
        AC <--> WH
    end

    subgraph Security_Features
        ME[Memory Encryption]
        RAS[Return Address Spoofing]
        SO[Sleep Obfuscation]
    end

    subgraph Technical_Specs["Technical Specifications"]
        direction TB
        WA["Windows APIs"]
        MP["Memory Protection"]
        EA["RC4 Encryption"]
        HP["Hook Points:
        - InternetConnectA
        - NtWaitForSingleObject
        - RtlAllocateHeap"]
    end

    Integration --> Core_Loader
    Core_Loader --> System_Interaction
    HMS --> Security_Features
    WH --> Security_Features

    classDef default fill:#f9f9f9,stroke:#333,stroke-width:1px
    classDef security fill:#ffebee,stroke:#c62828,stroke-width:2px
    classDef core fill:#e3f2fd,stroke:#1565c0,stroke-width:2px
    classDef integration fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px
    classDef specs fill:#fff3e0,stroke:#ef6c00,stroke-width:1px

    class ME,RAS,SO security
    class PIC,MME,HMS core
    class CS,PC integration
    class WA,MP,EA,HP specs

    click PIC "https://github.com/kyleavery/AceLdr/blob/main/src/ace.c"
    click AC "https://github.com/kyleavery/AceLdr/tree/main/src/asm/"
    click HMS "https://github.com/kyleavery/AceLdr/tree/main/src/hooks/"
    click MME "https://github.com/kyleavery/AceLdr/blob/main/src/util.c"
    click RAS "https://github.com/kyleavery/AceLdr/blob/main/src/retaddr.c"
    click CS "https://github.com/kyleavery/AceLdr/blob/main/bin/AceLdr.cna"
    click PC "https://github.com/kyleavery/AceLdr/blob/main/example.profile"
    click SO "https://github.com/kyleavery/AceLdr/blob/main/src/hooks/delay.c"

    %% Legend
    subgraph Legend
        S1[Security Components]:::security
        C1[Core Components]:::core
        I1[Integration Points]:::integration
        T1[Technical Specifications]:::specs
    end
```
