# skerkour/black-hat-rust architecture

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

- Interactive diagram: https://gitdiagram.com/skerkour/black-hat-rust
- Repository: https://github.com/skerkour/black-hat-rust

## Overview

Black Hat Rust is a book-length collection of independent Rust examples for offensive security, not one integrated application. Its documented learning arc covers reconnaissance, exploitation, phishing, and implant development. The graph highlights the scanner and agent workflows visible in excerpts, while retaining major unsampled capabilities as chapter-level subsystems. Chapter relationships are documented in the README; source-level links are limited to relationships shown by the supplied excerpts and SOURCE INDEX.

Main entry points: [`ch_04/tricoder/src/cli.rs`](https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/cli.rs) (Scanner CLI), [`ch_11/agent/src/run.rs`](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/agent/src/run.rs) (Remote agent), [`ch_11/server/src/main.rs`](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/server/src/main.rs) (Control server), [`ch_03/tricoder/src/main.rs`](https://github.com/skerkour/black-hat-rust/blob/main/ch_03/tricoder/src/main.rs) (Async scanner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_recon["Reconnaissance"]
  node_scanner_cli["Scanner CLI<br/>[cli.rs]"]
  node_dns["DNS discovery<br/>[dns.rs]"]
  node_port_scan["Port scanning<br/>[ports.rs]"]
  node_common_ports["Common ports<br/>[common_ports.rs]"]
  node_scan_modules["Scan modules"]
  node_async_scanner["Async scanner<br/>[main.rs]"]
  node_subdomain_enum["Subdomain enumeration<br/>[subdomains.rs]"]
  node_crawler["Web crawler<br/>[crawler.rs]"]
  node_spiders["Crawler spiders"]
end

subgraph group_exploit["Exploitation"]
  node_fuzzing["Fuzzing<br/>[lib.rs]"]
  node_exploits["Exploit examples"]
  node_shellcode["Shellcode examples"]
end

subgraph group_phishing["Phishing"]
  node_phishing_web["Phishing web app"]
  node_phishing_server["Phishing server<br/>[main.rs]"]
  node_email_delivery["Email delivery<br/>[main.rs]"]
end

subgraph group_implant["Implant development"]
  node_agent["Remote agent<br/>[run.rs]"]
  node_operator_client["Operator client<br/>[main.rs]"]
  node_control_server["Control server<br/>[main.rs]"]
  node_server_services["Server services"]
  node_server_storage[("Server persistence")]
  node_shared_protocol["Shared protocol<br/>[api.rs]"]
  node_crypto["Message encryption<br/>[crypto.rs]"]
  node_multiplatform["Cross-platform install"]
  node_worm_spread["Worm spreading<br/>[spread.rs]"]
end

subgraph group_foundations["Supporting examples"]
  node_email_templates["Email templates<br/>[template.rs]"]
end

node_operator(("Tool operator"))

node_operator -->|"runs scan"| node_scanner_cli
node_scanner_cli -->|"discovers hosts"| node_dns
node_scanner_cli -->|"scans ports"| node_port_scan
node_scanner_cli -->|"dispatches modules"| node_scan_modules
node_operator -->|"runs scan"| node_async_scanner
node_async_scanner -->|"enumerates domains"| node_subdomain_enum
node_operator -->|"selects spider"| node_crawler
node_crawler -->|"runs spider"| node_spiders
node_fuzzing -->|"finds vulnerabilities"| node_exploits
node_exploits -.->|"develops payloads"| node_shellcode
node_phishing_web -.->|"submits login"| node_phishing_server
node_email_templates -->|"renders message"| node_email_delivery
node_operator -->|"issues commands"| node_operator_client
node_operator_client -->|"sends requests"| node_control_server
node_control_server -.->|"dispatches operations"| node_server_services
node_server_services -.->|"uses persistence"| node_server_storage
node_agent -->|"communicates remotely"| node_control_server
node_agent -.->|"uses protocol"| node_shared_protocol
node_crypto -->|"secures messages"| node_shared_protocol
node_multiplatform -->|"installs agent"| node_agent
node_worm_spread -->|"extends reach"| node_agent

click node_scanner_cli "https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/cli.rs"
click node_dns "https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/dns.rs"
click node_port_scan "https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/ports.rs"
click node_common_ports "https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/common_ports.rs"
click node_scan_modules "https://github.com/skerkour/black-hat-rust/tree/main/ch_04/tricoder/src/modules"
click node_async_scanner "https://github.com/skerkour/black-hat-rust/blob/main/ch_03/tricoder/src/main.rs"
click node_subdomain_enum "https://github.com/skerkour/black-hat-rust/blob/main/ch_03/tricoder/src/subdomains.rs"
click node_crawler "https://github.com/skerkour/black-hat-rust/blob/main/ch_05/crawler/src/crawler.rs"
click node_spiders "https://github.com/skerkour/black-hat-rust/tree/main/ch_05/crawler/src/spiders"
click node_fuzzing "https://github.com/skerkour/black-hat-rust/blob/main/ch_06/fuzzing/src/lib.rs"
click node_exploits "https://github.com/skerkour/black-hat-rust/tree/main/ch_07/exploits"
click node_shellcode "https://github.com/skerkour/black-hat-rust/tree/main/ch_08"
click node_phishing_web "https://github.com/skerkour/black-hat-rust/tree/main/ch_09/phishing/webapp"
click node_phishing_server "https://github.com/skerkour/black-hat-rust/blob/main/ch_09/phishing/server/src/main.rs"
click node_email_delivery "https://github.com/skerkour/black-hat-rust/blob/main/ch_09/emails/src/main.rs"
click node_agent "https://github.com/skerkour/black-hat-rust/blob/main/ch_11/agent/src/run.rs"
click node_operator_client "https://github.com/skerkour/black-hat-rust/blob/main/ch_11/client/src/main.rs"
click node_control_server "https://github.com/skerkour/black-hat-rust/blob/main/ch_11/server/src/main.rs"
click node_server_services "https://github.com/skerkour/black-hat-rust/tree/main/ch_11/server/src/service"
click node_server_storage "https://github.com/skerkour/black-hat-rust/tree/main/ch_11/server/src/repository"
click node_shared_protocol "https://github.com/skerkour/black-hat-rust/blob/main/ch_11/common/src/api.rs"
click node_crypto "https://github.com/skerkour/black-hat-rust/blob/main/ch_11/common/src/crypto.rs"
click node_multiplatform "https://github.com/skerkour/black-hat-rust/tree/main/ch_12/rat/agent/src/install"
click node_worm_spread "https://github.com/skerkour/black-hat-rust/blob/main/ch_13/rat/agent/src/spread.rs"
click node_email_templates "https://github.com/skerkour/black-hat-rust/blob/main/ch_09/emails/src/template.rs"

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_scanner_cli,node_dns,node_port_scan,node_common_ports,node_scan_modules,node_async_scanner,node_subdomain_enum,node_crawler,node_spiders toneBlue
class node_fuzzing,node_exploits,node_shellcode toneAmber
class node_phishing_web,node_phishing_server,node_email_delivery toneMint
class node_agent,node_operator_client,node_control_server,node_server_services,node_server_storage,node_shared_protocol,node_crypto,node_multiplatform,node_worm_spread toneRose
class node_email_templates,node_operator toneIndigo
```

## Components

### Reconnaissance

- [Scanner CLI](https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/cli.rs): `ch_04/tricoder/src/cli.rs`
- [DNS discovery](https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/dns.rs): `ch_04/tricoder/src/dns.rs`
- [Port scanning](https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/ports.rs): `ch_04/tricoder/src/ports.rs`
- [Common ports](https://github.com/skerkour/black-hat-rust/blob/main/ch_04/tricoder/src/common_ports.rs): `ch_04/tricoder/src/common_ports.rs`
- [Scan modules](https://github.com/skerkour/black-hat-rust/tree/main/ch_04/tricoder/src/modules): `ch_04/tricoder/src/modules`
- [Async scanner](https://github.com/skerkour/black-hat-rust/blob/main/ch_03/tricoder/src/main.rs): `ch_03/tricoder/src/main.rs`
- [Subdomain enumeration](https://github.com/skerkour/black-hat-rust/blob/main/ch_03/tricoder/src/subdomains.rs): `ch_03/tricoder/src/subdomains.rs`
- [Web crawler](https://github.com/skerkour/black-hat-rust/blob/main/ch_05/crawler/src/crawler.rs): `ch_05/crawler/src/crawler.rs`
- [Crawler spiders](https://github.com/skerkour/black-hat-rust/tree/main/ch_05/crawler/src/spiders): `ch_05/crawler/src/spiders`

### Exploitation

- [Fuzzing](https://github.com/skerkour/black-hat-rust/blob/main/ch_06/fuzzing/src/lib.rs): `ch_06/fuzzing/src/lib.rs`
- [Exploit examples](https://github.com/skerkour/black-hat-rust/tree/main/ch_07/exploits): `ch_07/exploits`
- [Shellcode examples](https://github.com/skerkour/black-hat-rust/tree/main/ch_08): `ch_08`

### Phishing

- [Phishing web app](https://github.com/skerkour/black-hat-rust/tree/main/ch_09/phishing/webapp): `ch_09/phishing/webapp`
- [Phishing server](https://github.com/skerkour/black-hat-rust/blob/main/ch_09/phishing/server/src/main.rs): `ch_09/phishing/server/src/main.rs`
- [Email delivery](https://github.com/skerkour/black-hat-rust/blob/main/ch_09/emails/src/main.rs): `ch_09/emails/src/main.rs`

### Implant development

- [Remote agent](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/agent/src/run.rs): `ch_11/agent/src/run.rs`
- [Operator client](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/client/src/main.rs): `ch_11/client/src/main.rs`
- [Control server](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/server/src/main.rs): `ch_11/server/src/main.rs`
- [Server services](https://github.com/skerkour/black-hat-rust/tree/main/ch_11/server/src/service): `ch_11/server/src/service`
- [Server persistence](https://github.com/skerkour/black-hat-rust/tree/main/ch_11/server/src/repository): `ch_11/server/src/repository`
- [Shared protocol](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/common/src/api.rs): `ch_11/common/src/api.rs`
- [Message encryption](https://github.com/skerkour/black-hat-rust/blob/main/ch_11/common/src/crypto.rs): `ch_11/common/src/crypto.rs`
- [Cross-platform install](https://github.com/skerkour/black-hat-rust/tree/main/ch_12/rat/agent/src/install): `ch_12/rat/agent/src/install`
- [Worm spreading](https://github.com/skerkour/black-hat-rust/blob/main/ch_13/rat/agent/src/spread.rs): `ch_13/rat/agent/src/spread.rs`

### Supporting examples

- [Email templates](https://github.com/skerkour/black-hat-rust/blob/main/ch_09/emails/src/template.rs): `ch_09/emails/src/template.rs`

### Other components

- **Tool operator**

## Connections

- Tool operator → Scanner CLI: runs scan
- Scanner CLI → DNS discovery: discovers hosts (evidence: `ch_04/tricoder/src/cli.rs`)
- Scanner CLI → Port scanning: scans ports (evidence: `ch_04/tricoder/src/cli.rs`)
- Scanner CLI → Scan modules: dispatches modules (evidence: `ch_04/tricoder/src/cli.rs`)
- Tool operator → Async scanner: runs scan (evidence: `ch_03/tricoder/src/main.rs`)
- Async scanner → Subdomain enumeration: enumerates domains (evidence: `ch_03/tricoder/src/main.rs`)
- Tool operator → Web crawler: selects spider
- Web crawler → Crawler spiders: runs spider (evidence: `ch_05/crawler/src/main.rs`)
- Fuzzing → Exploit examples: finds vulnerabilities (evidence: `README.md`)
- Exploit examples → Shellcode examples: develops payloads
- Phishing web app → Phishing server: submits login
- Email templates → Email delivery: renders message (evidence: `ch_09/emails/src/main.rs`)
- Tool operator → Operator client: issues commands (evidence: `README.md`)
- Operator client → Control server: sends requests (evidence: `README.md`)
- Control server → Server services: dispatches operations (evidence: `ch_11/server/src/main.rs`)
- Server services → Server persistence: uses persistence
- Remote agent → Control server: communicates remotely (evidence: `README.md`)
- Remote agent → Shared protocol: uses protocol
- Message encryption → Shared protocol: secures messages (evidence: `README.md`)
- Cross-platform install → Remote agent: installs agent (evidence: `README.md`)
- Worm spreading → Remote agent: extends reach (evidence: `README.md`)
