# worm0x1/k4gen1nja architecture

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

- Interactive diagram: https://gitdiagram.com/worm0x1/k4gen1nja
- Repository: https://github.com/worm0x1/k4gen1nja

## Overview

##### Project Type and Purpose
- This is a static, front‐end–only demonstration site (index.html + script.js) hosted on a static-file host (e.g., Vercel).
- Its goal is to show how a malicious page can request camera/microphone/keyboard/GPS permissions and send the collected media/info to a Telegram Bot via simple HTTP calls.

##### Main Components
a. Client (User’s Browser)
- index.html + script.js loaded over HTTPS.
- Executes JavaScript to prompt for permissions, capture media and device/browser info.
b. Static Host (Vercel or equivalent)
- Serves index.html, script.js, and any static assets.
c. Public/Private Code API Endpoints
- Serverless functions (e.g., /video-f.html, /video-b.html, /main.html) that accept token & chat ID parameters.
- Relay the captured blobs and metadata to Telegram via the Bot API.
d. Telegram Bot Service
- External service endpoint (api.telegram.org) which receives HTTP requests from the Code API and delivers messages/media to the attacker’s chat.

##### Data Flows & Interactions
1. User navigates to the malicious link → Browser requests index.html and script.js from the Static Host.
2. script.js prompts for permissions (camera, mic, GPS, keyboard info).
3. If granted, media streams or snapshots are captured; otherwise, browser+OS info is collected.
4. script.js posts the data (via HTTP GET/POST) to one of the Code API endpoints, passing the attacker’s Telegram Bot token & chat ID as query parameters.
5. The Code API serverless function calls Telegram’s Bot API (https://api.telegram.org/bot<TOKEN>/sendPhoto or sendVideo/sendMessage) to forward the data.
6. Telegram delivers content to the attacker’s chat.

##### Architectural Patterns & Principles
- Single‐page static front end + serverless “backend” (thin relay).
- Separation of concerns: static hosting for UI/UX vs. serverless functions for messaging.
- External‐service integration: Telegram Bot API as a third‐party messaging service.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Client (User’s Browser)"
        direction TB
        Browser["Browser"]:::client
        Index["index.html"]:::client
        Script["script.js"]:::client
    end

    subgraph "Static Host (Vercel or Equivalent)" 
        direction TB
        Host[(Static File Host)]:::server
        ProjectRoot["Project Root"]:::server
        README["README.md"]:::server
    end

    subgraph "Serverless Relay Functions"
        direction TB
        VideoF["/video-f.html"]:::server
        VideoB["/video-b.html"]:::server
        MainF["/main.html"]:::server
    end

    Telegram["Telegram Bot API\n(api.telegram.org)"]:::external

    Browser -->|"HTTPS GET /index.html, script.js"| Host
    Host -->|Serves files| Browser

    Host --> Index
    Host --> Script
    ProjectRoot --> Host
    ProjectRoot --> README

    Script -->|"Permission prompt\n→ Media/Info capture"| Browser

    Script -->|"HTTP POST → /video-f.html?token=…&id=…"| VideoF
    Script -->|"HTTP POST → /video-b.html?token=…&id=…"| VideoB
    Script -->|"HTTP POST → /main.html?token=…&id=…"| MainF

    VideoF -->|"Bot API call\n(sendVideo/sendPhoto)"| Telegram
    VideoB -->|"Bot API call\n(sendVideo/sendPhoto)"| Telegram
    MainF -->|"Bot API call\n(sendMessage)"| Telegram

    click Index "https://github.com/worm0x1/k4gen1nja/blob/main/index.html"
    click Script "https://github.com/worm0x1/k4gen1nja/blob/main/script.js"
    click ProjectRoot "https://github.com/worm0x1/k4gen1nja/blob/main/."
    click README "https://github.com/worm0x1/k4gen1nja/blob/main/README.md"

    classDef client fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef server fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
