# whitecat18/rust-for-malware-development architecture

> Architecture diagram of the GitHub repository whitecat18/rust-for-malware-development, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/whitecat18/rust-for-malware-development
- Repository: https://github.com/whitecat18/rust-for-malware-development

## Overview

##### Project Type & Purpose
- Type: An open-source collection of Rust Proof-of-Concepts (PoCs) for malware techniques, encryption methods, evasion, reverse shells, etc.
- Purpose: Provide red-teamers and researchers with standalone Rust crates demonstrating Windows-specific attack/injection/encryption techniques.

##### File Structure
- Root contains:
– Documentation: README.md, deps.md, CLEAN.md, docker.md
– Cross-compile container: Dockerfile
– Top-level folders, each housing one or more independent Cargo projects:
· Malware Techniques (e.g., Process-Injection, Process, Persistence, Evasion, BSOD, Keyloggers…)
· Encryption Methods
· Syscalls (direct, indirect, parallel, TartarusGate, RecycledGate)
· Enumeration, Dynamic_Resolver, Api_Hooking, Named_Pipe, Reverse Shell, etc.
- Each folder is a standalone Rust crate with its own Cargo.toml and src/.

##### Readme Insights
- Categorization: “Malware Techniques” vs “Encryption Techniques”
- Build process: compile per-crate with Cargo; optional Docker for cross-compilation; clean command via CLEAN.md.
- Dependencies: windows-rs, winapi, ntapi, custom assembly (.asm) for syscalls/trampolines.
- Interaction examples: Named pipe client/server, reverse-shell client/server, GitHub-API stealer.

##### Components & Interactions to Capture
a. Main Components
– Monorepo (Git)
– Category Groups (Malware Techniques, Encryption, Syscalls, Enumeration, etc.)
– Individual Crates (standalone Cargo projects)
– Build System (Cargo CLI, optional Docker container)
– External Dependencies (crates.io; GitHub repos for windows-rs, ntapi, etc.)
– Interactive Modules:
- Reverse Shell client ↔ server (TCP)
- Named Pipe client ↔ server (Windows IPC)
- GitHub API stealer ↔ GitHub service
b. Relationships & Data Flow
– Developer pulls the Git monorepo → runs `cargo build` per crate
– Optionally spins up Docker (via Dockerfile) for cross-compilation
– Crates import common Windows-API crates (windows-rs, ntapi)
– Interactive modules communicate over network or named pipes
c. Architectural Patterns
– Monolithic monorepo of micro-crates (no shared workspace manifest)
– One crate = one PoC executable or library
– Heavy use of low-level Windows API (dynamic resolver, direct syscalls)
d. Key Technologies
– Rust toolchain & Cargo
– WinAPI bindings (windows-rs, winapi-rs, ntapi)
– Inline assembly (.asm) for syscall stubs
– Docker for cross-compile (Dockerfile)
– Documentation scripts (deps.md, CLEAN.md)

##### Detailed Architectural Elements
– Monorepo Root
- README.md, Dockerfile, deps.md, CLEAN.md
– Build System
- Cargo (per-crate)
- Docker container (for cross-compile)
– Repo Categories
- Malware Techniques
- Process-Injection
- GhostingProcess
- Persistence/PPid_spoofing
- WaitingThreadHijacking
- …etc.
- Encryption Methods
- Aes_Encryption
- Khufu_encryption
- ecc_shellcode_exec
- payload_shuffling
- …etc.
- Syscalls
- direct_syscalls
- indirect_syscalls (rust_syscalls lib)
- parallel_syscalls
- TartarusGate
- RecycledGate
- Interactive Demos
- Reverse Shell: rev_shell (client), rev_receive (server)
- Named Pipe: pipe_client, pipe_server
- GitHub API stealer: stealer/GitHub_API
– External Crate Dependencies
- windows-rs, winapi-rs, ntapi, janoglezcampos/rust_syscalls, etc.

- The monorepo’s hierarchical layout
- Independent crate boundaries
- Build and packaging pipeline
- Network/IPC interactions for multi-component demos
- External dependency flows

## Diagram (Mermaid)

```mermaid
flowchart TD
    Developer["Developer"]:::actor
    Developer -->|"clones"| Monorepo["Monorepo Root"]:::external

    subgraph "Monorepo Root"
        README["README.md"]
        Dockerfile["Dockerfile"]
        DepsDoc["deps.md"]
        CleanDoc["CLEAN.md"]
    end
    Monorepo --> README
    Monorepo --> Dockerfile
    Monorepo --> DepsDoc
    Monorepo --> CleanDoc

    subgraph "Build System"
        Cargo["Cargo CLI"]:::build
        DockerCont["Docker Container"]:::build
    end
    Monorepo --> Cargo
    Monorepo --> DockerCont
    Cargo -->|"build crates"| Binaries["Binary Artifacts"]:::build
    DockerCont -->|"cross-compile"| Binaries

    subgraph "Category: Malware Techniques"
        PI["Process-Injection"]:::malwareTech
        Ghosting["GhostingProcess"]:::malwareTech
        PersistenceDir["Persistence"]:::malwareTech
        Evasion["Evasion"]:::malwareTech
        BSOD["BSOD"]:::malwareTech
        Keyloggers["Keyloggers"]:::malwareTech
        DLLInj["DLL_Injector"]:::malwareTech
    end
    Monorepo --> PI
    Monorepo --> Ghosting
    Monorepo --> PersistenceDir
    Monorepo --> Evasion
    Monorepo --> BSOD
    Monorepo --> Keyloggers
    Monorepo --> DLLInj

    subgraph "Category: Encryption Methods"
        Aes["Aes_Encryption"]:::encrypt
        Khufu["Khufu_encryption"]:::encrypt
        Madryga["Madryga_encryption"]:::encrypt
        SysFunc["SystemFunction032_033"]:::encrypt
        Camellia["camellia_cipher"]:::encrypt
        ECC["ecc_shellcode_exec"]:::encrypt
        Payload["payload_shuffling"]:::encrypt
    end
    Monorepo --> Aes
    Monorepo --> Khufu
    Monorepo --> Madryga
    Monorepo --> SysFunc
    Monorepo --> Camellia
    Monorepo --> ECC
    Monorepo --> Payload

    subgraph "Category: Syscalls"
        direct["direct_syscalls"]:::syscalls
        indirect["indirect_syscalls"]:::syscalls
        parallel["parallel_syscalls"]:::syscalls
        Recycled["RecycledGate"]:::syscalls
        Tartarus["TartarusGate"]:::syscalls
    end
    Monorepo --> direct
    Monorepo --> indirect
    Monorepo --> parallel
    Monorepo --> Recycled
    Monorepo --> Tartarus

    subgraph "Category: Enumeration & Resolution"
        DR["Dynamic_Resolver"]:::syscalls
        Enum["Enumeration"]:::syscalls
    end
    Monorepo --> DR
    Monorepo --> Enum

    subgraph "Category: Persistence Techniques"
        PPid["PPid_spoofing"]:::malwareTech
    end
    Monorepo --> PPid

    subgraph "Interactive Demos"
        rev_shell["rev_shell (Client)"]:::interactive
        rev_receive["rev_receive (Server)"]:::interactive
        pipe_client["pipe_client (Client)"]:::interactive
        pipe_server["pipe_server (Server)"]:::interactive
        GitSteal["GitHub_API Stealer"]:::interactive
    end
    Monorepo --> rev_shell
    Monorepo --> rev_receive
    Monorepo --> pipe_client
    Monorepo --> pipe_server
    Monorepo --> GitSteal
    rev_shell <--> rev_receive
    pipe_client <--> pipe_server
    GitHubSvc["GitHub Service"]:::external
    GitSteal -->|"queries"| GitHubSvc

    subgraph "External Dependencies"
        WRS["windows-rs"]:::external
        WinAPI["winapi"]:::external
        NTAPI["ntapi"]:::external
        RustSys["rust_syscalls"]:::external
    end
    PI --> WRS
    Aes --> WRS
    direct --> RustSys
    indirect --> RustSys
    PersistenceDir --> WinAPI
    Evasion --> NTAPI

    classDef malwareTech fill:#f96,stroke:#800;
    classDef encrypt fill:#fc3,stroke:#a60;
    classDef syscalls fill:#c9f,stroke:#60a;
    classDef build fill:#ccc,stroke:#666;
    classDef interactive fill:#9cf,stroke:#06a;
    classDef external fill:#afa,stroke:#0a0;
    classDef actor fill:#fff,stroke:#333;

    click README "https://github.com/whitecat18/rust-for-malware-development/blob/main//README.md"
    click Dockerfile "https://github.com/whitecat18/rust-for-malware-development/tree/main//Dockerfile"
    click DepsDoc "https://github.com/whitecat18/rust-for-malware-development/blob/main//deps.md"
    click CleanDoc "https://github.com/whitecat18/rust-for-malware-development/blob/main//CLEAN.md"
    click PI "https://github.com/whitecat18/rust-for-malware-development/tree/main//Process-Injection"
    click Ghosting "https://github.com/whitecat18/rust-for-malware-development/tree/main//GhostingProcess"
    click PersistenceDir "https://github.com/whitecat18/rust-for-malware-development/tree/main//Persistence"
    click Evasion "https://github.com/whitecat18/rust-for-malware-development/tree/main//Evasion"
    click BSOD "https://github.com/whitecat18/rust-for-malware-development/tree/main//BSOD"
    click Keyloggers "https://github.com/whitecat18/rust-for-malware-development/tree/main//Keyloggers"
    click DLLInj "https://github.com/whitecat18/rust-for-malware-development/tree/main//DLL_Injector"
    click Aes "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/Aes_Encryption"
    click Khufu "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/Khufu_encryption"
    click Madryga "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/Madryga_encryption"
    click SysFunc "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/SystemFunction032_033"
    click Camellia "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/camellia_cipher"
    click ECC "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/ecc_shellcode_exec"
    click Payload "https://github.com/whitecat18/rust-for-malware-development/tree/main//Encryption Methods/payload_shuffling"
    click direct "https://github.com/whitecat18/rust-for-malware-development/tree/main//syscalls/direct_syscalls"
    click indirect "https://github.com/whitecat18/rust-for-malware-development/tree/main//syscalls/indirect_syscalls"
    click parallel "https://github.com/whitecat18/rust-for-malware-development/tree/main//syscalls/parallel_syscalls"
    click Recycled "https://github.com/whitecat18/rust-for-malware-development/tree/main//syscalls/RecycledGate"
    click Tartarus "https://github.com/whitecat18/rust-for-malware-development/tree/main//syscalls/TartarusGate"
    click DR "https://github.com/whitecat18/rust-for-malware-development/tree/main//Dynamic_Resolver"
    click Enum "https://github.com/whitecat18/rust-for-malware-development/tree/main//Enumeration"
    click PPid "https://github.com/whitecat18/rust-for-malware-development/tree/main//Persistence/PPid_spoofing"
    click rev_shell "https://github.com/whitecat18/rust-for-malware-development/tree/main//Reverse Shell/rev_shell"
    click rev_receive "https://github.com/whitecat18/rust-for-malware-development/tree/main//Reverse Shell/rev_receive"
    click pipe_client "https://github.com/whitecat18/rust-for-malware-development/tree/main//Named_Pipe/pipe_client"
    click pipe_server "https://github.com/whitecat18/rust-for-malware-development/tree/main//Named_Pipe/pipe_server"
    click GitSteal "https://github.com/whitecat18/rust-for-malware-development/tree/main//stealer/GitHub_API"
```
