BARK: BloodHound Attack Research Kit
BloodHound Attack Research Kit
BARK stands for BloodHound Attack Research Kit. It is a PowerShell script built to assist the BloodHound Enterprise team with researching and continuously validating abuse primitives. BARK currently focuses on Microsoft’s Azure suite of products and services.
BARK requires no third-party dependencies. BARK’s functions are designed to be as simple and maintainable as possible. Most functions are very simple wrappers for making requests to various REST API endpoints. BARK’s basic functions do not even require each other – you can pull almost any BARK function out of BARK and it will work perfectly as a standalone function in your own scripts.
Token Management and Manipulation Functions
Parse-JWTToken
will take a Base64 encoded JWT as input and parse it for you. Useful for verifying correct token audience and claims.Get-AZRefreshTokenWithUsernamePassword
requests a collection of tokens, including a refresh token, from login.microsoftonline.com with a user-supplied username and password. This will fail if the user has Multi-Factor Authentication requirements or is affected by a Conditional Access Policy.Get-MSGraphTokenWithClientCredentials
requests an MS Graph-scoped JWT with a client ID and secret. Useful for authenticating as an AzureAD service principal.Get-MSGraphTokenWithRefreshToken
requests an MS Graph-scoped JWT with a user-supplied refresh token.Get-MSGraphTokenWithPortalAuthRefreshToken
requests an MS Graph-scoped JWT with a user-supplied Azure Portal Auth Refresh token.Get-AzureRMTokenWithClientCredentials
requests an AzureRM-scoped JWT with a client ID and secret. Useful for authenticating as an AzureAD service principal.Get-ARMTokenWithPortalAuthRefreshToken
requests an AzureRM-scoped JWT with a user-supplied Azure Portal Auth Refresh token.Get-ARMTokenWithRefreshToken
requests an AzureRM-scoped JWT with a user-supplied refresh token.Get-AzurePortalTokenWithRefreshToken
requests an Azure Portal Auth Refresh token with a user-supplied refresh token.
The refresh token-based functions in BARK are based on functions in https://github.com/rvrsh3ll/TokenTactics by [https://twitter.com/424f424f](Steve Borosh)
Abuse Functions
Set-AZUserPassword
will attempt to set the password of another user to a new user-provided value.Reset-AZUserPassword
will attempt to reset the password of another user. If successful, the output will contain the new, Azure-generated password of the userNew-AzureRMRoleAssignment
will attempt to grant a user-specified AzureRM role assignment to a particular principal over a certain scope.New-AppRegSecret
will attempt to create a new secret for an existing AzureAD app registration.New-ServicePrincipalSecret
will attempt to create a new secret for an existing AzureAD service principal.New-AppRoleAssignment
will attempt to grant an app role to a service principal. For example, you can use this to grant a service principal the RoleManagement.ReadWrite.Directory app role.
Enumeration Functions
Get-AzureRMRoleDefinitions
collects all role definitions described at a subscription scope, including custom roles.Get-MGAppRoles
collects the app roles made available by the MS Graph service principal.Get-AllAzureADApps
collects all AzureAD application registration objects.Get-AllAzureADServicePrincipals
collects all AzureAD service principal objects.Get-AllAzureADUsers
collects all AzureAD users.Get-AllAzureADGroups
collects all AzureAD groups.Get-AllAzureRMSubscriptions
collects all AzureRM subscriptions.
Meta Functions
Test-AzureRMAddSelfToAzureRMRole
used in abuse validation testing to determine whether a service principal with certain rights can grant itself the User Access Admin role over a subscription.Test-AzureRMCreateFunction
used in abuse validation testing to test if a service principal can add a new function to an existing function app.Invoke-AllAzureRMAbuseTests
performs all AzureRM abuse validation tests and outputs a resulting object that describes which AzureRM roles granted the ability to perform each abuse.Remove-AbuseTestAzureRMRoles
is a clean-up function for removing AzureRM admin roles created during testing.Remove-AbuseTestServicePrincipals
cleans up abuse tests by removing the serivce principals that were created during testing.New-TestAppReg
creates an application registration object for the explicit purpose of abuse validation testing.New-TestSP
creates a new service principal and associates it with the app created by the above function.Test-MGAddSelfAsOwnerOfApp
is used in abuse validation testing to determine whether a service principal with a particular privilege can grant itself ownership of an existing AzureAD app.Test-MGAddSelfAsOwnerOfSP
is used in abuse validation testing to determine whether a service principal with a particular privilege can grant itself ownership of an existing AzureAD service principal.Test-MGAddSelfToAADRole
is used in abuse validation testing to determine whether a service principal with a particular privilege can add itself to an AzureAD admin role – Global Admin, for example.Test-MGAddSelfToMGAppRole
is used in abuse validation testing to determine whether a service principal with a particular privilege can grant itself a particular MS Graph app role without admin consent.Test-MGAddOwnerToRoleEligibleGroup
is used to test whether a service principal can grant itself explicit ownership of a role assignable group.Test-MGAddMemberToRoleEligibleGroup
is used to test whether the service principal can add itself to a role assignable group.Test-MGAddSecretToSP
is used to test whether the service principal can add a new secret to an existing service principal.Test-MGAddSecretToApp
is used to test whether the service principal can add a new secret to an existing app.Invoke-AllAzureMGAbuseTests
performs all abuse validation tests that can be executed by holding an MS Graph app role. Returns an object describing which privileges were successful at performing each abuse test.Invoke-AllAzureADAbuseTests
performs all abuse validation tests that can be executed by principals granted AzureAD admin roles. Returns an object describing which privileges were successful at performing each abuse test.ConvertTo-Markdown
is used for massaging output from the Invoke-Tests functions for usage in another platform.
Download & Use
Copyright (C) 2022 andyrobbins