# malwaredllc/byob architecture

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

- Interactive diagram: https://gitdiagram.com/malwaredllc/byob
- Repository: https://github.com/malwaredllc/byob

## Overview

Based on your file tree and README analysis, BYOB is a dual‐faceted, modular post-exploitation framework which consists of two major parts:
- a console-based C2 system (with its payload generator, client payloads, core utilities and modules) and
- a web GUI that provides an interactive dashboard; payload generation (via Docker & Wine) and an in-browser terminal emulator.

##### Main Components
a. Client (Payloads/Agents):
– This is generated using the dynamic payload generator and stagers in byob/core/generators.py & byob/core/stagers.py.
– It contains the “client.py” and the modules available under byob/modules, which include functionalities like persistence, keylogging, port scanning, screenshot, etc.
– Incorporates security (in byob/core/security) implementing Diffie-Hellman key exchange and various encryption modes (AES-256, XOR).
– Key note: “Remote Imports”—clients do not write to disk but dynamically load dependencies from the server.

b. Server (Command & Control):
– Represented in byob/server.py and further integrated with the core modules in byob/core (DAO, handler, loader, util).
– Uses a persistent SQLite database (via byob/core/dao) to store session states and client information.
– Exposes a console-based user interface for administrators along with HTTP POST handlers for file uploads.
– Provides the remote import mechanism to supply non-standard modules to clients on demand.

c. Web GUI:
– Located in the “web-gui” directory and “buildyourownbotnet” subfolder.
– Provides a dashboard with an interactive map, payload generator interface, and an in-browser terminal emulator.
– Handles client interactions from a web perspective and interfaces with the same C2 back-end developed in BYOB.
– Contains assets, API routes (files, payload, session), and templates for both the user interface and in-browser terminal.

d. Core Framework & Utility Modules:
– Found inside byob/core. These include utilities, security, payloads, generators, stagers, loader, and handler modules.
– They are fundamental to both the console application and to support dynamic functionalities (remote imports, encryption, secure communications).

e. Cross-Compilation & Packaging:
– The byob/crosscomp subdirectory and docker-pyinstaller indicate support for building payloads via Docker, Wine, and platform-targeting scripts.
– This ensures platform independence by compiling clients into standalone executables for Windows, macOS, or others.

##### Relationships and Interactions
– The Web GUI interacts with the Server’s core APIs, where the API routes (files, payload, session) are consumed to manage reverse TCP shells and payload delivery.
– The Console-Based Interface (from the server) interacts with the database (SQLite) for session and host management. Mark these with a persistent data storage symbol.

##### Architectural Patterns/Design Principles
– Modular/Split Architecture: Clearly delineate Web GUI, console-based C2 server, and client components as separate but interacting layers.
– Client-Server (Reverse TCP) communication: Emphasize that clients initiate the connection to the server to bypass firewall restrictions.
– Dynamic Remote Import & Zero IO (No disk writes): This design pattern minimizes local footprint, is key to BYOB’s stealth.
– Cross-compilation: Highlight Docker & Wine components that enable payload generation across different target platforms.

##### Technologies and Frameworks
– Python is the primary language (both for server and client), with its standard library at its core.
– SQLite for the persistent database.
– Docker/Wine for cross-compiling clients.
– Web frameworks/libraries (likely Flask or similar, considering the directory layout) for the Web GUI.
– Cryptography using AES-256, Diffie-Hellman (as defined in byob/core/security) for encrypted payload communications.
– (Additionally, many front-end libraries are used in the Web GUI including jQuery, Bootstrap, CodeMirror, etc.)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client (Payloads/Agents)
    subgraph "Client (Payloads/Agents)"
        CA["client.py: Agent Core"]:::client
        PG["Payload Generator & Stager"]:::client
        SEC["Security Module"]:::client
        MOD["Modules (Keylogger,Persistence,etc.)"]:::client
    end

    %% Server (Command & Control)
    subgraph "Server (Command & Control)"
        SM["server.py: Server Main"]:::server
        HND["Handler (handler.py)"]:::server
        RL["Remote Loader (loader.py)"]:::server
        DBM["Database Manager (database.py)"]:::db
        UTIL["Utility Modules (util.py)"]:::server
    end

    %% Web GUI/REST API
    subgraph "Web GUI/REST API"
        WG["Web GUI Interface"]:::gui
    end

    %% Cross-Compilation & Packaging
    subgraph "Cross-Compilation & Packaging"
        CC["Cross-Compilation (byob/crosscomp)"]:::cross
        DPI["Docker-pyinstaller (web-gui/docker-pyinstaller)"]:::cross
    end

    %% Core Framework & Utilities (common module)
    CORE["Core Framework & Utilities (byob/core)"]:::core

    %% Persistent Storage
    SQL["SQLite Database"]:::db

    %% Connections between components
    CA -->|"reverseTCP_secure"| SM
    SM --> RL
    RL -->|"dynamicImport"| MOD
    WG -->|"APIcalls"| SM
    DBM -->|"storesSessions"| SQL
    PG -->|"uses_Docker/Wine"| CC
    CC -->|"builds_payloads"| PG

    %% Both Client and Server utilize the Core Framework
    CA -->|"uses"| CORE
    PG -->|"uses"| CORE
    SEC -->|"uses"| CORE
    SM -->|"uses"| CORE
    HND -->|"uses"| CORE
    RL -->|"uses"| CORE
    UTIL -->|"uses"| CORE

    %% Additional internal connections within Server
    SM --> HND
    SM --> UTIL
    HND --> DBM
    UTIL --> DBM

    %% Security encryption applied on communication
    SEC -->|"encrypts"| SM

    %% Click events for Client components
    click CA "https://github.com/malwaredllc/byob/blob/master/byob/client.py"
    click PG "https://github.com/malwaredllc/byob/blob/master/byob/core/generators.py"
    click SEC "https://github.com/malwaredllc/byob/blob/master/byob/core/security.py"
    click MOD "https://github.com/malwaredllc/byob/tree/master/byob/modules/"

    %% Click events for Server components
    click SM "https://github.com/malwaredllc/byob/blob/master/byob/server.py"
    click HND "https://github.com/malwaredllc/byob/blob/master/byob/core/handler.py"
    click RL "https://github.com/malwaredllc/byob/blob/master/byob/core/loader.py"
    click DBM "https://github.com/malwaredllc/byob/blob/master/byob/core/database.py"
    click UTIL "https://github.com/malwaredllc/byob/blob/master/byob/core/util.py"

    %% Click event for Web GUI
    click WG "https://github.com/malwaredllc/byob/tree/master/web-gui/"

    %% Click events for Cross-Compilation & Packaging
    click CC "https://github.com/malwaredllc/byob/tree/master/byob/crosscomp/"
    click DPI "https://github.com/malwaredllc/byob/tree/master/web-gui/docker-pyinstaller/"

    %% Click event for Core Framework & Utilities
    click CORE "https://github.com/malwaredllc/byob/tree/master/byob/core/"

    %% Click event for SQLite Database
    click SQL "https://github.com/malwaredllc/byob/blob/master/byob/core/database.py"

    %% Styling for colors
    classDef client fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef server fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef gui fill:#FFC0CB,stroke:#000,stroke-width:2px;
    classDef core fill:#FFA500,stroke:#000,stroke-width:2px;
    classDef cross fill:#DA70D6,stroke:#000,stroke-width:2px;
    classDef db fill:#D3D3D3,stroke:#000,stroke-width:2px;

    class CA,PG,SEC,MOD client;
    class SM,HND,RL,UTIL server;
    class DBM,SQL db;
    class WG gui;
    class CC,DPI cross;
    class CORE core;
```
