Find the fastest, most damaging paths to your Active Directory crown jewels — then fix them.
BloodTrace is a self-hosted Active Directory attack-path analyzer for pentesters and blue teamers. It ingests BloodHound CE exports, maps high-value targets through a NetworkX attack graph, and ranks every path by risk so you know what to remediate first. Multi-provider AI turns each finding into an attack narrative and concrete remediation commands, exportable as a PDF report.
- Attack-path detection — enumerates reachable paths to Domain Controllers, Domain Admins, KRBTGT, and other high-value targets.
- Risk scoring — every path is scored from target criticality, path length, edge severity, and exploitation-enabling tags, then classified into severity bands.
- Bottleneck analysis — correlates paths to rank the highest-leverage nodes to remediate, with estimated risk reduction.
- AI explanations — one-click attack walkthroughs and copy-paste remediation commands from the provider of your choice; results are cached locally so reloading a session costs nothing.
- PDF reports — one-click report generation with summary stats, findings table, path details, bottlenecks, and AI explanations.
- Session storage — analyses are saved locally with a 5-session cap; the oldest is replaced (with confirmation) when exceeded.
- Self-hosted — Dockerized, all data stays on disk; optional
AI_MASTER_KEYencrypts stored API keys.
- Docker + Docker Compose (recommended path), or
- Python 3.11+ and
pipfor a native run. - A BloodHound CE / SharpHound JSON export (zip or raw JSON).
- An API key for at least one AI provider to use AI explanations (optional — a local mock fallback is used otherwise).
git clone https://github.com/yassertioursi/blood-trace
cd ad-blood-trace
docker compose up -d --buildFor a native run:
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
uvicorn backend.app.main:app --host 0.0.0.0 --port 8000docker compose up -d --buildThen open http://localhost:8000, drop a BloodHound zip or JSON export onto the upload card, and hit Analyze. Findings, bottleneck analysis, AI explanations, and PDF reports are available from the Dashboard and Sessions views.
| Provider | Default model | Notes |
|---|---|---|
| Gemini | gemini-3.6-flash |
Free tier works; retries on slow/empty responses |
| OpenAI | gpt-4o-mini |
OpenAI-compatible API |
| Claude | claude-sonnet-4-20250514 |
Native Anthropic /v1/messages API |
| Groq | llama-3.3-70b-versatile |
Fast OpenAI-compatible endpoints |
| OpenRouter | openai/gpt-4o-mini |
Route to many models via one key |
| Ollama | llama3.1 |
Keyless, local (uses host.docker.internal) |
- Open Settings → AI provider settings.
- Pick a provider, paste your API key, and click Save settings.
- Leave Model and Base URL blank to use the provider defaults (they auto-fill and are validated; wrong base URLs are corrected on save).
- A live connection test runs automatically after saving.
- Set the
AI_MASTER_KEYenvironment variable before first use to encrypt stored keys at rest — otherwise keys are stored in plaintext indata/ai_providers.json.
SharpHound exports are consumed directly; session data is optional but improves edge quality:
# Full collection (recommended)
SharpHound.exe -c All --OutputDirectory C:\BH --ZipFilename bloodhound.zip
# Lean collection
SharpHound.exe -c Default
# Collection relevant for path analysis
SharpHound.exe -c Group,LocalAdmin,Session,RDP,DCOnly,Trusts- BloodHound CE / SharpHound JSON files:
users.json,computers.json,groups.json,domains.json,gpos.json,ous.json,containers.json(upload individually). - A zip archive containing any of the above (extracted securely server-side, guarded against zip-slip and zip-bomb payloads).
ad-blood-trace/
├── backend/app/
│ ├── api/routes/ # upload, findings, sessions, settings, status
│ ├── models/contracts.py # Pydantic source-of-truth schemas
│ └── services/
│ ├── parser.py # BloodHound JSON → normalized GraphDocument
│ ├── graph_builder.py# NetworkX attack graph
│ ├── path_finder.py # shortest + simple paths → AttackPath
│ ├── scoring.py # risk scores and severity bands
│ ├── correlator.py # bottleneck / remediation ranking
│ ├── report.py # fpdf2 PDF report generation
│ ├── session.py # session metadata + 5-session cap
│ ├── jobs.py # async analysis job queue
│ └── ai/ # provider abstraction, cache, settings
├── frontend/src/api/ # TypeScript contracts mirroring backend models
├── backend/app/static/ # served SPA (vanilla JS)
├── backend/tests/ # pytest suite (42 tests)
├── docker-compose.yml
├── Dockerfile
└── requirements.txt
- Parser — SharpHound JSON (or zip) is validated and normalized into a
GraphDocumentof nodes and edges. - Graph — nodes and edges are typed and tagged (kerberoastable, unconstrained delegation, AD CS, etc.), and a directed NetworkX attack graph is built.
- Path finder — reachable paths to high-value targets are enumerated (all simple paths up to a cutoff, deduplicated for overlaps).
- Scorer — each
AttackPathis scored from target tier, hop count, worst edge, and enrichment tags, then classified by severity. - Correlator — paths are correlated to identify bottlenecks: nodes whose remediation eliminates the most critical/high paths, with a computed risk-reduction percentage and remediation commands.
- AI — on demand, each finding is sent to the configured provider for an attack walkthrough and PowerShell remediation commands; results are cached per session/provider with a 24h TTL and served instantly on reload.
- Report — summary, findings table, path details, bottlenecks, and AI explanations are compiled into a downloadable PDF.
A path score (0–100) is the sum of component scores, optionally multiplied by 1.25 when the source is owned (already compromised).
| Component | Contribution | Notes |
|---|---|---|
| Target tier | 20–40 | KRBTGT 40, Domain Controller 38, Domain Admins 36, Enterprise Admins 35, CA Server 30, AdminCount=1 25, High-Value 20 |
| Path length | 3–30 | 1 hop = 30, down to 7 at 5 hops, 3 for 6+ |
| Worst edge | 5–20 | DCSync/GenericAll 20, WriteDACL 18, WriteOwner 17, AllowedToDelegate 16 … down to CanRDP 5 |
| Enrichment tags | 5–12 each | unconstrained_delegation +12, kerberoastable +10, AD CS +10, AS-REP +8, SIDHistory +8, through_DC +5 |
| Owned source | ×1.25 | Multiplier applied when the entry point is already compromised |
| Band | Range |
|---|---|
| Critical | ≥ 85 |
| High | 65 – 84 |
| Medium | 45 – 64 |
| Low | < 45 |
- Custom query / cypher input for path enumeration limits.
- Scheduled re-analysis and drift detection between exports.
- Exportable remediation playbooks (Markdown / CSV) alongside PDF.
- Authentication for multi-user deployments.
- CI/CD with end-to-end browser tests.
Contributions are welcome. Please:
- Open an issue for feature requests or bugs.
- Keep backend Pydantic models the source of truth for schemas; mirror changes in
frontend/src/api/types.ts. - Add tests under
backend/tests/(run withpytest) and keep the suite green before opening a PR.
Released under the MIT License. You are free to use, modify, and distribute this software, provided the license notice is retained. See the repository license file for full terms.
For authorized testing only. BloodTrace is a security analysis tool; use it exclusively on systems you own or are explicitly authorized to assess. Attack-path analysis and AI-generated remediation advice are heuristic and may be incomplete or incorrect — validate all findings and commands against your environment before acting. The authors are not liable for misuse or for any damage resulting from the use of this tool.
