Skip to content

Commit

Permalink
Merge branch 'develop' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
silverhack committed Aug 31, 2022
2 parents ca69fd6 + 96032cb commit 41023b2
Show file tree
Hide file tree
Showing 39 changed files with 158 additions and 122 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ azurereview.log
# Data folder
monkey-reports*

# Azurite
__azurite_db_queue__.json
__azurite_db_queue_extent__.json

site/
*.csv

Expand Down
2 changes: 1 addition & 1 deletion Invoke-Monkey365.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Function Invoke-Monkey365{
.PARAMETER DeviceCode
Authenticate by using device code authentication flow
#>
[CmdletBinding()]
[CmdletBinding(HelpUri='https://silverhack.github.io/monkey365/')]
Param (
# pscredential of the user requesting the token
[Parameter(Mandatory = $false, ParameterSetName = 'Implicit')]
Expand Down
2 changes: 1 addition & 1 deletion config/monkey_365.config
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"netversion": "378389"
},
"version": {
"Monkey365Version": "0.6-beta"
"Monkey365Version": "0.6.2-beta"
},
"debug": {
"showResponseHeaders": "false"
Expand Down
4 changes: 4 additions & 0 deletions core/analysis/Invoke-AzureScanner.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ Function Invoke-AzureScanner{
Out-MonkeyData -MonkeyExportObject $MonkeyExportObject
#Increment count
$count+= 1
#Reset Report var
if($null -ne (Get-Variable -Name Report -Scope Script -ErrorAction Ignore)){
Remove-Variable -Name Report -Scope Script -Force
}
}
}
}
6 changes: 3 additions & 3 deletions core/api/auth/Connect-MonkeyCloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -203,16 +203,16 @@ Function Connect-MonkeyCloud{
#Connect to root site
$sps_params = $app_params.Clone()
$sps_params.Add('rootSite',$true);
$Script:o365_connections.SharepointOnline = (Connect-MonkeySharepointOnline -parameters $sps_params)
$Script:o365_connections.SharePointOnline = (Connect-MonkeySharepointOnline -parameters $sps_params)
#Connect to the admin site
$sps_params = $app_params.Clone()
$sps_params.Add('Admin',$true);
$Script:o365_connections.SharepointAdminOnline = (Connect-MonkeySharepointOnline -parameters $sps_params)
$Script:o365_connections.SharePointAdminOnline = (Connect-MonkeySharepointOnline -parameters $sps_params)
#Connects to OneDrive site
$sps_params = $app_params.Clone()
$sps_params.Add('oneDrive',$true);
$Script:o365_connections.OneDrive = (Connect-MonkeySharepointOnline -parameters $sps_params)
if($null -ne $Script:o365_connections.SharepointOnline){
if($null -ne $Script:o365_connections.SharePointOnline){
$Script:OnlineServices.SPS = $True
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ Function Select-MonkeyAzureSubscription{
$selected_subscriptions = $AllSubscriptions
}
elseif($O365Object.initParams.ContainsKey('subscriptions')){
$selected_subscriptions = @()
foreach($subscriptionId in $O365Object.initParams.subscriptions.Split(' ')){
$sub = $AllSubscriptions | Where-Object {$_.subscriptionId -eq $subscriptionId} | Select-Object * -ErrorAction Ignore
if($sub){$selected_subscriptions += $sub}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Function Invoke-MonkeySPSUrlRequest{
)
Begin{
if($null -eq $Authentication){
Write-Warning -Message ($message.NullAuthenticationDetected -f "Sharepoint Online")
Write-Warning -Message ($message.NullAuthenticationDetected -f "SharePoint Online")
return
}
#Get Authorization Header
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Function Test-IsUserSharepointAdministrator{
Param()
Begin{
#Get Access Token for Sharepoint admin
$sps_admin_auth = $O365Object.auth_tokens.SharepointAdminOnline
$sps_admin_auth = $O365Object.auth_tokens.SharePointAdminOnline
}
Process{
$params = @{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ Function Get-MonkeyPSWebPermission{

[cmdletbinding()]
Param (
[Parameter(Mandatory= $true, HelpMessage="Sharepoint Web Object")]
[Parameter(Mandatory= $true, HelpMessage="SharePoint Web Object")]
[Object]$Web
)
Begin{
#Get Access Token for Sharepoint
$sps_auth = $O365Object.auth_tokens.SharepointOnline
$sps_auth = $O365Object.auth_tokens.SharePointOnline
#Get switchs
$inherited = [System.Convert]::ToBoolean($O365Object.internal_config.o365.SharePointOnline.SitePermissions.IncludeInheritedPermissions)
#Get Web object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ Function Get-MonkeySPSWebsForUser{

Begin{
#Get Access Token for Sharepoint
$sps_auth = $O365Object.auth_tokens.SharepointOnline
$sps_auth = $O365Object.auth_tokens.SharePointOnline
#Get Access Token for Sharepoint admin
$sps_admin_auth = $O365Object.auth_tokens.SharepointAdminOnline
$sps_admin_auth = $O365Object.auth_tokens.SharePointAdminOnline
#Get switchs
$scanSites = [System.Convert]::ToBoolean($O365Object.internal_config.o365.SharePointOnline.ScanSites)
$recurseScan = [System.Convert]::ToBoolean($O365Object.internal_config.o365.SharePointOnline.Subsites.Recursive)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
Function Invoke-MonkeyPSCrawlWeb{
<#
.SYNOPSIS
Plugin to get information about O365 Sharepoint Online sites, including List items, files, folders, etc..
Plugin to get information about O365 SharePoint Online sites, including List items, files, folders, etc..
.DESCRIPTION
Plugin to get information about O365 Sharepoint Online sites, including List items, files, folders, etc..
Plugin to get information about O365 SharePoint Online sites, including List items, files, folders, etc..
.INPUTS
Expand All @@ -39,12 +39,12 @@ Function Invoke-MonkeyPSCrawlWeb{

[cmdletbinding()]
Param (
[Parameter(Mandatory= $true, HelpMessage="Sharepoint Web Object")]
[Parameter(Mandatory= $true, HelpMessage="SharePoint Web Object")]
[Object]$Web
)
Begin{
#Get Access Token for Sharepoint
$sps_auth = $O365Object.auth_tokens.SharepointOnline
#Get Access Token for SharePoint
$sps_auth = $O365Object.auth_tokens.SharePointOnline
#Exclude system lists
$ExcludedLists = @(
"Access Requests","App Packages","appdata","appfiles",
Expand Down
57 changes: 41 additions & 16 deletions core/init/Get-MonkeyPlugin.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,14 @@ Function Get-MonkeyPlugin{
if($azure_ad_plugins){
foreach($element in $azure_ad_plugins){
$p_path = ("{0}/{1}" -f $O365Object.Localpath, $element)
$selected_plugins+= Get-ChildItem -Path $p_path -Recurse `
-File -Include "*.ps1" `
-ErrorAction Ignore
$params = @{
Path = $p_path;
Recurse = $true;
File = $true;
Include = "*.ps1";
ErrorAction = 'Ignore';
}
$selected_plugins+= Get-ChildItem @params
}
}
#Check if dump users with internal Graph API
Expand All @@ -173,21 +178,31 @@ Function Get-MonkeyPlugin{
if($null -ne $O365Object.Instance){
switch ($O365Object.Instance.ToLower()){
'azure'{
if($O365Object.initParams.Analysis.ToLower().Contains('all')){
if($O365Object.initParams.Analysis.ToLower() -eq 'all'){
$p_path = ("{0}/{1}" -f $O365Object.Localpath, "plugins/azure/")
$selected_plugins+= Get-ChildItem -Path $p_path -Recurse `
-File -Include "*.ps1" `
-ErrorAction Ignore
$params = @{
Path = $p_path;
Recurse = $true;
File = $true;
Include = "*.ps1";
ErrorAction = 'Ignore';
}
$selected_plugins+= Get-ChildItem @params
}
else{
foreach($plugin in $O365Object.initParams.Analysis.GetEnumerator()){
if($AzurePlugins.ContainsKey($plugin)){
$pluginPaths = $AzurePlugins.Item($plugin)
foreach($element in $pluginPaths){
$p_path = ("{0}/{1}" -f $O365Object.Localpath, $element.Trim())
$selected_plugins+= Get-ChildItem -Path $p_path -Recurse `
-File -Include "*.ps1" `
-ErrorAction Ignore
$params = @{
Path = $p_path;
Recurse = $true;
File = $true;
Include = "*.ps1";
ErrorAction = 'Ignore';
}
$selected_plugins+= Get-ChildItem @params
}
}
else{
Expand All @@ -200,19 +215,29 @@ Function Get-MonkeyPlugin{
'office365'{
if($O365Object.initParams.Analysis.ToLower().Contains('all')){
$p_path = ("{0}/{1}" -f $O365Object.Localpath, "plugins/o365/")
$selected_plugins+= Get-ChildItem -Path $p_path -Recurse `
-File -Include "*.ps1" `
-ErrorAction Ignore
$params = @{
Path = $p_path;
Recurse = $true;
File = $true;
Include = "*.ps1";
ErrorAction = 'Ignore';
}
$selected_plugins+= Get-ChildItem @params
}
else{
foreach($plugin in $O365Object.initParams.Analysis.GetEnumerator()){
if($O365Plugins.ContainsKey($plugin)){
$pluginPaths = $O365Plugins.Item($plugin)
foreach($element in $pluginPaths){
$p_path = ("{0}/{1}" -f $O365Object.Localpath, $element)
$selected_plugins+= Get-ChildItem -Path $p_path -Recurse `
-File -Include "*.ps1" `
-ErrorAction Ignore
$params = @{
Path = $p_path;
Recurse = $true;
File = $true;
Include = "*.ps1";
ErrorAction = 'Ignore';
}
$selected_plugins+= Get-ChildItem @params
}
}
else{
Expand Down
4 changes: 2 additions & 2 deletions core/init/Initialize-MonkeyVar.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ Function Initialize-MonkeyVar{
Yammer = $null;
Forms = $null;
Lync= $null;
SharepointAdminOnline = $null;
SharepointOnline = $null;
SharePointAdminOnline = $null;
SharePointOnline = $null;
OneDrive = $null;
AADRM = $null;
MSGraph = $null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

Function Get-AdalTokenForSharepointOnline {
Function Get-AdalTokenForSharePointOnline {
<#
.SYNOPSIS
Expand All @@ -27,7 +27,7 @@ Function Get-AdalTokenForSharepointOnline {
.NOTES
Author : Juan Garrido
Twitter : @tr1ana
File Name : Get-AdalTokenForSharepointOnline
File Name : Get-AdalTokenForSharePointOnline
Version : 1.0
.LINK
Expand All @@ -48,7 +48,7 @@ Function Get-AdalTokenForSharepointOnline {
[parameter(Mandatory= $false, ParameterSetName = 'Implicit', HelpMessage= "User for access to the O365 services")]
[String]$UserPrincipalName,

[parameter(Mandatory= $false, HelpMessage= "Sharepoint Url")]
[parameter(Mandatory= $false, HelpMessage= "SharePoint Url")]
[String]$Endpoint,

# Tenant identifier of the authority to issue token.
Expand Down Expand Up @@ -149,13 +149,13 @@ Function Get-AdalTokenForSharepointOnline {
[Parameter(Mandatory=$false, ParameterSetName = 'Implicit', HelpMessage="Device code authentication")]
[Switch]$DeviceCode,

[Parameter(Mandatory=$false, HelpMessage="Connect Sharepoint Admin Url")]
[Parameter(Mandatory=$false, HelpMessage="Connect SharePoint Admin Url")]
[Switch]$Admin,

[Parameter(Mandatory=$false, HelpMessage="Connect Sharepoint Siteroot Url")]
[Parameter(Mandatory=$false, HelpMessage="Connect SharePoint Siteroot Url")]
[Switch]$rootSite,

[Parameter(Mandatory=$false, HelpMessage="Connect Sharepoint Siteroot Url")]
[Parameter(Mandatory=$false, HelpMessage="Connect SharePoint Siteroot Url")]
[Switch]$oneDrive
)
Begin{
Expand Down Expand Up @@ -186,12 +186,12 @@ Function Get-AdalTokenForSharepointOnline {
}
elseif($Admin){
if($null -ne $Tenant){
$sharepointUrl = Get-SharepointAdminUrl -TenantDetails $Tenant
$sharepointUrl = Get-SharePointAdminUrl -TenantDetails $Tenant
}
}
elseif($rootSite){
if($null -ne $Tenant){
$sharepointUrl = Get-SharepointUrl -TenantDetails $Tenant
$sharepointUrl = Get-SharePointUrl -TenantDetails $Tenant
}
}
elseif($oneDrive){
Expand All @@ -201,8 +201,8 @@ Function Get-AdalTokenForSharepointOnline {
}
else{
if($null -ne $Tenant){
#Connect to Sharepoint Admin Url
$sharepointUrl = Get-SharepointAdminUrl -TenantDetails $Tenant
#Connect to SharePoint Admin Url
$sharepointUrl = Get-SharePointAdminUrl -TenantDetails $Tenant
}
}
#Set clientId
Expand All @@ -222,7 +222,7 @@ Function Get-AdalTokenForSharepointOnline {
if($null -ne $sps_login -and $sps_login -is [Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationResult]){
#Write message
$msg = @{
MessageData = ($Script:messages.SuccessfullyConnectedTo -f "Sharepoint Online")
MessageData = ($Script:messages.SuccessfullyConnectedTo -f "SharePoint Online")
Tags = @('adalSuccessAuth');
InformationAction = $informationAction;
}
Expand All @@ -231,7 +231,7 @@ Function Get-AdalTokenForSharepointOnline {
}
else{
#Write message
Write-Warning -Message ($Script:messages.UnableToGetToken -f "Sharepoint Online")
Write-Warning -Message ($Script:messages.UnableToGetToken -f "SharePoint Online")
return $null
}
}
Expand Down
Loading

0 comments on commit 41023b2

Please sign in to comment.