# jgamblin/mirai-source-code architecture

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

- Interactive diagram: https://gitdiagram.com/jgamblin/mirai-source-code
- Repository: https://github.com/jgamblin/mirai-source-code

## Overview

README describes a botnet comprising an IoT bot, a command-and-control server, and a Telnet-based loader. The documented high-level workflow is loader discovery and deployment, bot execution, then CnC control and attack capability. Source excerpts show the loader’s Telnet state handling and the bot’s initialization/control loop; CnC internals and several supporting subsystems were not excerpted, so their relationships are limited to README-level evidence.

Main entry points: [`loader/src/server.c`](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/server.c) (Probe Server), [`mirai/cnc/main.go`](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/main.go) (CnC Server), [`mirai/bot/main.c`](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/main.c) (Bot Runtime), [`mirai/bot/attack.c`](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack.c) (Attack Dispatch)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_loader["Loader"]
  node_loader_entry["Loader Entry<br/>[main.c]"]
  node_telnet_targets(("Telnet Targets"))
  node_loader_server["Probe Server<br/>[server.c]"]
  node_loader_connection["Telnet Session<br/>[connection.c]"]
  node_telnet_records["Target Records<br/>[telnet_info.h]"]
  node_binary_select["Binary Selection<br/>[binary.c]"]
  node_loader_util["Loader Utilities<br/>[util.c]"]
end

subgraph group_bot["IoT Bot"]
  node_bot_runtime["Bot Runtime<br/>[main.c]"]
  node_scanner["Credential Scanner<br/>[scanner.c]"]
  node_attack_dispatch["Attack Dispatch<br/>[attack.c]"]
  node_attack_methods["Attack Methods<br/>[attack_app.c]"]
  node_packet_attacks["Packet Attacks<br/>[attack_tcp.c]"]
  node_gre_attacks["GRE Attacks<br/>[attack_gre.c]"]
  node_udp_attacks["UDP Attacks<br/>[attack_udp.c]"]
  node_bot_killer["Process Killer<br/>[killer.c]"]
  node_bot_table["String Table<br/>[table.c]"]
end

subgraph group_cnc["Command And Control"]
  node_cnc_server["CnC Server<br/>[main.go]"]
  node_cnc_admin["Admin Interface<br/>[admin.go]"]
  node_cnc_api["CnC API<br/>[api.go]"]
  node_cnc_attack["Attack Control<br/>[attack.go]"]
  node_cnc_bots["Bot Registry<br/>[bot.go]"]
  node_cnc_clients["Client List<br/>[clientList.go]"]
  node_cnc_database[("CnC Database<br/>[database.go]")]
end

subgraph group_support["Delivery Support"]
  node_delivery["Payload Delivery<br/>[main.c]"]
end

node_operator(("Operator"))

node_operator -->|"administers"| node_cnc_admin
node_operator -->|"runs loader"| node_loader_entry
node_loader_entry -->|"starts probes"| node_loader_server
node_telnet_targets -->|"target probes"| node_loader_server
node_loader_server -->|"handles sessions"| node_loader_connection
node_loader_server -->|"uses target data"| node_telnet_records
node_loader_server -->|"selects payload"| node_binary_select
node_loader_server -->|"uses utilities"| node_loader_util
node_loader_server -->|"deploys bot"| node_bot_runtime
node_bot_runtime -->|"starts scanner"| node_scanner
node_bot_runtime -->|"initializes attacks"| node_attack_dispatch
node_bot_runtime -->|"initializes killer"| node_bot_killer
node_bot_runtime -->|"connects to CnC"| node_cnc_server
node_cnc_admin -.->|"controls"| node_cnc_server
node_cnc_server -.->|"serves API"| node_cnc_api
node_cnc_server -.->|"tracks bots"| node_cnc_bots
node_cnc_server -.->|"tracks clients"| node_cnc_clients
node_cnc_server -.->|"uses database"| node_cnc_database
node_cnc_server -.->|"dispatches attacks"| node_cnc_attack
node_cnc_attack -->|"sends commands"| node_bot_runtime
node_attack_dispatch -.->|"dispatches methods"| node_attack_methods
node_attack_dispatch -.->|"dispatches methods"| node_packet_attacks
node_attack_dispatch -.->|"dispatches methods"| node_gre_attacks
node_attack_dispatch -.->|"dispatches methods"| node_udp_attacks
node_delivery -.->|"payload delivery"| node_bot_runtime

click node_loader_entry "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/main.c"
click node_loader_server "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/server.c"
click node_loader_connection "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/connection.c"
click node_telnet_records "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/headers/telnet_info.h"
click node_binary_select "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/binary.c"
click node_loader_util "https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/util.c"
click node_bot_runtime "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/main.c"
click node_scanner "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/scanner.c"
click node_attack_dispatch "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack.c"
click node_attack_methods "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_app.c"
click node_packet_attacks "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_tcp.c"
click node_gre_attacks "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_gre.c"
click node_udp_attacks "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_udp.c"
click node_bot_killer "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/killer.c"
click node_bot_table "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/table.c"
click node_cnc_server "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/main.go"
click node_cnc_admin "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/admin.go"
click node_cnc_api "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/api.go"
click node_cnc_attack "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/attack.go"
click node_cnc_bots "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/bot.go"
click node_cnc_clients "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/clientList.go"
click node_cnc_database "https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/database.go"
click node_delivery "https://github.com/jgamblin/mirai-source-code/blob/master/dlr/main.c"

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_loader_entry,node_telnet_targets,node_loader_server,node_loader_connection,node_telnet_records,node_binary_select,node_loader_util toneBlue
class node_bot_runtime,node_scanner,node_attack_dispatch,node_attack_methods,node_packet_attacks,node_gre_attacks,node_udp_attacks,node_bot_killer,node_bot_table toneAmber
class node_cnc_server,node_cnc_admin,node_cnc_api,node_cnc_attack,node_cnc_bots,node_cnc_clients,node_cnc_database toneMint
class node_delivery toneRose
class node_operator toneIndigo
```

## Components

### Loader

- [Loader Entry](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/main.c): `loader/src/main.c`
- **Telnet Targets**
- [Probe Server](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/server.c): `loader/src/server.c`
- [Telnet Session](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/connection.c): `loader/src/connection.c`
- [Target Records](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/headers/telnet_info.h): `loader/src/headers/telnet_info.h`
- [Binary Selection](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/binary.c): `loader/src/binary.c`
- [Loader Utilities](https://github.com/jgamblin/mirai-source-code/blob/master/loader/src/util.c): `loader/src/util.c`

### IoT Bot

- [Bot Runtime](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/main.c): `mirai/bot/main.c`
- [Credential Scanner](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/scanner.c): `mirai/bot/scanner.c`
- [Attack Dispatch](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack.c): `mirai/bot/attack.c`
- [Attack Methods](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_app.c): `mirai/bot/attack_app.c`
- [Packet Attacks](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_tcp.c): `mirai/bot/attack_tcp.c`
- [GRE Attacks](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_gre.c): `mirai/bot/attack_gre.c`
- [UDP Attacks](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/attack_udp.c): `mirai/bot/attack_udp.c`
- [Process Killer](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/killer.c): `mirai/bot/killer.c`
- [String Table](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/bot/table.c): `mirai/bot/table.c`

### Command And Control

- [CnC Server](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/main.go): `mirai/cnc/main.go`
- [Admin Interface](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/admin.go): `mirai/cnc/admin.go`
- [CnC API](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/api.go): `mirai/cnc/api.go`
- [Attack Control](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/attack.go): `mirai/cnc/attack.go`
- [Bot Registry](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/bot.go): `mirai/cnc/bot.go`
- [Client List](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/clientList.go): `mirai/cnc/clientList.go`
- [CnC Database](https://github.com/jgamblin/mirai-source-code/blob/master/mirai/cnc/database.go): `mirai/cnc/database.go`

### Delivery Support

- [Payload Delivery](https://github.com/jgamblin/mirai-source-code/blob/master/dlr/main.c): `dlr/main.c`

### Other components

- **Operator**

## Connections

- Operator → Admin Interface: administers (evidence: `README.md`)
- Operator → Loader Entry: runs loader (evidence: `README.md`)
- Loader Entry → Probe Server: starts probes (evidence: `loader/src/main.c`)
- Telnet Targets → Probe Server: target probes (evidence: `README.md`)
- Probe Server → Telnet Session: handles sessions (evidence: `loader/src/server.c`)
- Probe Server → Target Records: uses target data (evidence: `loader/src/server.c`)
- Probe Server → Binary Selection: selects payload (evidence: `loader/src/server.c`)
- Probe Server → Loader Utilities: uses utilities (evidence: `loader/src/server.c`)
- Probe Server → Bot Runtime: deploys bot (evidence: `README.md`)
- Bot Runtime → Credential Scanner: starts scanner (evidence: `mirai/bot/main.c`)
- Bot Runtime → Attack Dispatch: initializes attacks (evidence: `mirai/bot/main.c`)
- Bot Runtime → Process Killer: initializes killer (evidence: `mirai/bot/main.c`)
- Bot Runtime → CnC Server: connects to CnC (evidence: `README.md`)
- Admin Interface → CnC Server: controls
- CnC Server → CnC API: serves API
- CnC Server → Bot Registry: tracks bots
- CnC Server → Client List: tracks clients
- CnC Server → CnC Database: uses database
- CnC Server → Attack Control: dispatches attacks
- Attack Control → Bot Runtime: sends commands (evidence: `README.md`)
- Attack Dispatch → Attack Methods: dispatches methods
- Attack Dispatch → Packet Attacks: dispatches methods
- Attack Dispatch → GRE Attacks: dispatches methods
- Attack Dispatch → UDP Attacks: dispatches methods
- Payload Delivery → Bot Runtime: payload delivery
