A collection of files for adding and leveraging custom properties in BloodHound.
A collection of files for adding and leveraging custom properties in BloodHound.
A collection of files for adding and leveraging custom properties in BloodHound. A thorough overview of the ideas that led to these Custom Queries & Ruby script can be found in this blog post: http://porterhau5.com/blog/extending-bloodhound-track-and-visualize-your-compromise/
These are intended, although not required, to be used with a forked version of BloodHound found here: https://github.com/porterhau5/BloodHound
Files in the example-files directory can be used with the Ruby script and the BloodHoundExampleDB.graphdb for demonstration or development purposes. Usage examples are shown below.
Using these requires Neo4j, a populated database, and a BloodHound app.
The Ruby script (bh-owned.rb) and custom queries (customqueries.json) can be used with the official BloodHound app. However, the UI customizations are currently only available in the customized app found in this forked BloodHound repo.
Current UI customizations include:
If you'd like to try out the features added in the customized BloodHound app, then either download a pre-compiled binary here or build the app from source. If building from source, then follow the official BloodHound install directions but substitute the forked repo URL (https://github.com/porterhau5/BloodHound) for the official repo URL in step 2 (cloning the repository). The building instructions are on BloodHound's wiki.
To use the custom queries, first copy the customqueries.json file to the Electron project's home folder:
~\AppData\Roaming\bloodhound\~/Library/Application Support/bloodhound/Refresh or restart BloodHound for the changes to take effect. Custom Queries can be found in the Search Container (top-left) on the Queries tab underneath the Custom Queries header.
This script is the primary means for updating the Neo4j database to support the custom queries and UI enhancements.
…It helps to create a few new indexes to help with query performance. This can be done using Neo4j's web browser or BloodHound's Raw Query feature (I recommend Neo4j's web browser for this):
CREATE INDEX ON :Group(wave)
CREATE INDEX ON :User(wave)
CREATE INDEX ON :Computer(wave)
CREATE INDEX ON :Group(blacklist)
CREATE INDEX ON :User(blacklist)
CREATE INDEX ON :Computer(blacklist)Data is ingested using the script's -a flag with a file passed as an argument. Files should be in CSV format with the name of the compromised node first, followed by the method of compromise. If no method of compromise is provided then it will default to "Not specified" (these files can be found in the example-files dir):
$ cat 1st-wave.txt
[email protected],LLMNR wpad
[email protected],NBNS wpad
$ ruby bh-owned.rb -a 1st-wave.txt
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[*] No previously owned nodes found, setting wave to 1
[+] Success, marked '[email protected]' as owned in wave '1' via 'LLMNR wpad'
[+] Success, marked '[email protected]' as owned in wave '1' via 'NBNS wpad'
[*] Finding spread of compromise for wave 1
[+] 2 nodes found:
DOMAIN [email protected]
SYSTEM38.INTERNAL.LOCALThe script will first query the database and determine the latest wave added. It then increments it by one so that the incoming additions will be in the new wave. You can override this behavior by setting the -w flag to the preferred wave value.
Once the wave number is determined, the script takes the following steps:
Until more options and error-checking is thrown in, each wave should be added separately:
…The -A flag will skip the wave process entirely. This is useful if you just want to mark nodes as owned and move on:
$ cat example-files/owned-no-wave.txt
[email protected],Social engineered
[email protected]
[email protected],Phish
$ ruby bh-owned.rb -A example-files/owned-no-wave.txt
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[+] Success, marked '[email protected]' as owned via 'Social engineered'
[+] Success, marked '[email protected]' as owned via 'Not specified'
[+] Success, marked '[email protected]' as owned via 'Phish'Use -s to add a file containing a list of nodes with the same password. This will create a new relationship, "SharesPasswordWith", between each node in the list. Useful for representing Computers with a common local admin password, or Users that use the same password for multiple accounts:
…Specific nodes or relationships can be added to the blacklist. For adding nodes, put the name of each node in a newline-delimited file and add it using the -b flag. Note that blacklist features are only compatible with the custom queries:
$ cat blacklist-nodes.txt
MANAGEMENT3.INTERNAL.LOCAL
[email protected]
[email protected]
DESKTOP20.EXTERNAL.LOCAL
ruby bh-owned.rb -b blacklist-nodes.txt
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[+] Success, marked 'MANAGEMENT3.INTERNAL.LOCAL' as blacklisted
[+] Success, marked '[email protected]' as blacklisted
[+] Success, marked '[email protected]' as blacklisted
[+] Success, marked 'DESKTOP20.EXTERNAL.LOCAL' as blacklistedRelationships are added to the blacklist by specifying the start node and end node for the desired relationship. Each relationship should be in CSV format with the start node first, relationship second, and end node last, with one path per line. They are added to the blacklist using the -B flag:
$ cat blacklist-rels.txt
[email protected],AdminTo,MANAGEMENT3.INTERNAL.LOCAL
DESKTOP21.EXTERNAL.LOCAL,HasSession,[email protected]
$ ruby bh-owned.rb -B blacklist-rels.txt
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[+] Success, marked 'AdminTo' as blacklisted from '[email protected]' to 'MANAGEMENT3.INTERNAL.LOCAL'
[+] Success, marked 'HasSession' as blacklisted from 'DESKTOP21.EXTERNAL.LOCAL' to '[email protected]'Nodes are removed from the blacklist in the same manner they are added, but use the -r flag. Use -R to remove relationships from the blacklist:
…The -n flag can be used to dump the names of all nodes from the database:
$ ruby bh-owned.rb -n
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
[email protected]
The -e flag can be used to show examples of Cypher queries leveraging the custom properties. The juicy ones have been rolled up into the 'Custom Queries' available in the app:
…If you want to start over and remove any custom properties & relationships from your database nodes, use --reset:
$ ruby bh-owned.rb --reset
[*] Using default username: neo4j
[*] Using default password: BloodHound
[*] Using default URL: http://127.0.0.1:7474/
[*] Removing all custom properties and SharesPasswordWith relationshipsThere are the current custom queries in this set:
owned property.owned node.blacklist property set.blacklist property set.blacklist property set.owned property set.All queries (except for the blacklist-specific queries) will filter out nodes & relationships from the blacklist.
Check out the "UI Customizations and Custom Queries" section of the blog post to see examples of these custom queries in action.
hackerjiv and pfizzell for the sound advice and feedback. CptJesus, _wald0, and harmj0y for making a tremendous platform.
No open issues yet, or sync has not completed.