Skip to content

Commit

Permalink
Add test-hawkglobalobject function and have every public function cal…
Browse files Browse the repository at this point in the history
…l it before executing to ensure that hawk global object is fully configured prior to hawk execution.
  • Loading branch information
jonnybottles committed Jan 11, 2025
1 parent 70b992a commit 74d10dd
Show file tree
Hide file tree
Showing 36 changed files with 314 additions and 152 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ Function Get-HawkTenantAdminEmailForwardingChange {
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

# Test the Exchange Online connection to ensure the environment is ready for operations.
Test-EXOConnection
# Log the execution of the function for audit and telemetry purposes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ Function Get-HawkTenantAdminInboxRuleCreation {
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ Function Get-HawkTenantAdminInboxRuleModification {
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantAdminInboxRuleRemoval.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Function Get-HawkTenantAdminInboxRuleRemoval {
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Function Get-HawkTenantAdminMailboxPermissionChange {
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
param()

BEGIN {
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Expand Down
6 changes: 4 additions & 2 deletions Hawk/functions/Tenant/Get-HawkTenantAuditLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ https://docs.microsoft.com/en-us/graph/api/resources/auditlog?view=graph-rest-1.
#>
BEGIN{
#Initializing Hawk Object if not present
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Gathering Azure AD Audit Logs events" -Action
}
PROCESS{
Expand Down
13 changes: 5 additions & 8 deletions Hawk/functions/Tenant/Get-HawkTenantAuthHistory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,12 @@
[int]$IntervalMinutes = 15
)

# # Try to convert the submitted date into [datetime] format
# try {
# [datetime]$DateToStartSearch = Get-Date $StartDate
# }
# catch {
# Out-Logfile "[ERROR] - Unable to convert submitted date"
# break
# }
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


# Make sure the start date isn't more than 90 days in the past
if ((Get-Date).adddays(-91) -gt $StartDate) {
Out-Logfile "Start date is over 90 days in the past" -isError
Expand Down
10 changes: 7 additions & 3 deletions Hawk/functions/Tenant/Get-HawkTenantAzureAppAuditLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@
#>
Begin {
#Initializing Hawk Object if not present
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
Initialize-HawkGlobalObject
}
# Check if Hawk object exists and is fully initialized
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Out-LogFile "Gathering Tenant information" -Action
Test-EXOConnection
}#End BEGIN
Expand Down
7 changes: 7 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@
.NOTES
TODO: Put in some analysis ... flag some key things that we know we should
#>

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantConsentGrant.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
[CmdletBinding()]
param()

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Gathering OAuth / Application Grants" -Action

Test-GraphConnection
Expand Down
7 changes: 7 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantDomainActivity.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ Function Get-HawkTenantDomainActivity {
Searches for all Domain configuration actions
#>
BEGIN{
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}



Test-EXOConnection
Send-AIEvent -Event "CmdRun"
Out-LogFile "Gathering any changes to Domain configuration settings" -action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@
#TO DO: UPDATE THIS FUNCTION TO FIND E-Discovery roles created via the graph API

BEGIN {
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
7 changes: 7 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantEDiscoveryLog.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@
- Cmdlet: Command that was executed (if applicable)
#>
# Search UAL audit logs for any Domain configuration changes

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantEXOAdmin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
.NOTES
#>
BEGIN{
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Gathering Exchange Online Administrators" -Action

Test-EXOConnection
Expand Down
5 changes: 3 additions & 2 deletions Hawk/functions/Tenant/Get-HawkTenantEntraIDAdmin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
param()

BEGIN {
# Initializing Hawk Object if not present
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Gathering Microsoft Entra ID Administrators" -Action

# Verify Graph API connection
Expand Down
5 changes: 3 additions & 2 deletions Hawk/functions/Tenant/Get-HawkTenantEntraIDUser.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,11 @@
Properties selected for DFIR relevance.
#>
BEGIN {
# Initialize the Hawk environment if not already done
if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Gathering Entra ID Users" -Action

# Ensure we have a valid Graph connection
Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantInboxRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
[Parameter(Mandatory = $true)]
[string]$UserPrincipalName
)
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"
Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantMailItemsAccessed.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@

)
BEGIN {
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Starting Unified Audit Log (UAL) search for 'MailItemsAccessed'" -Action

}#End Begin
Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/Tenant/Get-HawkTenantRbacChange.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
#>
[CmdletBinding()]
param()
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


# Verify EXO connection and send telemetry
Test-EXOConnection
Expand Down
6 changes: 6 additions & 0 deletions Hawk/functions/Tenant/Search-HawkTenantActivityByIP.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
[string]$IpAddress
)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
7 changes: 4 additions & 3 deletions Hawk/functions/Tenant/Start-HawkTenantInvestigation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@
[CmdletBinding(SupportsShouldProcess)]
param()

if ([string]::IsNullOrEmpty($Hawk.FilePath)) {
Initialize-HawkGlobalObject
}
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Out-LogFile "Starting Tenant Sweep" -action
Send-AIEvent -Event "CmdRun"
Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/User/Get-HawkUserAdminAudit.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
[Parameter(Mandatory = $true)]
[array]$UserPrincipalName
)
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"
Expand Down
6 changes: 6 additions & 0 deletions Hawk/functions/User/Get-HawkUserAuthHistory.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
[switch]$ResolveIPLocations
)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/User/Get-HawkUserAutoReply.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,11 @@

)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
4 changes: 4 additions & 0 deletions Hawk/functions/User/Get-HawkUserConfiguration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
[Parameter(Mandatory = $true)]
[array]$UserPrincipalName
)
# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Test-EXOConnection
Send-AIEvent -Event "CmdRun"
Expand Down
6 changes: 6 additions & 0 deletions Hawk/functions/User/Get-HawkUserEmailForwarding.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
[array]$UserPrincipalName
)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
6 changes: 6 additions & 0 deletions Hawk/functions/User/Get-HawkUserHiddenRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@
[System.Management.Automation.PSCredential]$EWSCredential
)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
6 changes: 6 additions & 0 deletions Hawk/functions/User/Get-HawkUserInboxRule.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ Function Get-HawkUserInboxRule {

)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}


Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
5 changes: 5 additions & 0 deletions Hawk/functions/User/Get-HawkUserMailboxAuditing.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@
[array]$UserPrincipalName
)

# Check if Hawk object exists and is fully initialized
if (Test-HawkGlobalObject) {
Initialize-HawkGlobalObject
}

Test-EXOConnection
Send-AIEvent -Event "CmdRun"

Expand Down
Loading

0 comments on commit 74d10dd

Please sign in to comment.