# oni-kuki/rc-obfuscator architecture

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

- Interactive diagram: https://gitdiagram.com/oni-kuki/rc-obfuscator
- Repository: https://github.com/oni-kuki/rc-obfuscator

## Overview

##### Project Overview
- Purpose: To obfuscate binary shellcode by injecting it into resource files (ICO or Bitmap) and subsequently loading the payload using the ntmapViewOfSection technique.
- Modes: There are two primary modes – one for ICO conversion and one for Bitmap injection. Both methods include a “service” variant to manage payload run/start/stop using the Windows service interface.

##### Main Components
a. Shellcode Payload Input:
- The project expects a binary shellcode file as the initial input.
b. ICO Processing Module:
- Conversion of binary data into an ICO file:
- Core Files: Ico/Ico/Ico.cpp and supporting header (Ico/Ico/Native.h)
- Conversion Helper: Ico/Iconvert.cpp
- Service Variant:
- Service Files: Ico/Service/IcoServ.cpp and Ico/Service/Native.h
c. Bitmap Processing Module:
- Bitmap Generation and Injection:
- Bitmap Creation: Bitmap/CreateBitmap.cpp
- Injection: Bitmap/BitmapInsert/BitmapInsert.cpp (to inject the payload into an existing or newly created bitmap)
- Resource Loader: Bitmap/Bitmap/BMP.cpp and Bitmap/Bitmap/Native.h
- Service Variant:
- Service Files: Bitmap/Service/BMPServ.cpp and Bitmap/Service/Native.h
d. Resource Loader Technique:
- Both methods rely on the ntmapViewOfSection technique to load the payload-embedded files.
e. External Assets and Documentation:
- Assets for demonstration (e.g., Images folder) and a README hosting usage examples and visual guides.
f. Operating System Service Interaction:
- The usage examples in the README (using sc create, sc start) indicate an integration with Windows service control.

##### Relationships and Interactions
- For both ICO and Bitmap modules, the flow starts with the shellcode file. From here:
- In the ICO flow, the payload is converted (using Iconvert or Ico.cpp), and there’s an option to manage it as a service via Ico/Service.
- In the Bitmap flow, the process first creates a Bitmap (via CreateBitmap), then injects the payload (via BitmapInsert), with an optional service layer provided in Bitmap/Service.
- Both flows eventually lead to loading the obfuscated resource with the ntmapViewOfSection method.

##### Architectural Patterns and Design Principles
- Modularity: The design naturally splits into two separate modules (ICO and Bitmap) that do not interfere with one another.
- Service Orientation: Both methods offer a service-based interface to manage execution.
- Clear Separation of Concerns: Resource file creation/injection and loading mechanisms are handled in different parts of the codebase.
- Reusability: The conversion/injection components are reusable in both standalone and service-oriented contexts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A("Shellcode Payload Input"):::input

    subgraph "ICO Module"
        direction TB
        B("ICO Conversion Helper"):::processing
        C("ICO Conversion Module"):::processing
        C1("ICO Conversion Module Header"):::processing
        D("ICO Service Variant"):::service
        D1("ICO Service Header"):::service
    end

    subgraph "Bitmap Module"
        direction TB
        E("Bitmap Creation Module"):::processing
        F("Bitmap Payload Injection Module"):::processing
        G("Bitmap Resource Loader"):::processing
        G1("Bitmap Loader Header"):::processing
        H("Bitmap Service Variant"):::service
        H1("Bitmap Service Header"):::service
    end

    I("Payload Loader: ntmapViewOfSection"):::external

    subgraph "External Assets & Documentation"
        direction TB
        K("Images Folder"):::external
        L("README Documentation"):::external
    end

    %% ICO Flow Connections
    A --> B
    B --> C
    C --> C1
    C --> I
    C --> D
    D --> D1
    D --> I

    %% Bitmap Flow Connections
    A --> E
    E --> F
    F --> G
    G --> G1
    G --> I
    F --> H
    H --> H1
    H --> I

    %% Click Events for ICO Module
    click B "https://github.com/oni-kuki/rc-obfuscator/blob/main/Ico/Iconvert.cpp"
    click C "https://github.com/oni-kuki/rc-obfuscator/blob/main/Ico/Ico/Ico.cpp"
    click C1 "https://github.com/oni-kuki/rc-obfuscator/blob/main/Ico/Ico/Native.h"
    click D "https://github.com/oni-kuki/rc-obfuscator/blob/main/Ico/Service/IcoServ.cpp"
    click D1 "https://github.com/oni-kuki/rc-obfuscator/blob/main/Ico/Service/Native.h"

    %% Click Events for Bitmap Module
    click E "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/CreateBitmap.cpp"
    click F "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/BitmapInsert/BitmapInsert.cpp"
    click G "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/Bitmap/BMP.cpp"
    click G1 "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/Bitmap/Native.h"
    click H "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/Service/BMPServ.cpp"
    click H1 "https://github.com/oni-kuki/rc-obfuscator/blob/main/Bitmap/Service/Native.h"

    %% Click Events for External Assets
    click K "https://github.com/oni-kuki/rc-obfuscator/tree/main/Images"
    click L "https://github.com/oni-kuki/rc-obfuscator/blob/main/README.md"

    %% Class Definitions for styling
    classDef input fill:#f9f,stroke:#333,stroke-width:1px;
    classDef processing fill:#bbf,stroke:#333,stroke-width:1px;
    classDef service fill:#fb9,stroke:#333,stroke-width:1px;
    classDef external fill:#cfc,stroke:#333,stroke-width:1px;
```
