Skip to content

Commit ee20c45

Browse files
committed
Merge branch 'develop'
2 parents 662db08 + 90e7a78 commit ee20c45

File tree

1,170 files changed

+10360
-1156
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,170 files changed

+10360
-1156
lines changed

Invoke-Monkey365.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,7 @@ Function Invoke-Monkey365{
306306
[Switch]$ForceMSALDesktop,
307307

308308
[Parameter(Mandatory=$false, HelpMessage="List available collectors")]
309-
[Switch]$ListCollector,
310-
311-
[Parameter(Mandatory=$false, HelpMessage="List available rules")]
312-
[Switch]$ListRule
309+
[Switch]$ListCollector
313310
)
314311
dynamicparam{
315312
# Set available instance class
@@ -520,7 +517,7 @@ Function Invoke-Monkey365{
520517
#Connect
521518
Connect-MonkeyCloud
522519
#Start Watcher
523-
if($null -ne (Get-Command -Name "Watch-AccessToken" -ErrorAction ignore)){
520+
If($null -ne (Get-Command -Name "Watch-AccessToken" -ErrorAction ignore)){
524521
Watch-AccessToken
525522
}
526523
}
@@ -579,3 +576,4 @@ Function Invoke-Monkey365{
579576
}
580577
}
581578
}
579+

build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,4 @@ $param = @{
7878
Write-information @param
7979
#Start process
8080
Start-Process docker -ArgumentList $buildArgs -NoNewWindow -Wait
81+

collectors/azure/APIM/Get-MonkeyAZAPIM.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,4 @@ function Get-MonkeyAZAPIM {
131131

132132

133133

134+

collectors/azure/alerts/securityalerts/Get-MonkeyAzSecurityAlert.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,3 +138,4 @@ function Get-MonkeyAzSecurityAlert {
138138

139139

140140

141+
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
# Monkey365 - the PowerShell Cloud Security Tool for Azure and Microsoft 365 (copyright 2022) by Juan Garrido
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
16+
function Get-MonkeyAZApplicationInsightComponent {
17+
<#
18+
.SYNOPSIS
19+
Azure Collector to get application insight component
20+
21+
.DESCRIPTION
22+
Azure Collector to get application insight component
23+
24+
.INPUTS
25+
26+
.OUTPUTS
27+
28+
.EXAMPLE
29+
30+
.NOTES
31+
Author : Juan Garrido
32+
Twitter : @tr1ana
33+
File Name : Get-MonkeyAZApplicationInsightComponent
34+
Version : 1.0
35+
36+
.LINK
37+
https://github.com/silverhack/monkey365
38+
#>
39+
40+
[CmdletBinding()]
41+
param(
42+
[Parameter(Mandatory = $false,HelpMessage = "Background Collector ID")]
43+
[string]$collectorId
44+
)
45+
Begin {
46+
#Collector metadata
47+
$monkey_metadata = @{
48+
Id = "az000108";
49+
Provider = "Azure";
50+
Resource = "Subscription";
51+
ResourceType = $null;
52+
resourceName = $null;
53+
collectorName = "Get-MonkeyAZApplicationInsightComponent";
54+
ApiType = "resourceManagement";
55+
description = "Azure Collector to get application insight component";
56+
Group = @(
57+
"Subscription"
58+
);
59+
Tags = @(
60+
61+
);
62+
references = @(
63+
"https://silverhack.github.io/monkey365/"
64+
);
65+
ruleSuffixes = @(
66+
"az_insight_component"
67+
);
68+
dependsOn = @(
69+
70+
);
71+
enabled = $true;
72+
supportClientCredential = $true
73+
}
74+
#Get Config
75+
$config = $O365Object.internal_config.ResourceManager | Where-Object { $_.Name -eq "azureInsightsComponent" } | Select-Object -ExpandProperty resource
76+
#Get instances
77+
$Instances = $O365Object.all_resources.Where({ $_.Id -like '*microsoft.insights/components*' })
78+
if (-not $Instances) { continue }
79+
$AllInstances = $null
80+
}
81+
Process {
82+
$msg = @{
83+
MessageData = ($message.MonkeyGenericTaskMessage -f $collectorId,"Azure Insights Component",$O365Object.current_subscription.displayName);
84+
callStack = (Get-PSCallStack | Select-Object -First 1);
85+
logLevel = 'info';
86+
InformationAction = $InformationAction;
87+
Tags = @('AzureInsightsInfo');
88+
}
89+
Write-Information @msg
90+
if ($Instances.Count -gt 0) {
91+
$new_arg = @{
92+
APIVersion = $config.api_version;
93+
}
94+
$p = @{
95+
ScriptBlock = { Get-MonkeyAzInsightComponentInfo -InputObject $_ };
96+
Arguments = $new_arg;
97+
Runspacepool = $O365Object.monkey_runspacePool;
98+
ReuseRunspacePool = $true;
99+
Debug = $O365Object.VerboseOptions.Debug;
100+
Verbose = $O365Object.VerboseOptions.Verbose;
101+
MaxQueue = $O365Object.nestedRunspaces.MaxQueue;
102+
BatchSleep = $O365Object.nestedRunspaces.BatchSleep;
103+
BatchSize = $O365Object.nestedRunspaces.BatchSize;
104+
}
105+
$AllInstances = $Instances | Invoke-MonkeyJob @p
106+
}
107+
}
108+
End {
109+
if ($AllInstances) {
110+
$AllInstances.PSObject.TypeNames.Insert(0,'Monkey365.Azure.Application.Insights.Components')
111+
[pscustomobject]$obj = @{
112+
Data = $AllInstances;
113+
Metadata = $monkey_metadata;
114+
}
115+
$returnData.az_insight_component = $obj
116+
}
117+
else {
118+
$msg = @{
119+
MessageData = ($message.MonkeyEmptyResponseMessage -f "Azure Insights Component",$O365Object.TenantID);
120+
callStack = (Get-PSCallStack | Select-Object -First 1);
121+
logLevel = "verbose";
122+
InformationAction = $O365Object.InformationAction;
123+
Tags = @('AzureInsightsEmptyResponse');
124+
Verbose = $O365Object.Verbose;
125+
}
126+
Write-Verbose @msg
127+
}
128+
}
129+
}

collectors/azure/appservices/Get-MonkeyAzAppServiceInfo.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,4 @@ function Get-MonkeyAzAppServiceInfo {
137137

138138

139139

140+

collectors/azure/botchannels/Get-MonkeyAzBotChannel.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,4 @@ function Get-MonkeyAzBotChannel {
139139

140140

141141

142+

collectors/azure/classicvm/virtualmachines/Get-MonkeyAzClassicDisk.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,4 @@ function Get-MonkeyAzClassicDisk {
132132

133133

134134

135+

collectors/azure/classicvm/virtualmachines/Get-MonkeyAzClassicVM.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,4 @@ function Get-MonkeyAzClassicVM {
171171

172172

173173

174+

collectors/azure/cognitive/Get-MonkeyAzCognitiveService.ps1

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function Get-MonkeyAzCognitiveService {
4848
begin {
4949
#Collector metadata
5050
$monkey_metadata = @{
51-
Id = "az00006";
51+
Id = "az00162";
5252
Provider = "Azure";
5353
Resource = "CognitiveServices";
5454
ResourceType = $null;
@@ -77,9 +77,9 @@ function Get-MonkeyAzCognitiveService {
7777
#Get Config
7878
$CognitiveAPI = $O365Object.internal_config.ResourceManager | Where-Object { $_.Name -eq "azureCognitive" } | Select-Object -ExpandProperty resource
7979
#Get Cognitive Services accounts
80-
$cognitive_services = $O365Object.all_resources | Where-Object { $_.type -like 'Microsoft.CognitiveServices/accounts' }
80+
$cognitive_services = $O365Object.all_resources.Where({ $_.type -like '*Microsoft.CognitiveServices/accounts*'})
8181
if (-not $cognitive_services) { continue }
82-
$all_cognitive_services = @();
82+
$all_cognitive_services = $null;
8383
}
8484
process {
8585
$msg = @{
@@ -91,29 +91,22 @@ function Get-MonkeyAzCognitiveService {
9191
}
9292
Write-Information @msg
9393
#Get All Cognitive accounts
94-
if ($cognitive_services) {
95-
foreach ($cognitive_service in $cognitive_services) {
96-
#Set query
97-
$p = @{
98-
Id = $cognitive_service.Id;
99-
APIVersion = $CognitiveAPI.api_version;
100-
Verbose = $O365Object.Verbose;
101-
Debug = $O365Object.Debug;
102-
InformationAction = $O365Object.InformationAction;
103-
}
104-
$my_cognitive_account = Get-MonkeyAzObjectById @p
105-
if ($my_cognitive_account) {
106-
#Get Network properties
107-
if (-not $my_cognitive_account.Properties.NetworkRuleSet) {
108-
$my_cognitive_account | Add-Member -Type NoteProperty -Name allowAccessFromAllNetworks -Value $true
109-
}
110-
else {
111-
$my_cognitive_account | Add-Member -Type NoteProperty -Name allowAccessFromAllNetworks -Value $false
112-
}
113-
#Add cognitive account to array
114-
$all_cognitive_services += $my_cognitive_account
115-
}
94+
if ($cognitive_services.Count -gt 0) {
95+
$new_arg = @{
96+
APIVersion = $CognitiveAPI.api_version;
11697
}
98+
$p = @{
99+
ScriptBlock = { Get-MonkeyAIHubCognitiveAccountInfo -InputObject $_ };
100+
Arguments = $new_arg;
101+
Runspacepool = $O365Object.monkey_runspacePool;
102+
ReuseRunspacePool = $true;
103+
Debug = $O365Object.VerboseOptions.Debug;
104+
Verbose = $O365Object.VerboseOptions.Verbose;
105+
MaxQueue = $O365Object.nestedRunspaces.MaxQueue;
106+
BatchSleep = $O365Object.nestedRunspaces.BatchSleep;
107+
BatchSize = $O365Object.nestedRunspaces.BatchSize;
108+
}
109+
$all_cognitive_services = $cognitive_services | Invoke-MonkeyJob @p
117110
}
118111
}
119112
end {
@@ -147,3 +140,4 @@ function Get-MonkeyAzCognitiveService {
147140

148141

149142

143+

0 commit comments

Comments
 (0)