# specterops/mssqlhound architecture

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

- Interactive diagram: https://gitdiagram.com/specterops/mssqlhound
- Repository: https://github.com/specterops/mssqlhound

## Overview

MSSQLHound is a Go collector that turns SQL Server security and relationship data into BloodHound OpenGraph output. The main workflow starts at the CLI, optionally discovers SQL Server SPNs or domain computers, collects SQL Server metadata and permissions, builds graph nodes and edges, and writes output for optional BloodHound upload. A separate EPA-matrix command configures SQL Server settings remotely and tests authentication behavior. The collector excerpt shows its orchestration dependencies; some detailed subsystem links are documented in the README rather than sampled source.

Main entry points: [`internal/collector/collector.go`](https://github.com/specterops/mssqlhound/blob/main/internal/collector/collector.go) (Collector), [`internal/mssql/client.go`](https://github.com/specterops/mssqlhound/blob/main/internal/mssql/client.go) (SQL Collection), [`cmd/mssqlhound/cmd_test_epa_matrix.go`](https://github.com/specterops/mssqlhound/blob/main/cmd/mssqlhound/cmd_test_epa_matrix.go) (EPA Matrix Command), [`internal/epamatrix/epamatrix.go`](https://github.com/specterops/mssqlhound/blob/main/internal/epamatrix/epamatrix.go) (EPA Matrix Runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_collection["Collection"]
  node_cli["CLI<br/>[main.go]"]
  node_collector["Collector<br/>[collector.go]"]
  node_sql_collection["SQL Collection<br/>[client.go]"]
  node_cve_detection["CVE Detection<br/>[cve.go]"]
  node_shared_types["Shared Types<br/>[types.go]"]
end

subgraph group_graph_output["Graph Output"]
  node_graph_model["Graph Edge Model<br/>[edges.go]"]
  node_graph_writer["Graph Writer<br/>[writer.go]"]
  node_output_files["Output Archive<br/>[collector.go]"]
end

subgraph group_integrations["Integrations"]
  node_ad_discovery["AD Discovery<br/>[client.go]"]
  node_domain_computers["Computer Enumeration<br/>[adsi_windows.go]"]
  node_wmi["WMI Enumeration<br/>[wmi_windows.go]"]
  node_proxy["SOCKS Proxy<br/>[proxydialer.go]"]
  node_upload_client["Upload Client<br/>[client.go]"]
  node_bloodhound[("BloodHound")]
end

subgraph group_diagnostics["EPA Diagnostics"]
  node_epa_command["EPA Matrix Command"]
  node_epa_matrix["EPA Matrix Runner<br/>[epamatrix.go]"]
  node_winrm["WinRM Client<br/>[winrmclient.go]"]
end

node_operator(("Operator"))
node_sql_server[("SQL Server")]
node_remote_host["Remote Windows Host"]

node_operator -->|"configures and runs"| node_cli
node_cli -->|"starts collection"| node_collector
node_collector -->|"enumerates SPNs"| node_ad_discovery
node_ad_discovery -.->|"queries directory"| node_sql_server
node_collector -.->|"enumerates computers"| node_domain_computers
node_collector -->|"collects SQL data"| node_sql_collection
node_sql_collection -.->|"queries"| node_sql_server
node_collector -.->|"checks CVEs"| node_cve_detection
node_collector -->|"queries service data"| node_wmi
node_collector -->|"configures proxy"| node_proxy
node_collector -->|"uses types"| node_shared_types
node_collector -->|"creates relationships"| node_graph_model
node_collector -->|"writes graph data"| node_graph_writer
node_collector -->|"packages output"| node_output_files
node_collector -->|"uploads results"| node_upload_client
node_upload_client -->|"sends graph files"| node_bloodhound
node_operator -->|"runs diagnostics"| node_epa_command
node_epa_command -->|"runs matrix"| node_epa_matrix
node_epa_command -->|"creates executor"| node_winrm
node_epa_matrix -->|"executes settings scripts"| node_winrm
node_epa_matrix -->|"tests EPA"| node_sql_collection
node_winrm -.->|"configures SQL settings"| node_remote_host
node_sql_collection -.->|"tests authentication"| node_sql_server

click node_cli "https://github.com/specterops/mssqlhound/blob/main/cmd/mssqlhound/main.go"
click node_collector "https://github.com/specterops/mssqlhound/blob/main/internal/collector/collector.go"
click node_ad_discovery "https://github.com/specterops/mssqlhound/blob/main/internal/ad/client.go"
click node_domain_computers "https://github.com/specterops/mssqlhound/blob/main/internal/collector/adsi_windows.go"
click node_sql_collection "https://github.com/specterops/mssqlhound/blob/main/internal/mssql/client.go"
click node_cve_detection "https://github.com/specterops/mssqlhound/blob/main/internal/collector/cve.go"
click node_wmi "https://github.com/specterops/mssqlhound/blob/main/internal/wmi/wmi_windows.go"
click node_proxy "https://github.com/specterops/mssqlhound/blob/main/internal/proxydialer/proxydialer.go"
click node_graph_model "https://github.com/specterops/mssqlhound/blob/main/internal/bloodhound/edges.go"
click node_graph_writer "https://github.com/specterops/mssqlhound/blob/main/internal/bloodhound/writer.go"
click node_output_files "https://github.com/specterops/mssqlhound/blob/main/internal/collector/collector.go"
click node_upload_client "https://github.com/specterops/mssqlhound/blob/main/internal/uploader/client.go"
click node_epa_command "https://github.com/specterops/mssqlhound/blob/main/cmd/mssqlhound/cmd_test_epa_matrix.go"
click node_epa_matrix "https://github.com/specterops/mssqlhound/blob/main/internal/epamatrix/epamatrix.go"
click node_winrm "https://github.com/specterops/mssqlhound/blob/main/internal/winrmclient/winrmclient.go"
click node_shared_types "https://github.com/specterops/mssqlhound/blob/main/internal/types/types.go"

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_cli,node_collector,node_sql_collection,node_cve_detection,node_shared_types toneBlue
class node_graph_model,node_graph_writer,node_output_files,node_sql_server toneAmber
class node_ad_discovery,node_domain_computers,node_wmi,node_proxy,node_upload_client,node_bloodhound toneMint
class node_epa_command,node_epa_matrix,node_winrm toneRose
class node_operator,node_remote_host toneIndigo
```

## Components

### Collection

- [CLI](https://github.com/specterops/mssqlhound/blob/main/cmd/mssqlhound/main.go): `cmd/mssqlhound/main.go`
- [Collector](https://github.com/specterops/mssqlhound/blob/main/internal/collector/collector.go): `internal/collector/collector.go`
- [SQL Collection](https://github.com/specterops/mssqlhound/blob/main/internal/mssql/client.go): `internal/mssql/client.go`
- [CVE Detection](https://github.com/specterops/mssqlhound/blob/main/internal/collector/cve.go): `internal/collector/cve.go`
- [Shared Types](https://github.com/specterops/mssqlhound/blob/main/internal/types/types.go): `internal/types/types.go`

### Graph Output

- [Graph Edge Model](https://github.com/specterops/mssqlhound/blob/main/internal/bloodhound/edges.go): `internal/bloodhound/edges.go`
- [Graph Writer](https://github.com/specterops/mssqlhound/blob/main/internal/bloodhound/writer.go): `internal/bloodhound/writer.go`
- [Output Archive](https://github.com/specterops/mssqlhound/blob/main/internal/collector/collector.go): `internal/collector/collector.go`

### Integrations

- [AD Discovery](https://github.com/specterops/mssqlhound/blob/main/internal/ad/client.go): `internal/ad/client.go`
- [Computer Enumeration](https://github.com/specterops/mssqlhound/blob/main/internal/collector/adsi_windows.go): `internal/collector/adsi_windows.go`
- [WMI Enumeration](https://github.com/specterops/mssqlhound/blob/main/internal/wmi/wmi_windows.go): `internal/wmi/wmi_windows.go`
- [SOCKS Proxy](https://github.com/specterops/mssqlhound/blob/main/internal/proxydialer/proxydialer.go): `internal/proxydialer/proxydialer.go`
- [Upload Client](https://github.com/specterops/mssqlhound/blob/main/internal/uploader/client.go): `internal/uploader/client.go`
- **BloodHound**

### EPA Diagnostics

- [EPA Matrix Command](https://github.com/specterops/mssqlhound/blob/main/cmd/mssqlhound/cmd_test_epa_matrix.go): `cmd/mssqlhound/cmd_test_epa_matrix.go`
- [EPA Matrix Runner](https://github.com/specterops/mssqlhound/blob/main/internal/epamatrix/epamatrix.go): `internal/epamatrix/epamatrix.go`
- [WinRM Client](https://github.com/specterops/mssqlhound/blob/main/internal/winrmclient/winrmclient.go): `internal/winrmclient/winrmclient.go`

### Other components

- **Operator**
- **SQL Server**
- **Remote Windows Host**

## Connections

- Operator → CLI: configures and runs (evidence: `cmd/mssqlhound/main.go`)
- CLI → Collector: starts collection (evidence: `cmd/mssqlhound/main.go`)
- Collector → AD Discovery: enumerates SPNs (evidence: `internal/collector/collector.go`)
- AD Discovery → SQL Server: queries directory (evidence: `README.md`)
- Collector → Computer Enumeration: enumerates computers (evidence: `README.md`)
- Collector → SQL Collection: collects SQL data (evidence: `internal/collector/collector.go`)
- SQL Collection → SQL Server: queries (evidence: `README.md`)
- Collector → CVE Detection: checks CVEs
- Collector → WMI Enumeration: queries service data (evidence: `internal/collector/collector.go`)
- Collector → SOCKS Proxy: configures proxy (evidence: `internal/collector/collector.go`)
- Collector → Shared Types: uses types (evidence: `internal/collector/collector.go`)
- Collector → Graph Edge Model: creates relationships (evidence: `internal/collector/collector.go`)
- Collector → Graph Writer: writes graph data (evidence: `internal/collector/collector.go`)
- Collector → Output Archive: packages output (evidence: `internal/collector/collector.go`)
- Collector → Upload Client: uploads results (evidence: `internal/collector/collector.go`)
- Upload Client → BloodHound: sends graph files (evidence: `internal/uploader/client.go`)
- Operator → EPA Matrix Command: runs diagnostics (evidence: `cmd/mssqlhound/cmd_test_epa_matrix.go`)
- EPA Matrix Command → EPA Matrix Runner: runs matrix (evidence: `cmd/mssqlhound/cmd_test_epa_matrix.go`)
- EPA Matrix Command → WinRM Client: creates executor (evidence: `cmd/mssqlhound/cmd_test_epa_matrix.go`)
- EPA Matrix Runner → WinRM Client: executes settings scripts (evidence: `internal/epamatrix/epamatrix.go`)
- EPA Matrix Runner → SQL Collection: tests EPA (evidence: `internal/epamatrix/epamatrix.go`)
- WinRM Client → Remote Windows Host: configures SQL settings (evidence: `README.md`)
- SQL Collection → SQL Server: tests authentication (evidence: `README.md`)
