# m4sc3r4n0/spyrat architecture

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

- Interactive diagram: https://gitdiagram.com/m4sc3r4n0/spyrat
- Repository: https://github.com/m4sc3r4n0/spyrat

## Overview

SpyRat is a two-part remote-access tool: an operator runs a listener, which accepts client connections and offers an interactive command session; the client reconnects and handles commands over that socket. The client also attempts Windows startup persistence and supports shell commands, file transfer, deletion, directory changes, and screenshots. The graph reflects behavior visible in the supplied source; some listener-side command branches appear incomplete or inconsistent, so uncertain links are omitted.

Main entry points: [`listener.py`](https://github.com/m4sc3r4n0/spyrat/blob/master/listener.py) (Listener), [`client.py`](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py) (Command Dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_operator["Operator Console"]
  node_listener["Listener<br/>[listener.py]"]
end

subgraph group_client["Client Agent"]
  node_client_agent["Client Agent<br/>[client.py]"]
  node_persistence["Startup Persistence<br/>[client.py]"]
  node_command_dispatch["Command Dispatch<br/>[client.py]"]
end

subgraph group_capabilities["Client Capabilities"]
  node_shell["Shell Commands<br/>[client.py]"]
  node_file_transfer["File Transfer<br/>[client.py]"]
  node_file_management["File Management<br/>[client.py]"]
  node_screenshots["Screenshots<br/>[client.py]"]
end

node_operator_user(("Operator"))
node_windows_registry[("Windows Registry")]

node_operator_user -->|"enters commands"| node_listener
node_listener -->|"accepts connection"| node_client_agent
node_client_agent -->|"connects by TCP"| node_listener
node_listener -->|"sends commands"| node_command_dispatch
node_command_dispatch -->|"runs commands"| node_shell
node_command_dispatch -->|"handles transfer"| node_file_transfer
node_command_dispatch -->|"handles file actions"| node_file_management
node_command_dispatch -->|"captures image"| node_screenshots
node_client_agent -->|"attempts setup"| node_persistence
node_persistence -->|"writes startup entry"| node_windows_registry
node_shell -->|"returns output"| node_listener
node_file_transfer -->|"sends requested files"| node_listener
node_listener -->|"sends upload data"| node_file_transfer

click node_listener "https://github.com/m4sc3r4n0/spyrat/blob/master/listener.py"
click node_client_agent "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_persistence "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_command_dispatch "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_shell "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_file_transfer "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_file_management "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"
click node_screenshots "https://github.com/m4sc3r4n0/spyrat/blob/master/client.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_listener toneBlue
class node_client_agent,node_persistence,node_command_dispatch,node_windows_registry toneAmber
class node_shell,node_file_transfer,node_file_management,node_screenshots toneMint
class node_operator_user toneIndigo
```

## Components

### Operator Console

- [Listener](https://github.com/m4sc3r4n0/spyrat/blob/master/listener.py): `listener.py`

### Client Agent

- [Client Agent](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`
- [Startup Persistence](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`
- [Command Dispatch](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`

### Client Capabilities

- [Shell Commands](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`
- [File Transfer](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`
- [File Management](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`
- [Screenshots](https://github.com/m4sc3r4n0/spyrat/blob/master/client.py): `client.py`

### Other components

- **Operator**
- **Windows Registry**

## Connections

- Operator → Listener: enters commands (evidence: `listener.py`)
- Listener → Client Agent: accepts connection (evidence: `listener.py`)
- Client Agent → Listener: connects by TCP (evidence: `client.py`)
- Listener → Command Dispatch: sends commands (evidence: `listener.py`)
- Command Dispatch → Shell Commands: runs commands (evidence: `client.py`)
- Command Dispatch → File Transfer: handles transfer (evidence: `client.py`)
- Command Dispatch → File Management: handles file actions (evidence: `client.py`)
- Command Dispatch → Screenshots: captures image (evidence: `client.py`)
- Client Agent → Startup Persistence: attempts setup (evidence: `client.py`)
- Startup Persistence → Windows Registry: writes startup entry (evidence: `client.py`)
- Shell Commands → Listener: returns output (evidence: `client.py`)
- File Transfer → Listener: sends requested files (evidence: `client.py`)
- Listener → File Transfer: sends upload data (evidence: `listener.py`)
