Skip to content

Commit

Permalink
update collectors
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhack committed Aug 9, 2024
1 parent 09d02c7 commit 2941846
Show file tree
Hide file tree
Showing 13 changed files with 661 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,46 +89,20 @@ function Get-MonkeyAADDirectoryRole {
MessageData = ($message.MonkeyGenericTaskMessage -f $collectorId,"Microsoft Entra ID Directory Roles",$O365Object.TenantID);
callStack = (Get-PSCallStack | Select-Object -First 1);
logLevel = 'info';
InformationAction = $InformationAction;
InformationAction = $O365Object.InformationAction;
Tags = @('AzureMSGraphDirectoryRole');
}
Write-Information @msg
#Get Role Assignment
$p = @{
APIVersion = $aadConf.api_version;
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$directory_roles = Get-MonkeyMSGraphAADRoleAssignment @p
#Get AAD role assignment
#Get Entra ID role assignment
$p = @{
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$aad_role_assignment = Get-MonkeyMSGraphAADDirectoryRole @p
$aad_role_assignment = Get-MonkeyMSGraphEntraRoleAssignment @p
}
end {
if ($directory_roles) {
$directory_roles.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.DirectoryRoles')
[pscustomobject]$obj = @{
Data = $directory_roles;
Metadata = $monkey_metadata;
}
$returnData.aad_directory_roles = $obj
}
else {
$msg = @{
MessageData = ($message.MonkeyEmptyResponseMessage -f "Directory roles",$O365Object.TenantID);
callStack = (Get-PSCallStack | Select-Object -First 1);
logLevel = 'verbose';
Tags = @('AzureGraphUsersEmptyResponse');
Verbose = $O365Object.Verbose;
}
Write-Verbose @msg
}
if ($aad_role_assignment) {
End {
If ($aad_role_assignment) {
$aad_role_assignment.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.RoleAssignment')
[pscustomobject]$obj = @{
Data = $aad_role_assignment;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ function Get-MonkeyAADExternalCollaboration {
break
}
$externalCollaboration = $ctAccessPolicy = $null
#Set PsObject
$crossTenantAccessPolicyObj = New-MonkeyEntraCrossTenantAccessPolicyObject
}
process {
$msg = @{
Expand All @@ -101,27 +103,45 @@ function Get-MonkeyAADExternalCollaboration {
Debug = $O365Object.Debug;
}
$externalCollaboration = Get-MonkeyMSGraphExternalCollaborationSetting @p
#Get default cross-tenant access policy
$p = @{
APIVersion = $aadConf.api_version;
Default = $true;
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$crossTenantAccessPolicyObj.defaultCrossTenantAccessPolicy = Get-MonkeyMSGraphcrossTenantAccessPolicy @p
#Get cross-tenant access policies for partners
$p = @{
APIVersion = $aadConf.api_version;
Partner = $true;
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$crossTenantAccessPolicyObj.partnerCrossTenantAccessPolicy = Get-MonkeyMSGraphcrossTenantAccessPolicy @p
#Get cross-tenant access policy
$p = @{
$p = @{
APIVersion = $aadConf.api_version;
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$ctAccessPolicy = Get-MonkeyMSGraphcrossTenantAccessPolicy @p
$crossTenantAccessPolicyObj.crossTenantAccessPolicy = Get-MonkeyMSGraphcrossTenantAccessPolicy @p
}
end {
if ($null -ne $ctAccessPolicy) {
$ctAccessPolicy.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.CrossTenantAccessPolicy')
if ($null -ne $crossTenantAccessPolicyObj) {
$crossTenantAccessPolicyObj.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.CrossTenantAccessPolicy')
[pscustomobject]$obj = @{
Data = $ctAccessPolicy;
Data = $crossTenantAccessPolicyObj;
Metadata = $monkey_metadata;
}
$returnData.aad_cross_tenant_accessPolicy = $obj;
}
else {
$msg = @{
MessageData = ($message.MonkeyEmptyResponseMessage -f "Microsoft Entra ID Cross-Tenant access policy",$O365Object.TenantID);
MessageData = ($message.MonkeyEmptyResponseMessage -f "Microsoft Entra ID cross-tenant access policy",$O365Object.TenantID);
callStack = (Get-PSCallStack | Select-Object -First 1);
logLevel = "verbose";
InformationAction = $O365Object.InformationAction;
Expand Down
2 changes: 1 addition & 1 deletion collectors/aad/msgraph/groups/Get-MonkeyAADGroup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function Get-MonkeyAADGroup {
}
end {
if ($null -ne $groups) {
$domains.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.GroupInfo')
$groups.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.GroupInfo')
[pscustomobject]$obj = @{
Data = $groups;
Metadata = $monkey_metadata;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


function Get-MonkeyAADIdentityProtectionNotification {
<#
.SYNOPSIS
Collector to get notification settings for Entra ID Identity Protection
.DESCRIPTION
Collector to get notification settings for Entra ID Identity Protection
.INPUTS
.OUTPUTS
.EXAMPLE
.NOTES
Author : Juan Garrido
Twitter : @tr1ana
File Name : Get-MonkeyAADIdentityProtectionNotification
Version : 1.0
.LINK
https://github.com/silverhack/monkey365
#>

[CmdletBinding()]
param(
[Parameter(Mandatory = $false,HelpMessage = "Background Collector ID")]
[string]$collectorId
)
Begin {
#Collector metadata
$monkey_metadata = @{
Id = "aad0045";
Provider = "EntraID";
Resource = "EntraID";
ResourceType = $null;
resourceName = $null;
collectorName = "Get-MonkeyAADIdentityProtectionNotification";
ApiType = "MSGraph";
description = "Collector to get notification settings for Entra ID Identity Protection";
Group = @(
"EntraID"
);
Tags = @{
"enabled" = $true
};
Docs = "https://silverhack.github.io/monkey365/";
ruleSuffixes = @(
"aad_identityprotection_notifications"
);
dependsOn = @(

);
}
$notifications = $null
}
Process {
$msg = @{
MessageData = ($message.MonkeyGenericTaskMessage -f $collectorId,"Microsoft Entra ID Identity Protection Notifications",$O365Object.TenantID);
callStack = (Get-PSCallStack | Select-Object -First 1);
logLevel = 'info';
InformationAction = $O365Object.InformationAction;
Tags = @('EntraIDIdentityProtectionNotificationInfo');
}
Write-Information @msg
$p = @{
APIVersion = 'beta';
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$notifications = Get-MonkeyMSGraphIdentityProtectionNotification @p
}
End {
if ($null -ne $notifications) {
$notifications.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.IdentityProtection.Notifications')
[pscustomobject]$obj = @{
Data = $notifications;
Metadata = $monkey_metadata;
}
$returnData.aad_identityprotection_notifications = $obj;
}
else {
$msg = @{
MessageData = ($message.MonkeyEmptyResponseMessage -f "Microsoft Entra ID Identity Protection Notifications",$O365Object.TenantID);
callStack = (Get-PSCallStack | Select-Object -First 1);
logLevel = "verbose";
InformationAction = $O365Object.InformationAction;
Verbose = $O365Object.Verbose;
Tags = @('EntraIDIdentityProtectionNotificationEmptyResponse')
}
Write-Verbose @msg
}
}
}







Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function Get-MonkeyPIMRoleAssignment {
ResourceType = $null;
resourceName = $null;
collectorName = "Get-MonkeyPIMRoleAssignment";
ApiType = "PIM";
ApiType = "MSGraph";
description = "Collector to get information about role assignment from PIM";
Group = @(
"EntraID"
Expand Down Expand Up @@ -84,7 +84,7 @@ function Get-MonkeyPIMRoleAssignment {
Verbose = $O365Object.Verbose;
Debug = $O365Object.Debug;
}
$role_assignment = Invoke-MonkeyPrivilegedIdentityInfo @p
$role_assignment = Get-MonkeyMSGraphPIMRoleAssignment @p
}
end {
if ($null -ne $role_assignment) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function Get-MonkeyAADSecureScoreControlProfile {
};
Docs = "https://silverhack.github.io/monkey365/";
ruleSuffixes = @(
"aad_conditional_access_policy"
"aad_secureScore_controlProfile"
);
dependsOn = @(

Expand Down Expand Up @@ -101,14 +101,14 @@ function Get-MonkeyAADSecureScoreControlProfile {
}
$ss_control_profile = Get-MonkeyMSGraphSecureScoreControlProfile @p
}
end {
End {
if ($null -ne $ss_control_profile) {
$ss_control_profile.PSObject.TypeNames.Insert(0,'Monkey365.EntraID.SecureScoreControlProfile')
[pscustomobject]$obj = @{
Data = $ss_control_profile;
Metadata = $monkey_metadata;
}
$returnData.aad_conditional_access_policy = $obj;
$returnData.aad_secureScore_controlProfile = $obj;
}
else {
$msg = @{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,15 @@ function Get-MonkeyADDirectoryProperty {
#Get Azure B2B directory policy
$params.Query = "B2B/b2bPolicy"
$azure_ad_b2b_directory_policies = Get-MonkeyAzurePortalObject @params
#Mock b2b directory policy if not exists
if($null -eq $azure_ad_b2b_directory_policies){
$azure_ad_b2b_directory_policies = [PsCustomObject]@{
targetedDomains = @();
hasListEntries = $false;
adminConsentedForUsersIntoTenantIds = @();
noAADConsentForUsersFromTenantsIds = @();
}
}
}
end {
#Return directory properties
Expand Down
Loading

0 comments on commit 2941846

Please sign in to comment.