Top Related Projects
A Python based ingestor for BloodHound
Six Degrees of Domain Admin
Quick Overview
BloodHound.py is a Python-based ingestor for BloodHound, a tool used for Active Directory security assessment. It allows users to collect data about Active Directory environments without requiring administrator privileges on domain systems, making it a valuable tool for both red team operations and security audits.
Pros
- Cross-platform compatibility (Windows, Linux, macOS)
- Doesn't require administrative privileges for data collection
- Supports various authentication methods (Kerberos, NTLM, username/password)
- Lightweight and easy to deploy compared to the original C# BloodHound ingestor
Cons
- May trigger security alerts in some environments due to its data collection activities
- Requires careful handling of collected data to maintain security and privacy
- Limited compared to the full C# BloodHound ingestor in terms of some advanced features
- Potential for misuse if not handled responsibly
Code Examples
- Basic usage to collect all data:
from bloodhound import BloodHound
bh = BloodHound()
bh.collect_all()
- Collecting specific data types:
from bloodhound import BloodHound
bh = BloodHound()
bh.collect_users()
bh.collect_groups()
bh.collect_computers()
- Using alternative authentication methods:
from bloodhound import BloodHound
bh = BloodHound(username='user@domain.com', password='password')
# Or with Kerberos ticket
# bh = BloodHound(auth_method='kerberos', ticket_file='/path/to/ticket')
bh.collect_all()
Getting Started
To get started with BloodHound.py:
-
Install the library:
pip install bloodhound
-
Import and use in your Python script:
from bloodhound import BloodHound bh = BloodHound(domain='domain.com') bh.collect_all()
-
Run the script with appropriate permissions in the target environment.
-
Import the generated JSON files into the BloodHound GUI for analysis.
Remember to use this tool responsibly and only in environments where you have explicit permission to perform security assessments.
Competitor Comparisons
A Python based ingestor for BloodHound
Pros of BloodHound.py
- Python-based implementation, offering cross-platform compatibility
- Lightweight and easy to integrate into existing Python-based workflows
- Provides a command-line interface for easy automation and scripting
Cons of BloodHound.py
- May have fewer features compared to the original BloodHound implementation
- Potentially slower performance for large-scale data collection and analysis
- Might require additional Python dependencies to be installed
Code Comparison
BloodHound.py:
def get_domain_controllers(self):
q = """
MATCH (n:Computer)
WHERE n.domain={domain} AND n.objectsid ENDS WITH "-516"
RETURN n.name
"""
return self.cypher(q, domain=self.domain)
Both repositories are the same project, so there isn't a meaningful code comparison to make between them. The code snippet above is an example of how BloodHound.py interacts with the Neo4j database to retrieve domain controllers.
Summary
BloodHound.py is a Python implementation of the BloodHound tool, which is used for Active Directory security assessment. It offers cross-platform compatibility and ease of integration with Python-based workflows. However, it may have some limitations in terms of features and performance compared to the original C# implementation. The project is suitable for users who prefer working with Python or need to incorporate BloodHound functionality into existing Python scripts.
Six Degrees of Domain Admin
Pros of BloodHound
- More comprehensive and feature-rich GUI for visualizing and analyzing Active Directory relationships
- Supports custom Cypher queries for advanced data analysis
- Includes a built-in data collection tool (SharpHound) for Windows environments
Cons of BloodHound
- Requires a Neo4j database for data storage and querying
- More complex setup and installation process
- Larger resource footprint due to its GUI and database requirements
Code Comparison
BloodHound (SharpHound collector):
public static string InvokeBloodHound(string args)
{
var arguments = ArgumentParser.Parse(args);
var controller = new CollectionController(arguments);
return controller.StartCollection();
}
BloodHound.py:
def run(args):
bloodhound = BloodHound(args)
bloodhound.connect()
bloodhound.run()
bloodhound.close()
BloodHound.py is a Python-based alternative to the original BloodHound tool. It offers a lightweight, command-line approach to Active Directory data collection and analysis. While it lacks the advanced GUI and some features of BloodHound, it provides a simpler setup process and doesn't require a Neo4j database. BloodHound.py is particularly useful for quick assessments or in environments where installing the full BloodHound suite is not feasible.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
BloodHound.py
BloodHound.py is a Python based ingestor for BloodHound, based on Impacket.
This version of BloodHound.py is only compatible with BloodHound 4.2 and 4.3. For BloodHound CE, check out the bloodhound-ce branch
Limitations
BloodHound.py currently has the following limitations:
- Supports most, but not all BloodHound (SharpHound) features. Currently GPO local groups are not supported, all other collection methods are implemented.
Installation and usage
You can install the ingestor via pip with pip install bloodhound
, or by cloning this repository and running pip install .
from the project directory.
BloodHound.py requires impacket
, ldap3
and dnspython
to function.
The installation will add a command line tool bloodhound-python
to your PATH.
To use the ingestor, at a minimum you will need credentials of the domain you're logging in to.
You will need to specify the -u
option with a username of this domain (or username@domain
for a user in a trusted domain). If you have your DNS set up properly and the AD domain is in your DNS search list, then BloodHound.py will automatically detect the domain for you. If not, you have to specify it manually with the -d
option.
By default BloodHound.py will query LDAP and the individual computers of the domain to enumerate users, computers, groups, trusts, sessions and local admins.
If you want to restrict collection, specify the --collectionmethod
parameter, which supports the following options (similar to SharpHound):
- Default - Performs group membership collection, domain trust collection, local admin collection, and session collection
- Group - Performs group membership collection
- LocalAdmin - Performs local admin collection
- RDP - Performs Remote Desktop Users collection
- DCOM - Performs Distributed COM Users collection
- Container - Performs container collection (GPO/Organizational Units/Default containers)
- PSRemote - Performs Remote Management (PS Remoting) Users collection
- DCOnly - Runs all collection methods that can be queried from the DC only, no connection to member hosts/servers needed. This is equal to Group,Acl,Trusts,ObjectProps,Container
- Session - Performs session collection
- Acl - Performs ACL collection
- Trusts - Performs domain trust enumeration
- LoggedOn - Performs privileged Session enumeration (requires local admin on the target)
- ObjectProps - Performs Object Properties collection for properties such as LastLogon or PwdLastSet
- All - Runs all methods above, except LoggedOn
- Experimental - Connects to individual hosts to enumerate services and scheduled tasks that may have stored credentials
Multiple collectionmethods should be separated by a comma, for example: -c Group,LocalAdmin
You can override some of the automatic detection options, such as the hostname of the primary Domain Controller if you want to use a different Domain Controller with -dc
, or specify your own Global Catalog with -gc
.
Docker usage
- Build container
docker build -t bloodhound .
- Run container
docker run -v ${PWD}:/bloodhound-data -it bloodhound
After that you can runbloodhound-python
inside the container, all data will be stored in the path from where you start the container.
Credits
BloodHound.py was originally written by Dirk-jan Mollema, Edwin van Vliet and Matthijs Gielen from Fox-IT (NCC Group). BloodHound.py is currently maintained by Dirk-jan Mollema from Outsider Security. The implementation and data model is based on the original tool from SpecterOps. Many thanks to everyone who contributed by testing, submitting issues and pull requests over the years.
Top Related Projects
A Python based ingestor for BloodHound
Six Degrees of Domain Admin
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot