# urban20/backdoor architecture

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

- Interactive diagram: https://gitdiagram.com/urban20/backdoor
- Repository: https://github.com/urban20/backdoor

## Overview

##### Project type and purpose
- This is a client-server “backdoor” / remote-access tool for Windows machines.
- Purpose: run a host process on a Windows target (the backdoor) that automatically tries to persist itself on startup, listens on a TCP port (default 999), executes incoming commands (shell commands, screenshots, etc.), and returns results to a client program.

##### File structure
- Top-level folders V1.0 (Python) and V2.0 (Go) contain two independent subprojects each:
- backdoorV2.0 (server)
– conexiones/   (socket handling)
– ejecuciones/  (command execution logic)
– main.go      (entry point, config/initialization)
- clienteV2.0 (client)
– colores/     (UI coloring)
– input/       (user input parsing)
– conex/       (network commands, subpackages comandos/ and comandos/ss for screenshots)
– main.go      (entry point, CLI flags)
- Important config/build files: go.mod, go.sum.

##### Insights from the README
- Architecture is a simple TCP client–server.
- Backdoor auto-copies to Windows startup (Python V1.0), silent on failure in GUI mode.
- Client issues both hardcoded automated commands (msg, shutdown, cls, ss) and arbitrary shell commands.
- Screenshots: captured on host, encoded to binary, streamed over socket to client, then saved to disk.

a. Main components:
- Client UI & CLI layer (golang client)
- Client Connection Manager (dialer, socket read/write)
- Command Dispatcher (maps user input to network payloads)
- Network Transport (TCP channel over IP:port 999)
- Server Listener (accepts connections)
- Server Connection Handler (reads payloads, routes to executors)
- Execution Modules:
- Shell Executor (executes arbitrary OS commands)
- Screenshot Module (captures, encodes, streams)
- Built-in Command Module (msg, shutdown, cls)
- File System (persistence, screenshot storage on client)
- Windows OS (target host environment)
b. Relationships and interactions:
- User → Client UI → Connection Manager → TCP Socket → Server Listener
- Server Handler → Execution Module → OS → Returns stdout/binary → back the same socket → Client
- Client receives data → if binary screenshot, writes to disk; else prints to console.
c. Architectural patterns/design principles:
- Modular separation by functionality (network, execution, IO)
- Single responsibility per package (conexiones vs ejecuciones vs comandos)
- CLI flag parsing at entry point, dependency injection of modules for testability
d. Key technologies/frameworks:
- Golang net package for sockets
- os/exec for command execution
- image encoding libraries (for screenshot binary transfer)
- Windows system calls (for startup persistence in Python V1.0)

##### Diagrammatic conventions
- Use clear, descriptive labels (e.g., “Client.CommandDispatcher”, “Server.ScreenshotModule”).

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Client (V2.0)"
        UI["Client UI & CLI Layer"]:::client
        Input["Input Parser (CLI flags & user input)"]:::client
        Color["UI Coloring Module"]:::client
        Disp["Client.Command Dispatcher"]:::client
        ConnMgr["Client.Connection Manager"]:::client
        SSHandler["Client.Screenshot Sub-command Handler"]:::client
        NetCfg["TCP Transport Configuration"]:::client
        FSClient["Client File System (screenshot storage)"]:::external
    end

    subgraph "Server (V2.0)"
        Listener["Server Entry Point & Listener"]:::server
        ConnHandler["Server Connection Handler"]:::server
        subgraph "Server.Execution Modules"
            Shell["Server.Shell Executor"]:::server
            Builtin["Server.Built-in Commands"]:::server
            SSMod["Server.Screenshot Module"]:::server
        end
        Deps["Server Dependencies"]:::server
        OS["Windows OS"]:::external
    end

    UI --> Input
    UI --> Color
    Input --> Disp
    Color --> Disp
    Disp --> ConnMgr
    ConnMgr --> NetCfg
    NetCfg -->|"TCP Port 999"| Listener
    Listener --> ConnHandler
    ConnHandler --> Shell
    ConnHandler --> Builtin
    ConnHandler --> SSMod
    Shell -->|stdout| ConnHandler
    Builtin -->|status| ConnHandler
    SSMod -->|binary stream| ConnHandler
    ConnHandler -->|"response"| ConnMgr
    ConnMgr --> UI
    ConnMgr -->|"screenshot file"| FSClient
    FSClient -.-> UI
    Deps --> Shell
    Deps --> Builtin
    Deps --> SSMod
    OS --> Shell
    OS --> SSMod

    click UI "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/main.go"
    click Input "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/input/input.go"
    click Color "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/colores/colores.go"
    click ConnMgr "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/conex/conexiones.go"
    click Disp "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/conex/comandos/comandos.go"
    click SSHandler "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/conex/comandos/ss/ss.go"
    click NetCfg "https://github.com/urban20/backdoor/blob/main/V2.0/clienteV2.0/go.mod"
    click Listener "https://github.com/urban20/backdoor/blob/main/V2.0/backdoorV2.0/main.go"
    click ConnHandler "https://github.com/urban20/backdoor/blob/main/V2.0/backdoorV2.0/conexiones/conexiones.go"
    click Shell "https://github.com/urban20/backdoor/blob/main/V2.0/backdoorV2.0/ejecuciones/ejecuciones.go"
    click Deps "https://github.com/urban20/backdoor/blob/main/V2.0/backdoorV2.0/go.mod"

    classDef client fill:#BBE1FA,stroke:#000,stroke-width:1px
    classDef server fill:#FFB3B3,stroke:#000,stroke-width:1px
    classDef external fill:#BBF3BB,stroke:#000,stroke-width:1px
```
