Skip to main content

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 --edition flag
  • 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

  1. Add method to BloodHoundClient base class
  2. Implement in both BloodHoundLegacyClient and BloodHoundCEClient
  3. Add CLI command in main.py
  4. 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

  1. Fork the repository
  2. Create a feature branch
  3. Add tests for new functionality
  4. Ensure all tests pass
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bloodhound_cli-1.2.1.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bloodhound_cli-1.2.1-py3-none-any.whl (37.4 kB view details)

Uploaded Python 3

File details

Details for the file bloodhound_cli-1.2.1.tar.gz.

File metadata

  • Download URL: bloodhound_cli-1.2.1.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for bloodhound_cli-1.2.1.tar.gz
Algorithm Hash digest
SHA256 5cc54b76f83d64eda5f0baa92367de39699f7afc9945644bd719c7e3c0f0952d
MD5 ddf1d195ecd2bdf66c4ef717b9eadba3
BLAKE2b-256 db6fccaf8286342d20211454668086a68c8705369f79b3ce6abb7428bcb0f081

See more details on using hashes here.

File details

Details for the file bloodhound_cli-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: bloodhound_cli-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 37.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for bloodhound_cli-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 63835a4240e0cc8471a65408d8d85437b45ff24b58ca98125d486a146828c9c7
MD5 b9c28ca08678733b1f3c6d59b919ee48
BLAKE2b-256 0b8e4a0183771d845af23d366fcf1f582bf9dd1c343232716dcab102e2e6d9df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page