# 0xspyy/devilstealer architecture

> Architecture diagram of the GitHub repository 0xspyy/devilstealer, 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/0xspyy/devilstealer
- Repository: https://github.com/0xspyy/devilstealer

## Overview

1. The actual stealer (found in the “devilStealer” directory) – this is the functional payload that gathers data from a victim’s machine.
2. The builder (found in the “devilStealer-Builder” directory) – this script assists in packaging/building the stealer (for example turning it into an executable via tools like nuitka or pyinstaller) and may include additional steps like configuration and customization.

##### Main Components
- Stealer Module:
- Files: bot.py, stealer.py (under devilStealer folder)
- Core Functions: Data collection from browsers (cookies and passwords), capturing screenshots, gathering system info (IP, MAC, hostname, CPU, GPU, RAM, disk, etc.), and sending harvested data via Telegram bot.
- Builder Module:
- Files: builder.py, cache.json, and the duplicate stealer/bot.py and stealer.py (under devilStealer-Builder)
- Purpose: Provide a user interface for configuration and automated build process, which includes steps like embedding configurable parameters (e.g., file paths, Telegram token, admin ID) and using build tools like Nuitka or PyInstaller.
- Telegram Bot (External Service):
- Interaction: The stealer uses Telegram’s API (via pyTelegramBotAPI) to send the collected data.
- External Libraries/Dependencies:
- Pillow, browser-cookie3, psutil, pywin32, and pyTelegramBotAPI (for stealer functionality).
- Additional library “colorama” for builder console UI.
- Local System/Environment:
- The Windows OS environment (since the stealer works only on Windows as per README).
- The data directories (defined in stealer.py) which are used for temporary storage.

##### Relationships and Interactions
- The Builder allows a user to customize settings and then compiles the stealer module for deployment.
- Once built and executed on a Windows machine, the Stealer collects data from various sources (browsers, system info, screenshots) and then routes this data to a Telegram Bot via API calls.
- The builder may also generate a cache (cache.json) during its build process to store user options and build settings.
- Flow from the victim’s machine (data sources) → stealer collection routines → packaging/transmission via Telegram Bot to the attacker’s Telegram account.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The design neatly separates the build process from actual data theft functionality.
- Modular Design: Although code duplication exists between builder and stealer folders, the components have defined purposes (building vs. execution).
- External Dependency Integration: Usage of third-party libraries to interact with external systems (e.g., Telegram API, browser data extraction).

##### Technology Highlights
- Python 3.11 (as tests indicate) with specified dependencies.
- Use of Telegram for data exfiltration, which is a key integration point.
- Packaging tools (Nuitka/pyinstaller) to generate an executable from Python scripts.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Victim Machine Layer
    VM["Victim Machine (Local Sources)\nBrowsers, System Info, Screenshots"]:::local

    %% Data Storage for Screenshots
    DS["Data Storage: Screenshots"]:::local

    %% Payload Layer
    subgraph "Devil Stealer - Payload"
        SC["Stealer Data Collector\n(stealer.py)"]:::payload
        TB["Telegram Bot Comm\n(bot.py)"]:::payload
    end

    %% External Service Layer
    TBAPI["Telegram Bot API"]:::external

    %% Builder Layer
    subgraph "Devil Stealer Builder"
        BP["Builder (Packaging Process)\n(builder.py)"]:::builder
        BSC["Builder Payload Collector\n(devilStealer/stealer.py)"]:::builder
        BTW["Builder Payload Bot\n(devilStealer/bot.py)"]:::builder
        BC["Build Cache\n(cache.json)"]:::builder
    end

    %% Relationships
    VM -->|"collectsData"| SC
    SC -->|"storesScreenshots"| DS
    SC -->|"sendsData"| TB
    TB -->|"transmitsViaTelegramAPI"| TBAPI
    BP -->|"buildDeploys"| SC
    BP -->|"includesDuplicatePayload"| BSC
    BP -->|"includesDuplicatePayload"| BTW

    %% Styling Classes
    classDef payload fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef builder fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFD700,stroke:#000,stroke-width:2px;
    classDef local fill:#D3D3D3,stroke:#000,stroke-width:2px;

    %% Click Events for Payload Module
    click SC "https://github.com/0xspyy/devilstealer/blob/main/devilStealer/stealer.py"
    click TB "https://github.com/0xspyy/devilstealer/blob/main/devilStealer/bot.py"

    %% Click Events for Builder Module
    click BP "https://github.com/0xspyy/devilstealer/blob/main/devilStealer-Builder/builder.py"
    click BC "https://github.com/0xspyy/devilstealer/blob/main/devilStealer-Builder/cache.json"
    click BSC "https://github.com/0xspyy/devilstealer/blob/main/devilStealer-Builder/devilStealer/stealer.py"
    click BTW "https://github.com/0xspyy/devilstealer/blob/main/devilStealer-Builder/devilStealer/bot.py"
    
    %% Click Event for Data Storage Directory
    click DS "https://github.com/0xspyy/devilstealer/tree/main/screenshots"
```
