A command line utility to aid in Pentesting with BloodHound. Not related to the official bloodhound-cli.
-
Install Podman and docker-compose.
-
Configure rootless containers for Podman.
-
Enable the Podman socket for your user.
systemctl --user enable --now podman.socket -
Install this Python package with uv or pipx.
uv tool install git+https://github.com/dadevel/bhcli.git@main pipx install git+https://github.com/dadevel/bhcli.git@main
If you don't want to use bhcli and are here just for the custom queries run the command below. Otherwise the queries are automatically installed when you create your first bhcli project.
curl -Lo ~/.config/bloodhound/customqueries.json https://github.com/dadevel/bhcli/raw/main/src/bhcli/data/customqueries.jsonThe queries are based on work by @luemmelsec and @martinsohn. Thank you!
Projects are managed with Podman containers. Only one project can be active at a time. Each project consists of BloodHound Community Edition, Neo4j and Postgres.
bhcli setup-project example1
bhcli shutdown-project example1
bhcli setup-project example2
bhcli list-projects
bhcli destroy-project example1
bhcli destroy-project example2- BloodHound Legacy: bolt://localhost:7687/, username neo4j, empty password
- Neo4j: http://localhost:7474/, username neo4j, empty password
- BloodHound Community Edition: http://localhost:7575/, username admin, password admin
Ingest files from AzureHound and modern SharpHound.
bhcli import-bhce ./azurehound.json ./*_BloodHound.zipFiles from bloodhound.py and old SharpHound must be imported with BloodHound Legacy.
Quickly fetch data from Neo4j for use with other tools or import data from other tools into BloodHound.
bhcli query 'MATCH (u:User {enabled: true}) RETURN u.samaccountname' > ./users.txt
bhcli query -s 'MATCH (u:User {name: toUpper($stdin)} SET u.owned=true RETURN u.name' << EOF
john.doe@corp.local
jane.doe@corp.local
EOF
bhcli query -s -j 'MATCH (u:User {name: $stdin.name}) SET u.foo=$stdin.value RETURN u.name' << EOF
{"name": "john.doe@corp.local", "value": "bar"}
{"name": "jane.doe@corp.local", "value": "baz"}
EOFExecute a set of post-processing queries to mark certain objects with additional attributes and add additional edges for certain situations.
bhcli enrichThese attributes are:
tier=0for a standard set of tier 0 objectshighvalue=truefor objects with potential path to tier 0active=truefor accounts with login in last 90 dayssensitive=truefor members of Protected Users
The enrichment also assigns weights to edges in BloodHound (based on work by @riccardoancarani and @jmbesnard).
This allows to search for the easiest instead of the shortest path to Domain Admin.
MATCH (a {owned: true}) MATCH (b {highvalue: true}) CALL apoc.algo.dijkstra(a, b, '>', 'cost') YIELD path RETURN path;Run a DCSync from impacket-secretsdump with multiple wordlists and rulesets trough Hashcat.
LM hashes and pre-created computer accounts are automatically cracked unless --no-lm-brute respective --no-pre2k is specified.
impacket-secretsdump -just-dc -outputfile corp.local -k -no-pass dc01.corp.local
bhcli generate-wordlist > ./custom-words.txt # made of usernames, descriptions, etc.
bhcli hashcat-ntds -t ./clem9669-wordlists/dictionnaire_de ./clem9669-hashcat-rules/clem9669_medium.rule -t ./custom-words.txt ./unicorn-hashcat-rules/unicorn\ rules/SuperUnicorn.rule -t ./weakpass-3.txt ./unicorn-hashcat-rules/unicorn\ rules/Unicorn250.rule -p ./hashcat.potfile ./*.ntdsImport the DCSync output and Hashcat potfile into BloodHound (inspired by @knavesec and @syss-research).
This adds Credential objects with nthash, lmhash and password properties and HasCredential as well as AssignedTo edges between users and credentials.
bhcli import-ntds -p ./hashcat.potfile ./*.ntdsNote: bhcli assumes that the name of the NTDS file minus the
.ntdssuffix is the FQDN of the domain. This means a DCSync fromdc01.subdomain.corp.localmust be namedsubdomain.corp.local.ntds.
Import adidnsdump into BloodHound to add an ipaddress attribute to computers.
For hosts that appear in ADIDNS but don't exist in BloodHound, standalone computer objects are created.
bhcli import-adidns corp.local ./records.csvImport nodes for standalone computers and local users by leveraging the SQLite database of NetExec.
This includes nthash properties from SAM dumps and AdminTo as well as HasCredential and AssignedTo edges e.g. to identify local admin password reuse.
bhcli import-netexec ~/.nxc/workspaces/default/smb.dbAdd historical session data as well as inferred RDP and local admin edges (original idea from @rantasec). First export recent logons from Windows Event Logs with Get-RecentLogons.ps1, then transfer the JSON output to your computer and finally import it into Neo4j.
bhcli import-winevents ./logons.jsonImport SMB Signing, WebClient and EFS info from ServiceDetector.
bhcli query 'MATCH (c:Computer {active: true}) RETURN c.name' > ./computers.txt
servicedetector -c coercion -d corp.local -u jdoe -p 'passw0rd' $(< ./computers.txt) | tee -a ./servicedetector.json
jq -r 'select(.category=="coercion" and .product=="WebClient" and .state=="running")|.host' ./servicedetector.json | bhcli query -s 'MATCH (c:Computer {name: $stdin}) SET c.webclient=true RETURN c.name'
jq -r 'select(.category=="coercion" and .product=="EFS" and .state=="running")|.host' ./servicedetector.json | bhcli query -s 'MATCH (c:Computer {name: $stdin}) SET c.efs=true RETURN c.name'
jq -r 'select(.category=="smb" and .signing==false)|.host' ./servicedetector.json | bhcli query -s 'MATCH (c:Computer {name: $stdin}) SET c.smbsigning=false RETURN c.name'