From 036059a454dc4619badef71c2bbd88e1e14dcb6e Mon Sep 17 00:00:00 2001 From: silverhack Date: Wed, 8 Jan 2025 22:05:47 +0100 Subject: [PATCH] Update Monkey365 --- Invoke-Monkey365.ps1 | 44 +++++++++++++++++++++++++++- README.md | 10 +++---- build.ps1 | 4 +-- monkey365.ps1 | 4 +-- monkey365.psd1 | 10 +++++-- monkey365.psm1 | 4 +-- tests/Get-MonkeyTest.ps1 | 3 +- tests/MonkeyCloudUtils.Tests.ps1 | 4 +-- tests/MonkeyJob.Tests.ps1 | 4 +-- tests/MonkeyWebRequests.Tests.ps1 | 4 +-- tests/MonkeyWebRequestsAPI.Tests.ps1 | 4 +-- 11 files changed, 70 insertions(+), 25 deletions(-) diff --git a/Invoke-Monkey365.ps1 b/Invoke-Monkey365.ps1 index f11173ea..7c725c36 100644 --- a/Invoke-Monkey365.ps1 +++ b/Invoke-Monkey365.ps1 @@ -459,6 +459,48 @@ Function Invoke-Monkey365{ } return } + #Check if list collectors + If($PSBoundParameters.ContainsKey('ListRule') -and $PSBoundParameters['ListRule'].IsPresent){ + #Get command Metadata + $MetaData = New-Object -TypeName "System.Management.Automation.CommandMetaData" (Get-Command -Name "Get-Rule") + $newPsboundParams = [ordered]@{} + if($null -ne $MetaData){ + $param = $MetaData.Parameters.Keys + foreach($p in $param.GetEnumerator()){ + if($PSBoundParameters.ContainsKey($p)){ + $newPsboundParams.Add($p,$PSBoundParameters[$p]) + } + } + #Add verbose, debug + $newPsboundParams.Add('Verbose',$O365Object.verbose) + $newPsboundParams.Add('Debug',$O365Object.debug) + $newPsboundParams.Add('InformationAction',$O365Object.InformationAction) + #Add pretty print + [void]$newPsboundParams.Add('Pretty',$true); + #Add RulesPath + If($newPsboundParams.Contains('RulesPath')){ + $newPsboundParams.RulesPath = $O365Object.rulesPath; + } + Else{ + [void]$newPsboundParams.Add('RulesPath',$O365Object.rulesPath); + } + #Remove RuleSet if null + If($newPsboundParams.Contains('RuleSet') -and $null -eq $newPsboundParams['RuleSet']){ + [void]$newPsboundParams.Remove('RuleSet'); + } + #Remove instance if EntraID is selected + If($newPsboundParams.Contains('Instance') -and $newPsboundParams['Instance'] -eq 'EntraID'){ + [void]$newPsboundParams.Remove('Instance'); + } + #Remove Instance if null + If($newPsboundParams.Contains('Instance') -and $null -eq $newPsboundParams['Instance']){ + [void]$newPsboundParams.Remove('Instance'); + } + #Execute command + Get-Rule @newPsboundParams + } + return + } #Check for mandatory params Test-MandatoryParameter #Import MSAL module @@ -536,4 +578,4 @@ Function Invoke-Monkey365{ [System.GC]::GetTotalMemory($true) | out-null } } -} \ No newline at end of file +} diff --git a/README.md b/README.md index ae71cfe8..5f17ae09 100644 --- a/README.md +++ b/README.md @@ -65,14 +65,14 @@ The following example will retrieve data and metadata from Azure AD and SharePoi ``` powershell -$param = @{ +$options = @{ Instance = 'Microsoft365'; - Analysis = 'SharePointOnline'; + Collect = 'ExchangeOnline'; PromptBehavior = 'SelectAccount'; IncludeEntraID = $true; - ExportTo = 'PRINT'; + ExportTo = 'CSV'; } -$assets = Invoke-Monkey365 @param +Invoke-Monkey365 @options ``` # Regulatory compliance checks @@ -93,9 +93,7 @@ By default, the HTML report shows you the CIS (Center for Internet Security) Ben The following standards are supported by Monkey365: -* CIS Microsoft Azure Foundations Benchmark v2.0.0 * CIS Microsoft Azure Foundations Benchmark v3.0.0 -* CIS Microsoft 365 Foundations Benchmark v2.0.0 * CIS Microsoft 365 Foundations Benchmark v3.0.0 More standards will be added in next releases (NIST, HIPAA, GDPR, PCI-DSS, etc..) as they are available. diff --git a/build.ps1 b/build.ps1 index eecde982..c71ba29d 100644 --- a/build.ps1 +++ b/build.ps1 @@ -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. @@ -77,4 +77,4 @@ $param = @{ } Write-information @param #Start process -Start-Process docker -ArgumentList $buildArgs -NoNewWindow -Wait \ No newline at end of file +Start-Process docker -ArgumentList $buildArgs -NoNewWindow -Wait diff --git a/monkey365.ps1 b/monkey365.ps1 index c8e41336..929a8b99 100644 --- a/monkey365.ps1 +++ b/monkey365.ps1 @@ -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. @@ -14,4 +14,4 @@ [CmdletBinding()] param() -Invoke-Monkey365 \ No newline at end of file +Invoke-Monkey365 diff --git a/monkey365.psd1 b/monkey365.psd1 index 9be2c980..ec5292b4 100644 --- a/monkey365.psd1 +++ b/monkey365.psd1 @@ -12,7 +12,7 @@ RootModule = 'monkey365.psm1' # Version number of this module. -ModuleVersion = '0.93' +ModuleVersion = '0.94' # Supported PSEditions # CompatiblePSEditions = @() @@ -85,7 +85,8 @@ FunctionsToExport = @( 'Copy-PsObject', 'ConvertTo-SecureScriptBlock', 'Update-PsObject', - 'Get-AstFunction' + 'Get-AstFunction', + 'Get-ObjectPropertyByPath' ) # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. @@ -117,10 +118,12 @@ PrivateData = @{ "Microsoft 365 security", "Azure", "AzureAD", + "Entra ID security assessment", "Microsoft Entra", "CSPM", "Office 365", - "Office 365 Security" + "Office 365 Security", + "CIS Benchmark" ) # A URL to the license for this module. @@ -152,3 +155,4 @@ HelpInfoURI = 'https://silverhack.github.io/monkey365/' } + diff --git a/monkey365.psm1 b/monkey365.psm1 index dd86d39c..9da55955 100644 --- a/monkey365.psm1 +++ b/monkey365.psm1 @@ -1,4 +1,4 @@ -#Set-StrictMode -Off #-Version Latest +#Set-StrictMode -Off #-Version Latest Set-StrictMode -Version Latest $LocalizedDataParams = @{ @@ -93,4 +93,4 @@ $all_files = $all_files.Where({$_.EndsWith('ps1')}) $all_files.ForEach({. $_}) $monkey = ("{0}/Invoke-Monkey365.ps1" -f $PSScriptRoot) -. $monkey \ No newline at end of file +. $monkey diff --git a/tests/Get-MonkeyTest.ps1 b/tests/Get-MonkeyTest.ps1 index 8cfbcdb2..8e3f74a9 100644 --- a/tests/Get-MonkeyTest.ps1 +++ b/tests/Get-MonkeyTest.ps1 @@ -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. @@ -51,3 +51,4 @@ Function Get-MonkeyTest{ Write-Host "End!" } } + diff --git a/tests/MonkeyCloudUtils.Tests.ps1 b/tests/MonkeyCloudUtils.Tests.ps1 index d6e2b48f..620f8b41 100644 --- a/tests/MonkeyCloudUtils.Tests.ps1 +++ b/tests/MonkeyCloudUtils.Tests.ps1 @@ -1,4 +1,4 @@ -# PSScriptAnalyzer - ignore test file +# PSScriptAnalyzer - ignore test file Import-Module Pester Set-StrictMode -Version Latest @@ -94,4 +94,4 @@ Describe 'MonkeyCloudUtils' { $tinfo.TenantRegionScope | Should -Be "USGov" } } -} \ No newline at end of file +} diff --git a/tests/MonkeyJob.Tests.ps1 b/tests/MonkeyJob.Tests.ps1 index fc4b9209..30e9633f 100644 --- a/tests/MonkeyJob.Tests.ps1 +++ b/tests/MonkeyJob.Tests.ps1 @@ -1,4 +1,4 @@ -# PSScriptAnalyzer - ignore test file +# PSScriptAnalyzer - ignore test file Import-Module Pester Set-StrictMode -Version Latest @@ -96,4 +96,4 @@ Describe 'MonkeyJob' { Get-MonkeyJob | Remove-MonkeyJob -Force } } -} \ No newline at end of file +} diff --git a/tests/MonkeyWebRequests.Tests.ps1 b/tests/MonkeyWebRequests.Tests.ps1 index 276d47c6..fa3b23ec 100644 --- a/tests/MonkeyWebRequests.Tests.ps1 +++ b/tests/MonkeyWebRequests.Tests.ps1 @@ -1,4 +1,4 @@ -# PSScriptAnalyzer - ignore test file +# PSScriptAnalyzer - ignore test file Import-Module Pester Set-StrictMode -Version Latest @@ -25,4 +25,4 @@ Describe 'Google' { $StatusCode | Should -Be 'OK' } } -} \ No newline at end of file +} diff --git a/tests/MonkeyWebRequestsAPI.Tests.ps1 b/tests/MonkeyWebRequestsAPI.Tests.ps1 index 34d4acfd..311cac69 100644 --- a/tests/MonkeyWebRequestsAPI.Tests.ps1 +++ b/tests/MonkeyWebRequestsAPI.Tests.ps1 @@ -1,4 +1,4 @@ -# PSScriptAnalyzer - ignore test file +# PSScriptAnalyzer - ignore test file Import-Module Pester Set-StrictMode -Version Latest @@ -16,4 +16,4 @@ Describe 'Star Wars' { $Han = Invoke-MonkeyWebRequest -url "https://swapi.dev/api/people/14" $Han.name | Should -Be 'Han Solo' } -} \ No newline at end of file +}