Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
af39e51
Updated to the latest commit of main branch on the original repo
vishalk-metron Jun 17, 2025
848b218
Update .gitignore
vishalk-metron Jun 17, 2025
62498f4
Partial code completion for fetching devices from intune
vishalk-metron Jun 17, 2025
0d5c890
sample integration example (partial, may not work)
vishalk-metron Jun 17, 2025
45f8965
Merge remote-tracking branch 'spectreops-ah-repo/main' into vishalk-m…
vishalk-metron Jun 17, 2025
a62a190
Intune basic APIs have been implemented
vishalk-metron Jun 17, 2025
688ccf2
Added powershell script to get JWT Token from graph
vishalk-metron Jun 17, 2025
c6a476f
Update .gitignore
vishalk-metron Jun 17, 2025
373cfc2
Updated the file 'list-intune-script-results.go' to get results from …
vishalk-metron Jun 18, 2025
c85f340
Added files for Registry values module - incomplete
vishalk-metron Jun 19, 2025
ab1d17b
Removed Registry Values Files to clean up the PR
vishalk-metron Jun 19, 2025
8c4e2a8
Delete registry.go
vishalk-metron Jun 19, 2025
6c20e19
Removed references for script execution module
vishalk-metron Jun 19, 2025
14f9461
Removed Duplicate Code, Unused Code
vishalk-metron Jun 19, 2025
5fcda19
Reduced Code Duplication
vishalk-metron Jun 19, 2025
414247f
Working Unoptimised version
vishalk-metron Jun 25, 2025
a63b083
Implemented Real API instead of mock results
vishalk-metron Jun 26, 2025
160a712
Delete cla.yml
vishalk-metron Jun 26, 2025
97867d2
Removing Action / Checks
vishalk-metron Jun 26, 2025
fd673c1
test commit
vishalk-metron Jun 26, 2025
e1c2866
Revert "test commit"
vishalk-metron Jun 27, 2025
ba2d4f3
Revert "Removing Action / Checks"
vishalk-metron Jun 27, 2025
8ebed47
Revert "Delete cla.yml"
vishalk-metron Jun 27, 2025
5a48c7d
Delete intune_converter.go
vishalk-metron Jun 27, 2025
39bdfca
Update list-intune-registry-analysis.go
vishalk-metron Jul 2, 2025
5811b81
Delete get_token.ps1
vishalk-metron Jul 2, 2025
6b0d8a9
Active sessions data fetching through Intune
vishalk-metron Jul 2, 2025
65d402b
Updated with real API calls and to use existing config file
vishalk-metron Jul 3, 2025
27aee2e
Completed/Corrected the Session Collection Module
vishalk-metron Jul 3, 2025
229243c
Improved the module and added detailed analysis --verbose flag
vishalk-metron Jul 3, 2025
d68622a
PR Comment Resolution
vishalk-metron Jul 9, 2025
ff456f4
Code Cleaning
vishalk-metron Jul 9, 2025
4c2e98e
CodeRabbit PR comments resolved
vishalk-metron Jul 17, 2025
d84286a
CodeRabbit PR comments resolved
vishalk-metron Jul 17, 2025
fda5092
Merge Conflict Resolution
vishalk-metron Sep 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -232,3 +232,7 @@ tags

# Built Visual Studio Code Extensions
*.vsix
.github/workflows/cla.yml
.github/workflows/vuln-scan.yml
/.github
get_token.ps1
49 changes: 49 additions & 0 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,41 @@ import (
"fmt"
"net/http"
"net/url"
"time"

"github.com/bloodhoundad/azurehound/v2/client/config"
"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/client/rest"
"github.com/bloodhoundad/azurehound/v2/models/azure"
"github.com/bloodhoundad/azurehound/v2/models/intune"
"github.com/bloodhoundad/azurehound/v2/panicrecovery"
"github.com/bloodhoundad/azurehound/v2/pipeline"
)

// SignInEvent represents a sign-in event from Microsoft Graph
type SignInEvent struct {
ID string `json:"id"`
CreatedDateTime time.Time `json:"createdDateTime"`
UserDisplayName string `json:"userDisplayName"`
UserPrincipalName string `json:"userPrincipalName"`
UserId string `json:"userId"`
AppDisplayName string `json:"appDisplayName"`
ClientAppUsed string `json:"clientAppUsed"`
IPAddress string `json:"ipAddress"`
IsInteractive bool `json:"isInteractive"`
Status struct {
ErrorCode int `json:"errorCode"`
} `json:"status"`
DeviceDetail struct {
DeviceId string `json:"deviceId"`
DisplayName string `json:"displayName"`
OperatingSystem string `json:"operatingSystem"`
IsCompliant bool `json:"isCompliant"`
} `json:"deviceDetail"`
RiskState string `json:"riskState"`
RiskLevelAggregated string `json:"riskLevelAggregated"`
}

func NewClient(config config.Config) (AzureClient, error) {
if msgraph, err := rest.NewRestClient(config.GraphUrl(), config); err != nil {
return nil, err
Expand Down Expand Up @@ -175,8 +201,18 @@ type azureClient struct {
}

type AzureGraphClient interface {
ValidateScriptDeployment(ctx context.Context) error
GetAzureADOrganization(ctx context.Context, selectCols []string) (*azure.Organization, error)

ListIntuneDevices(ctx context.Context, params query.GraphParams) <-chan AzureResult[azure.IntuneDevice]
ExecuteRegistryCollectionScript(ctx context.Context, deviceID string) (*azure.ScriptExecution, error)
GetScriptExecutionResults(ctx context.Context, scriptID string) <-chan AzureResult[azure.ScriptExecutionResult]
WaitForScriptCompletion(ctx context.Context, scriptID string, maxWaitTime time.Duration) (*azure.RegistryData, error)
CollectRegistryDataFromDevice(ctx context.Context, deviceID string) (*azure.RegistryData, error)
CollectRegistryDataFromAllDevices(ctx context.Context) <-chan AzureResult[azure.DeviceRegistryData]
GetDeployedScriptID(ctx context.Context, scriptName string) (string, error)
TriggerScriptExecution(ctx context.Context, scriptID, deviceID string) error

ListAzureADGroups(ctx context.Context, params query.GraphParams) <-chan AzureResult[azure.Group]
ListAzureADGroupMembers(ctx context.Context, objectId string, params query.GraphParams) <-chan AzureResult[json.RawMessage]
ListAzureADGroupOwners(ctx context.Context, objectId string, params query.GraphParams) <-chan AzureResult[json.RawMessage]
Expand Down Expand Up @@ -221,6 +257,19 @@ type AzureClient interface {

TenantInfo() azure.Tenant
CloseIdleConnections()

// New methods for role detection
GetUserDirectoryRoles(ctx context.Context, userPrincipalName string) ([]azure.DirectoryRole, error)
GetUserMemberOf(ctx context.Context, userPrincipalName string) ([]azure.DirectoryObject, error)

CollectSessionDataDirectly(ctx context.Context) <-chan AzureResult[azure.DeviceSessionData]
GetUserSignInActivity(ctx context.Context, userPrincipalName string, days int) ([]SignInEvent, error)
GetDeviceSignInActivity(ctx context.Context, deviceId string, days int) ([]SignInEvent, error)

// Add Intune methods
ListIntuneManagedDevices(ctx context.Context, params query.GraphParams) <-chan AzureResult[intune.ManagedDevice]
GetIntuneDeviceCompliance(ctx context.Context, deviceId string, params query.GraphParams) <-chan AzureResult[intune.ComplianceState]
GetIntuneDeviceConfiguration(ctx context.Context, deviceId string, params query.GraphParams) <-chan AzureResult[intune.ConfigurationState]
}

func (s azureClient) TenantInfo() azure.Tenant {
Expand Down
65 changes: 65 additions & 0 deletions client/intune_devices.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
// File: client/intune_devices.go
// Copyright (C) 2022 SpecterOps
// Implementation of Intune device management API calls

package client

import (
"context"
"fmt"

"github.com/bloodhoundad/azurehound/v2/client/query"
"github.com/bloodhoundad/azurehound/v2/constants"
"github.com/bloodhoundad/azurehound/v2/models/intune"
)

// Maximum page size for Microsoft Graph API requests
const MaxGraphAPIPageSize = 999

func setDefaultParams(params *query.GraphParams) {
if params.Top == 0 {
params.Top = MaxGraphAPIPageSize
}
}

// ListIntuneManagedDevices retrieves all managed devices from Intune
// GET /deviceManagement/managedDevices
func (s *azureClient) ListIntuneManagedDevices(ctx context.Context, params query.GraphParams) <-chan AzureResult[intune.ManagedDevice] {
var (
out = make(chan AzureResult[intune.ManagedDevice])
path = fmt.Sprintf("/%s/deviceManagement/managedDevices", constants.GraphApiVersion)
)

setDefaultParams(&params)

go getAzureObjectList[intune.ManagedDevice](s.msgraph, ctx, path, params, out)
return out
}

// GetIntuneDeviceCompliance retrieves compliance information for a specific device
// GET /deviceManagement/managedDevices/{id}/deviceCompliancePolicyStates
func (s *azureClient) GetIntuneDeviceCompliance(ctx context.Context, deviceId string, params query.GraphParams) <-chan AzureResult[intune.ComplianceState] {
var (
out = make(chan AzureResult[intune.ComplianceState])
path = fmt.Sprintf("/%s/deviceManagement/managedDevices/%s/deviceCompliancePolicyStates", constants.GraphApiVersion, deviceId)
)

setDefaultParams(&params)

go getAzureObjectList[intune.ComplianceState](s.msgraph, ctx, path, params, out)
return out
}

// GetIntuneDeviceConfiguration retrieves configuration information for a specific device
// GET /deviceManagement/managedDevices/{id}/deviceConfigurationStates
func (s *azureClient) GetIntuneDeviceConfiguration(ctx context.Context, deviceId string, params query.GraphParams) <-chan AzureResult[intune.ConfigurationState] {
var (
out = make(chan AzureResult[intune.ConfigurationState])
path = fmt.Sprintf("/%s/deviceManagement/managedDevices/%s/deviceConfigurationStates", constants.GraphApiVersion, deviceId)
)

setDefaultParams(&params)

go getAzureObjectList[intune.ConfigurationState](s.msgraph, ctx, path, params, out)
return out
}
Loading
Loading