CLI for querying BloodHound data (Legacy Neo4j + CE skeleton).
Project description
bloodhound-cli
bloodhound-cli is a Python command-line tool designed to query and manage data from BloodHound with support for both Legacy (Neo4j) and Community Edition (CE) backends.
๐๏ธ Modular Architecture
The CLI now features a clean, modular architecture that eliminates code duplication and follows best practices:
src/bloodhound_cli/
โโโ core/
โ โโโ base.py # Abstract base class with common interface
โ โโโ legacy.py # Neo4j implementation
โ โโโ ce.py # HTTP API implementation
โ โโโ factory.py # Factory pattern for client creation
โโโ main.py # CLI entry point
โโโ tests/ # Comprehensive test suite
โจ Key Features
๐ Dual Backend Support
- Legacy (Neo4j): Full feature set with direct Neo4j queries
- Community Edition (CE): HTTP API integration with BloodHound CE
๐ฏ Unified Interface
- Same commands work with both backends
- Automatic client selection based on
--editionflag - No code duplication - queries centralized in base classes
๐งช Comprehensive Testing
- Unit tests with mocks for isolated testing
- Integration tests with real BloodHound CE and GOAD data
- Docker-based test environment with realistic data
๐ง Advanced Query Support
- User enumeration with domain filtering
- Computer enumeration with LAPS filtering
- Admin and high-value user detection
- Password policy analysis
- Session and access path queries
๐ Installation
Recommended: pipx (isolated environment)
pipx install bloodhound-cli
Alternative: pip
pip install bloodhound-cli
Development: from source
git clone https://github.com/ADScanPro/bloodhound-cli.git
cd bloodhound-cli
pip install -e .
๐ Usage
Basic Commands
List Users
# Legacy (Neo4j)
bloodhound-cli --edition legacy user -d mydomain.local
# Community Edition (CE)
bloodhound-cli --edition ce user -d mydomain.local
List Computers
# All computers
bloodhound-cli --edition ce computer -d mydomain.local
# Filter by LAPS
bloodhound-cli --edition ce computer -d mydomain.local --laps true
Admin Users
bloodhound-cli --edition ce admin -d mydomain.local
High Value Users
bloodhound-cli --edition ce highvalue -d mydomain.local
Connection Configuration
Legacy (Neo4j)
bloodhound-cli --edition legacy user -d mydomain.local \
--uri bolt://localhost:7687 \
--user neo4j \
--password mypassword
Community Edition (CE)
bloodhound-cli --edition ce user -d mydomain.local \
--base-url http://localhost:8080 \
--username admin \
--ce-password Bloodhound123!
Debug and Verbose Output
bloodhound-cli --edition ce --debug --verbose user -d mydomain.local
๐งช Testing
Unit Tests
pytest tests/unit/ -v
Integration Tests
# Requires BloodHound CE running
pytest tests/integration/ -v
Full Test Suite with GOAD Data
# Setup test environment with GOAD data
./scripts/setup-complete.sh
./scripts/test-with-goad-domains.sh
๐๏ธ Architecture Benefits
โ No Code Duplication
- Queries defined once in base classes
- Legacy and CE implementations inherit common interface
- Changes propagate automatically to both backends
โ Easy Extension
- Add new queries by implementing abstract methods
- Factory pattern handles client creation
- Clean separation of concerns
โ Comprehensive Testing
- Unit tests with mocks for fast feedback
- Integration tests with real data
- Docker-based test environment
โ Maintainable Code
- Clear separation between CLI, core logic, and implementations
- Type hints and documentation
- Follows Python best practices
๐ง Development
Project Structure
bloodhound-cli/
โโโ src/bloodhound_cli/
โ โโโ core/ # Core business logic
โ โโโ main.py # CLI entry point
โ โโโ __init__.py
โโโ tests/ # Test suite
โโโ scripts/ # Automation scripts
โโโ test-data/ # Test data (GOAD)
Adding New Queries
- Add method to
BloodHoundClientbase class - Implement in both
BloodHoundLegacyClientandBloodHoundCEClient - Add CLI command in
main.py - Create tests in
tests/
Testing Strategy
- Unit Tests: Mock external dependencies
- Integration Tests: Real BloodHound CE with GOAD data
- CI/CD: Automated testing with Docker
๐ Supported Domains (GOAD Test Data)
The project includes comprehensive test data from GOAD (Game of Active Directory):
- north.sevenkingdoms.local: House Stark domain
- essos.local: Daenerys Targaryen domain
- sevenkingdoms.local: King's Landing domain
๐ฏ Roadmap
- Complete all Legacy queries for CE
- Add more advanced query capabilities
- Enhanced error handling and logging
- Performance optimizations
- Additional test coverage
๐ License
This project is licensed under the MIT License.
๐ค Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
๐ Support
For issues and questions:
- Create an issue on GitHub
- Check the test suite for usage examples
- Review the integration tests for setup guidance
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bloodhound_cli-1.1.2.tar.gz.
File metadata
- Download URL: bloodhound_cli-1.1.2.tar.gz
- Upload date:
- Size: 30.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e40715189999186d8dd0fc3beebd24ffcbca0c339678f5b2182732e781289db5
|
|
| MD5 |
99653b29abb077a9d0bba172cdd9fe1b
|
|
| BLAKE2b-256 |
0d25e398b49a286c14967e2b9f48f0cca8cb8875526b6a87c205f1a497c168f4
|
File details
Details for the file bloodhound_cli-1.1.2-py3-none-any.whl.
File metadata
- Download URL: bloodhound_cli-1.1.2-py3-none-any.whl
- Upload date:
- Size: 31.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.23
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
148c568485ad96b16d5155b0f282ceb61108d7f67b4a79692f236de1ced394f6
|
|
| MD5 |
d8981f0978bd161a4e29762c21e2379b
|
|
| BLAKE2b-256 |
26c851d0aad6325cd4038df56d66e556e619a8f255ea5b1af8aea97f8bcad85d
|