# yogeshwar-2004y/trojan architecture

> Architecture diagram of the GitHub repository yogeshwar-2004y/trojan, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yogeshwar-2004y/trojan
- Repository: https://github.com/yogeshwar-2004y/trojan

## Overview

##### Project type and purpose
- This is not a typical client-server app or microservice suite, but rather a collection of Python-based trojan modules:
- Keylogger (captures keystrokes & mouse clicks)
- Anti-analysis detector (self-termination under suspicious activity)
- Screenshot capturer (full-screen capture + base64 encoding)
- Shellcode executor (downloads & runs arbitrary shellcode via Windows API)
- All modules target Windows, leverage ctypes and pywin32 for low-level API access, and pynput for input hooks.

##### File structure
- Top-level Python scripts each implement a standalone capability.
- No config files; parameters (URLs, thresholds) are likely hard-coded or passed via CLI.

##### Key points from the README
- Each script has its own “Overview” and “Requirements.”
- Common dependencies: Python 3.x, pywin32, pynput, ctypes.

##### Main components
a. Controller / Launcher (conceptual): orchestrates module execution or runs all in parallel
b. Keylogger module
c. Anti-analysis Detector module
d. Screenshot Capture module
e. Shellcode Execution module
f. Windows OS / WinAPI (ctypes, pywin32)
g. External Server (for shellcode download or exfiltration of logs/screenshots, if applicable)
h. Storage (local files or in-memory buffers)

##### Relationships & interactions
- Controller → invokes Keylogger, Anti-analysis, Screenshot, Shellexec
- Keylogger & Screenshot → generate data → pass to Storage or Network layer
- Shellcode Execution → network call to fetch payload → WinAPI allocate & execute
- Anti-analysis monitors input volume → if threshold exceeded → terminates its own process or signals Controller

##### Architectural patterns & design principles
- Modular design: each capability is a separate script/module
- Single-responsibility: each script handles one facet of the trojan
- Low-level API integration: highlight the use of ctypes and pywin32 for stealth and power

##### Technologies & frameworks
- Python 3.x runtime
- pynput (keyboard/mouse hooks)
- pywin32 (clipboard, screen capture)
- ctypes (memory allocation, function calls in native DLLs)
- Base64 encoding library (built-in)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Controller
    Controller["Controller / Launcher"]:::controller

    %% Modules Layer
    subgraph "Modules"
        direction TB
        Keylogger["Keylogger Module"]:::module
        AntiAnalysis["Anti-analysis Detector Module"]:::module
        Screenshot["Screenshot Capture Module"]:::module
        ShellcodeExec["Shellcode Execution Module"]:::module
    end

    %% OS / WinAPI Layer
    WinAPI[(WinAPI Layer)]:::api

    %% Storage Layer
    Storage[(Local Storage)]:::storage

    %% External Service
    ExternalC2["External C2 Server"]:::external

    %% Connections
    Controller -->|"invoke"| Keylogger
    Controller -->|"invoke"| AntiAnalysis
    Controller -->|"invoke"| Screenshot
    Controller -->|"invoke"| ShellcodeExec

    Keylogger -->|"key event stream"| Storage
    Keylogger -->|"WinAPI hooks"| WinAPI

    Screenshot -->|"full-screen capture"| WinAPI
    Screenshot -->|"base64 image"| Storage

    ShellcodeExec -->|"HTTP GET shellcode"| ExternalC2
    ShellcodeExec -->|"allocate & execute"| WinAPI

    AntiAnalysis -->|"monitor input"| WinAPI
    AntiAnalysis -->|"self-terminate"| Controller

    %% Optional exfiltration arrows
    Keylogger -->|"exfil logs"| ExternalC2
    Screenshot -->|"exfil image"| ExternalC2

    %% Click Events
    click Keylogger "https://github.com/yogeshwar-2004y/trojan/blob/main/keylogger.py"
    click AntiAnalysis "https://github.com/yogeshwar-2004y/trojan/blob/main/sandbox_detect.py"
    click Screenshot "https://github.com/yogeshwar-2004y/trojan/blob/main/screenshot.py"
    click ShellcodeExec "https://github.com/yogeshwar-2004y/trojan/blob/main/shell_exec.py"
    click Controller "https://github.com/yogeshwar-2004y/trojan/blob/main/README.md"

    %% Styles
    classDef module fill:#ffe4e1,stroke:#e9967a,stroke-width:1px
    classDef api fill:#e0ffff,stroke:#20b2aa,stroke-width:1px
    classDef storage fill:#f0fff0,stroke:#32cd32,stroke-width:1px
    classDef external fill:#fff0f5,stroke:#db7093,stroke-width:1px
    classDef controller fill:#ffffe0,stroke:#daa520,stroke-width:2px,stroke-dasharray: 5 5
```
