# specterops/sharphound architecture

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

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

## Overview

SharpHound is a .NET command-line collector that gathers Active Directory and computer data for BloodHound. An operator supplies collection options; the application initializes and validates a domain context, discovers enumeration domains, runs a collection task, processes results, and writes output. Distinct collection modes include LDAP queries, stealth collection, and computer-file targeting; optional looped collection packages results. The map preserves major documented collection capabilities, but several internal links are omitted where sampled source does not show the caller or data transfer.

Main entry points: [`src/Runtime/CollectionTask.cs`](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/CollectionTask.cs) (Collection task), [`src/SharpLinks.cs`](https://github.com/specterops/sharphound/blob/2.X/src/SharpLinks.cs) (Setup workflow), [`src/Sharphound.cs`](https://github.com/specterops/sharphound/blob/2.X/src/Sharphound.cs) (CLI entry), [`src/Runtime/ObjectProcessors.cs`](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/ObjectProcessors.cs) (Object processors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI and setup"]
  node_cli["CLI entry<br/>[Sharphound.cs]"]
  node_options["Options<br/>[Options.cs]"]
  node_context["Run context<br/>[BaseContext.cs]"]
  node_links["Setup workflow<br/>[SharpLinks.cs]"]
  node_domain["Domain model"]
end

subgraph group_collect["Collection"]
  node_task["Collection task<br/>[CollectionTask.cs]"]
  node_ldapproducer["LDAP collection<br/>[LdapProducer.cs]"]
  node_stealth["Stealth collection<br/>[StealthProducer.cs]"]
  node_computerfile["Computer-file collection"]
end

subgraph group_process["Processing"]
  node_ldapconsumer["LDAP consumer<br/>[LDAPConsumer.cs]"]
  node_processors["Object processors"]
  node_ldaputils["LDAP helpers<br/>[ClientHelpers.cs]"]
end

subgraph group_output["Output and repeat"]
  node_outputwriter["Output writer<br/>[OutputWriter.cs]"]
  node_jsonwriter["JSON writer<br/>[JsonDataWriter.cs]"]
  node_statuswriter["Status writer"]
  node_loop["Loop manager<br/>[LoopManager.cs]"]
end

node_operator(("Operator"))
node_directory[("Active Directory")]
node_files["Output files"]

node_operator -->|"runs"| node_cli
node_cli -->|"parses"| node_options
node_cli -->|"invokes"| node_links
node_links -->|"initializes"| node_context
node_links -->|"tests connection"| node_directory
node_links -->|"discovers"| node_domain
node_links -->|"starts"| node_task
node_task -->|"dispatches"| node_ldapproducer
node_task -->|"dispatches"| node_stealth
node_task -->|"dispatches"| node_computerfile
node_ldapproducer -.->|"queries"| node_directory
node_stealth -.->|"queries"| node_directory
node_computerfile -.->|"collects from"| node_directory
node_task -->|"processes entries"| node_processors
node_task -.->|"feeds"| node_ldapconsumer
node_processors -.->|"reads properties"| node_directory
node_processors -->|"uses helpers"| node_ldaputils
node_task -->|"starts writer"| node_outputwriter
node_outputwriter -->|"writes JSON"| node_jsonwriter
node_task -->|"starts writer"| node_statuswriter
node_outputwriter -.->|"writes results"| node_files
node_links -.->|"starts looping"| node_loop
node_loop -->|"repeats collection"| node_task
node_loop -->|"packages results"| node_files

click node_cli "https://github.com/specterops/sharphound/blob/2.X/src/Sharphound.cs"
click node_options "https://github.com/specterops/sharphound/blob/2.X/src/Options.cs"
click node_context "https://github.com/specterops/sharphound/blob/2.X/src/BaseContext.cs"
click node_links "https://github.com/specterops/sharphound/blob/2.X/src/SharpLinks.cs"
click node_domain "https://github.com/specterops/sharphound/blob/2.X/src/EnumerationDomain.cs"
click node_task "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/CollectionTask.cs"
click node_ldapproducer "https://github.com/specterops/sharphound/blob/2.X/src/Producers/LdapProducer.cs"
click node_stealth "https://github.com/specterops/sharphound/blob/2.X/src/Producers/StealthProducer.cs"
click node_computerfile "https://github.com/specterops/sharphound/blob/2.X/src/Producers/ComputerFileProducer.cs"
click node_ldapconsumer "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/LDAPConsumer.cs"
click node_processors "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/ObjectProcessors.cs"
click node_ldaputils "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/ClientHelpers.cs"
click node_outputwriter "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/OutputWriter.cs"
click node_jsonwriter "https://github.com/specterops/sharphound/blob/2.X/src/Writers/JsonDataWriter.cs"
click node_statuswriter "https://github.com/specterops/sharphound/blob/2.X/src/Writers/CompStatusWriter.cs"
click node_loop "https://github.com/specterops/sharphound/blob/2.X/src/Runtime/LoopManager.cs"

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_options,node_context,node_links,node_domain toneBlue
class node_task,node_ldapproducer,node_stealth,node_computerfile,node_directory toneAmber
class node_ldapconsumer,node_processors,node_ldaputils toneMint
class node_outputwriter,node_jsonwriter,node_statuswriter,node_loop toneRose
class node_operator,node_files toneIndigo
```

## Components

### CLI and setup

- [CLI entry](https://github.com/specterops/sharphound/blob/2.X/src/Sharphound.cs): `src/Sharphound.cs`
- [Options](https://github.com/specterops/sharphound/blob/2.X/src/Options.cs): `src/Options.cs`
- [Run context](https://github.com/specterops/sharphound/blob/2.X/src/BaseContext.cs): `src/BaseContext.cs`
- [Setup workflow](https://github.com/specterops/sharphound/blob/2.X/src/SharpLinks.cs): `src/SharpLinks.cs`
- [Domain model](https://github.com/specterops/sharphound/blob/2.X/src/EnumerationDomain.cs): `src/EnumerationDomain.cs`

### Collection

- [Collection task](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/CollectionTask.cs): `src/Runtime/CollectionTask.cs`
- [LDAP collection](https://github.com/specterops/sharphound/blob/2.X/src/Producers/LdapProducer.cs): `src/Producers/LdapProducer.cs`
- [Stealth collection](https://github.com/specterops/sharphound/blob/2.X/src/Producers/StealthProducer.cs): `src/Producers/StealthProducer.cs`
- [Computer-file collection](https://github.com/specterops/sharphound/blob/2.X/src/Producers/ComputerFileProducer.cs): `src/Producers/ComputerFileProducer.cs`

### Processing

- [LDAP consumer](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/LDAPConsumer.cs): `src/Runtime/LDAPConsumer.cs`
- [Object processors](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/ObjectProcessors.cs): `src/Runtime/ObjectProcessors.cs`
- [LDAP helpers](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/ClientHelpers.cs): `src/Runtime/ClientHelpers.cs`

### Output and repeat

- [Output writer](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/OutputWriter.cs): `src/Runtime/OutputWriter.cs`
- [JSON writer](https://github.com/specterops/sharphound/blob/2.X/src/Writers/JsonDataWriter.cs): `src/Writers/JsonDataWriter.cs`
- [Status writer](https://github.com/specterops/sharphound/blob/2.X/src/Writers/CompStatusWriter.cs): `src/Writers/CompStatusWriter.cs`
- [Loop manager](https://github.com/specterops/sharphound/blob/2.X/src/Runtime/LoopManager.cs): `src/Runtime/LoopManager.cs`

### Other components

- **Operator**
- **Active Directory**
- **Output files**

## Connections

- Operator → CLI entry: runs (evidence: `README.md`)
- CLI entry → Options: parses (evidence: `src/Sharphound.cs`)
- CLI entry → Setup workflow: invokes (evidence: `src/Sharphound.cs`)
- Setup workflow → Run context: initializes (evidence: `src/SharpLinks.cs`)
- Setup workflow → Active Directory: tests connection (evidence: `src/SharpLinks.cs`)
- Setup workflow → Domain model: discovers (evidence: `src/SharpLinks.cs`)
- Setup workflow → Collection task: starts (evidence: `src/SharpLinks.cs`)
- Collection task → LDAP collection: dispatches (evidence: `src/Runtime/CollectionTask.cs`)
- Collection task → Stealth collection: dispatches (evidence: `src/Runtime/CollectionTask.cs`)
- Collection task → Computer-file collection: dispatches (evidence: `src/Runtime/CollectionTask.cs`)
- LDAP collection → Active Directory: queries
- Stealth collection → Active Directory: queries
- Computer-file collection → Active Directory: collects from
- Collection task → Object processors: processes entries (evidence: `src/Runtime/CollectionTask.cs`)
- Collection task → LDAP consumer: feeds
- Object processors → Active Directory: reads properties
- Object processors → LDAP helpers: uses helpers (evidence: `src/Runtime/ObjectProcessors.cs`)
- Collection task → Output writer: starts writer (evidence: `src/Runtime/CollectionTask.cs`)
- Output writer → JSON writer: writes JSON (evidence: `src/Runtime/OutputWriter.cs`)
- Collection task → Status writer: starts writer (evidence: `src/Runtime/CollectionTask.cs`)
- Output writer → Output files: writes results
- Setup workflow → Loop manager: starts looping (evidence: `src/SharpLinks.cs`)
- Loop manager → Collection task: repeats collection (evidence: `src/Runtime/LoopManager.cs`)
- Loop manager → Output files: packages results (evidence: `src/Runtime/LoopManager.cs`)
