|
| 1 | +# bloodhound-cli |
| 2 | + |
| 3 | +**bloodhound-cli** is a Python command-line tool designed to query and manage data from **BloodHound**. |
| 4 | + |
| 5 | +- Legacy (Neo4j-backed) is fully supported. |
| 6 | +- Community Edition (CE) is introduced with a pluggable client skeleton so behavior can be incrementally implemented without breaking legacy users. |
| 7 | + |
| 8 | +>CE support note: This CLI now includes an early CE client. Many CE features are placeholders. If you need the official SpecterOps CE installer CLI, see their project at `https://github.com/specterOps/bloodHound-cli`. |
| 9 | +
|
| 10 | +## Key Features |
| 11 | + |
| 12 | +1. **Configuration Management** |
| 13 | + |
| 14 | + - Save your Neo4j connection details (host, port, user, and password) to a local configuration file (`~/.bloodhound_config`) using the `set` subcommand. |
| 15 | + - The configuration file is stored with restricted permissions (`chmod 600`) to protect your sensitive credentials. |
| 16 | +2. **ACL Queries (`acl` subcommand)** |
| 17 | + |
| 18 | + - Enumerate ACLs related to a single user by specifying `-u/--user`. |
| 19 | + - Enumerate cross-domain ACLs for a domain by specifying `-d/--domain`. |
| 20 | + - Optionally exclude multiple domains with `-bd/--blacklist-domains`. |
| 21 | +3. **Computer Queries (`computer` subcommand)** |
| 22 | + |
| 23 | + - Enumerate computers within a specified domain (`-d`). |
| 24 | + - Optionally save results to a file (`-o`). |
| 25 | + - Filter by LAPS status (`--laps True/False`). |
| 26 | +4. **User Queries (`user` subcommand)** |
| 27 | + |
| 28 | + - Enumerate users within a specified domain (`-d`). |
| 29 | + - Optionally save results to a file (`-o`). |
| 30 | + - Use mutually exclusive filters to target specific user attributes: |
| 31 | + - `--admin-count`: Show only privileged (admin) users. |
| 32 | + - `--high-value`: Show only high-value users. |
| 33 | + - `--password-not-required`: Show only users with `passwordnotreqd` enabled. |
| 34 | + - `--password-never-expires`: Show only users with `pwdneverexpires` enabled. |
| 35 | +5. **Session and Access Queries** |
| 36 | + |
| 37 | + - Query sessions and access path relations in a domain (legacy). |
| 38 | + |
| 39 | +6. **Debug and Verbose Output** |
| 40 | + |
| 41 | + - Global flags `--debug` and `--verbose` enhance output. When available, output is formatted with `rich`. |
| 42 | + |
| 43 | +7. **Secure Credential Storage** |
| 44 | + |
| 45 | + - The `set` subcommand saves your Neo4j credentials in a local file (`~/.bloodhound_config`) which is excluded from source control and has strict file permissions. |
| 46 | + |
| 47 | +## Installation |
| 48 | + |
| 49 | +It is recommended to install **bloodhound-cli** using [pipx](https://github.com/pipxproject/pipx) to ensure it runs in an isolated environment. You can install it from PyPI: |
| 50 | + |
| 51 | +```sh |
| 52 | +pipx install bloodhound-cli |
| 53 | +``` |
| 54 | + |
| 55 | +Alternatively, you can use pip: |
| 56 | + |
| 57 | +```sh |
| 58 | +pip install bloodhound-cli |
| 59 | +``` |
| 60 | + |
| 61 | +## Usage |
| 62 | + |
| 63 | +1. **Set Neo4j (Legacy) Configuration** |
| 64 | + |
| 65 | + ```sh |
| 66 | + bloodhound-cli set --host <neo4j_host> --port <neo4j_port> --db-user <neo4j_user> --db-password <neo4j_password> |
| 67 | + ``` |
| 68 | + |
| 69 | +2. **Set CE Configuration (optional, early support)** |
| 70 | + |
| 71 | + (Removed) Use the auth subcommand passing --base-url and credentials instead. |
| 72 | + |
| 73 | +3. **Authenticate to CE (generate and store token)** |
| 74 | + |
| 75 | + ```sh |
| 76 | + bloodhound-cli --edition ce auth --url http://localhost:7474 --username <user> |
| 77 | + # It will prompt for the password securely |
| 78 | + # Optional flags: |
| 79 | + # --password <pass> |
| 80 | + # --login-path /api/v2/login |
| 81 | + # --insecure |
| 82 | + ``` |
| 83 | + |
| 84 | +4. **Run in a chosen edition** |
| 85 | + |
| 86 | + - The default edition can be persisted in `~/.bloodhound_config` under `[GENERAL] edition`. |
| 87 | + Running `set` will store `legacy`; running `auth` will store `ce`. |
| 88 | + |
| 89 | + - To target CE explicitly: |
| 90 | + |
| 91 | + ```sh |
| 92 | + bloodhound-cli --edition ce user --domain mydomain.local |
| 93 | + ``` |
| 94 | + |
| 95 | + - Or via env var: |
| 96 | + |
| 97 | + ```sh |
| 98 | + BLOODHOUND_EDITION=ce bloodhound-cli user --domain mydomain.local |
| 99 | + ``` |
| 100 | + |
| 101 | +5. **Upload collector artifacts to CE (v2 file-upload flow)** |
| 102 | + |
| 103 | + ```sh |
| 104 | + bloodhound-cli --edition ce upload \ |
| 105 | + -f data1.zip data2.json \ |
| 106 | + --start-path /api/v2/file-upload/start \ |
| 107 | + --upload-path /api/v2/file-upload/{job_id} \ |
| 108 | + --end-path /api/v2/file-upload/{job_id}/end |
| 109 | + # Optional flags: |
| 110 | + # --content-type application/zip|application/json (auto-detected if omitted) |
| 111 | + # --insecure |
| 112 | + ``` |
| 113 | + |
| 114 | +6. **Enumerate ACLs** |
| 115 | + |
| 116 | + - **For a single user:** |
| 117 | + |
| 118 | + ```sh |
| 119 | + bloodhound-cli acl --user myuser |
| 120 | + ``` |
| 121 | + |
| 122 | + - **For cross-domain:** |
| 123 | + |
| 124 | + ```sh |
| 125 | + bloodhound-cli acl --domain mydomain.local |
| 126 | + ``` |
| 127 | + |
| 128 | + - **Exclude multiple domains:** |
| 129 | + |
| 130 | + ```sh |
| 131 | + bloodhound-cli acl --domain mydomain.local -bd EXCLUDED1 EXCLUDED2 |
| 132 | + ``` |
| 133 | + |
| 134 | +7. **Enumerate Computers** |
| 135 | + |
| 136 | + - **All computers in a domain:** |
| 137 | + |
| 138 | + ```sh |
| 139 | + bloodhound-cli computer --domain mydomain.local |
| 140 | + ``` |
| 141 | + |
| 142 | + - **Filter by LAPS and save results:** |
| 143 | + |
| 144 | + ```sh |
| 145 | + bloodhound-cli computer --domain mydomain.local --laps True -o computers_with_laps.txt |
| 146 | + ``` |
| 147 | + |
| 148 | +8. **Enumerate Users** |
| 149 | + |
| 150 | + - **List all users in a domain:** |
| 151 | + |
| 152 | + ```sh |
| 153 | + bloodhound-cli user --domain mydomain.local |
| 154 | + ``` |
| 155 | + |
| 156 | + - **List privileged (admin) users:** |
| 157 | + |
| 158 | + ```sh |
| 159 | + bloodhound-cli user --domain mydomain.local --admin-count |
| 160 | + ``` |
| 161 | + |
| 162 | + - **List high-value users:** |
| 163 | + |
| 164 | + ```sh |
| 165 | + bloodhound-cli user --domain mydomain.local --high-value |
| 166 | + ``` |
| 167 | + |
| 168 | + - **List users with password not required:** |
| 169 | + |
| 170 | + ```sh |
| 171 | + bloodhound-cli user --domain mydomain.local --password-not-required |
| 172 | + ``` |
| 173 | + |
| 174 | + - **List users with password never expires:** |
| 175 | + |
| 176 | + ```sh |
| 177 | + bloodhound-cli user --domain mydomain.local --password-never-expires |
| 178 | + ``` |
| 179 | + |
| 180 | + - **Save user query results:** |
| 181 | + |
| 182 | + ```sh |
| 183 | + bloodhound-cli user --domain mydomain.local --admin-count -o admin_users.txt |
| 184 | + ``` |
| 185 | + |
| 186 | +## Edition Support Details |
| 187 | + |
| 188 | +- `--edition legacy` (default): full feature set (Neo4j backend). |
| 189 | +- `--edition ce`: CE client with support for `auth` (/api/v2/login) y `upload` (flow de file-upload v2). El resto de comandos imprimirán un mensaje hasta estar conectados a CE. |
| 190 | + |
| 191 | +## Changelog |
| 192 | + |
| 193 | +- 0.2.0 |
| 194 | + - Add `--edition` and `--verbose` global flags |
| 195 | + - Add CE configuration `set-ce` and CE client skeleton |
| 196 | + - Add CE `auth` (JWT via `/api/v2/login`) and `upload` (file-upload `/start`, `/{job_id}`, `/{job_id}/end`) |
| 197 | + - Integrate `rich` for debug/verbose output |
| 198 | + - Dependencies: add `requests`, `rich` |
| 199 | + |
| 200 | +## License |
| 201 | + |
| 202 | +This project is licensed under the MIT License. |
0 commit comments