Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
365Inspect — 一个用于自动化 Microsoft 365 环境安全评估的 PowerShell 脚本。 | Kitploit
工具/GitHubGitHub/soteria-security/365inspect
防御工具漏洞扫描器配置审计渗透测试云安全
GitHubsoteria-security/365inspect

365Inspect

一个用于自动化 Microsoft 365 环境安全评估的 PowerShell 脚本。

查看仓库
6601141年前Kitploit 审核通过

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享
网站





目的

编写一个 PowerShell 脚本,自动化 Microsoft 365 环境的安全评估,以推进 Microsoft 365 安全领域的发展。

Soteria Inspect

Soteria Inspect 源自 365Inspect 项目,是 Soteria 的 SaaS 解决方案,旨在协助评估 Microsoft 365 租户的安全性,涵盖 Microsoft 365 全套服务中的 200 多个检查点。

Microsoft 365 版 Soteria Inspect 允许客户跟踪每个发现项所影响的对象随时间的变化以及修复工作,现在还包括为 MSP 和上级组织提供的多租户功能,以便随时了解其子租户的情况。

Microsoft 365 版 Soteria Inspect 可直接通过 Soteria 或通过 Azure Marketplace 获取

查看我们所有的 Microsoft 365 版 Soteria Inspect 产品

查看功能对比!

365Inspect 社区版与 Microsoft 365 版 Soteria Inspect 对比

设置

365Inspect 社区版需要用于 Exchange 管理、Microsoft Graph、Microsoft Teams 和 SharePoint 管理的管理 PowerShell 模块。

365Inspect 现已兼容 PowerShell Core (6+),并且由于所需的模块依赖关系,需要 Microsoft Windows 操作系统。

365Inspect.ps1 PowerShell 脚本将验证已安装的模块以及检查器运行所需的最低模块版本。

如果您没有安装这些模块,系统将提示您安装它们,得到您的同意后,脚本将尝试安装。否则,您可以通过在管理 PowerShell 提示符下运行以下命令,或按照下方参考文档中的说明进行安装:

root@kitploit:~
Install-Module -Name ExchangeOnlineManagement -AllowClobber -Force

Install-Module -Name PnP.PowerShell -AllowClobber -Force

Install-Module -Name Microsoft.Graph -AllowClobber -Force

Install-Module -Name MicrosoftTeams -AllowClobber -Force

安装 Exchange Online PowerShell

安装 SharePoint PnP PowerShell 模块

安装 Microsoft Graph SDK

安装 Microsoft Teams

安装完上述模块后,使用浏览器或通过 git clone 从 Github 下载 365Inspect 源码文件夹。

重大变更

PnP.PowerShell 模块

自 2024 年 9 月 9 日起,PnP.PowerShell 要求租户管理员注册自己的应用程序以用于 SharePoint/PnP 服务。

请参阅以下 PnP.PowerShell 文档了解所需步骤。 注册一个 Entra ID 应用程序以用于 PnP PowerShell 确定权限 身份验证

注意:如果您使用的是 PowerShell 5.1,PnP PowerShell 不再兼容,所有 SharePoint 检查器将在运行时被排除。

有一个可运行的命令可以 自动完成此步骤。```powershell Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "PnP Rocks" -Tenant [yourtenant].onmicrosoft.com -Interactive

root@kitploit:~
__请记住所创建应用程序的名称或应用程序/客户端ID。这是现在进行身份验证所必需的,系统会提示你输入AppID!__

# 模块兼容性

目前,Microsoft.Graph 和 Microsoft.Graph.Beta 模块版本 2.23.0 与 ExchangeOnlineManagement 版本 3.5.1 不兼容。
以下版本兼容:
- Microsoft.Graph 版本 2.21.1
- Microsoft.Graph.Beta 版本 2.21.1
- ExchangeOnlineManagement 版本 3.5.0

可以使用以下命令安装兼容版本:```powershell
Install-Module -Name Microsoft.Graph -Scope CurrentUser -RequiredVersion 2.21.1 -AllowClobber -Force
Install-Module -Name Microsoft.Graph.Beta -Scope CurrentUser -RequiredVersion 2.21.1 -AllowClobber -Force
Install-Module -Name ExchangeOnlineManagement -Scope CurrentUser -RequiredVersion 3.5.0 -AllowClobber -Force

由于您将以管理员权限运行 365Inspect,应将其放置在合理的位置,并确保文件夹内容仅对管理员用户可读可写。如果您计划将 365Inspect 安装在频繁执行或用作自动化流程一部分的位置,这一点尤其重要。注意: 365Inspect 无需在管理 PowerShell 窗口中运行即可正常使用。

使用方法

要运行 365Inspect,请打开 PowerShell 控制台,导航到您下载 365Inspect 的文件夹:

root@kitploit:~
cd 365Inspect

您将通过从 PowerShell 命令提示符执行主脚本文件 365Inspect.ps1 来与 365Inspect 交互。

365Inspect 检查您的 M365 租户所需的全部条件是通过具有适当权限的 M365 账户进行访问,因此大多数命令行参数与正在评估的组织和身份验证方法相关。

执行 365Inspect 的格式如下:

root@kitploit:~
.\365Inspect.ps1 -OutPath <value> -UserPrincipalName [email protected] -Auth <MFA|DEVICE|ALREADY_AUTHED|APP> -pnpPowerShellApplicationId <Your Pnp PowerShell Application/Client ID>
执行示例

脚本执行

例如,通过浏览器输入凭据并支持 MFA 登录:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth MFA

要登录到政府或其他国家云部署(中国、德国等),应指定 -Environment 参数,如下所示:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth MFA -Environment USGovGCCHigh

-Environment 的有效参数包括:

  • Default - 默认 Microsoft 365 租户授权终结点。如果未指定 Environment 参数,这是默认参数。
  • USGovGCCHigh - 美国政府 GCC High 租户
  • USGovDoD - 美国政府 DoD 租户
  • Germany - Microsoft 365 Azure Germany 托管的租户
  • China - Microsoft 365 中国/Vianet 托管的租户

可通过以下参数执行脚本实现应用程序身份验证:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth APP

要登录到政府或其他国家云部署(中国、德国等),应指定 -Environment 参数,如下所示:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth APP -Environment USGovGCCHigh

-Environment 的有效参数包括:

随着 365Inspect 的执行,它会稳定地打印状态更新,指示正在运行哪个检查任务。

365Inspect 可能需要一些时间执行。这个时间随被测环境的大小和复杂性而变化。例如,某些检查任务涉及扫描所有用户的账户配置。对于拥有 50 个用户的组织,这可能近乎瞬间完成,但对于拥有 10000 个用户的组织,可能需要整整几分钟(!)。

输出

365Inspect 创建 out_path 参数中指定的目录。此目录是整个 365Inspect 检查的结果。它包含四个重要项目:

  • Report.html:图形报告,描述 365Inspect 识别的 M365 安全问题,列出配置错误的 M365 对象,并提供修复建议。
  • Various text files named [Inspector-Name]:这些是检查器模块的原始输出,包含一行一个列表的配置错误的 M365 对象。例如,如果模块 Inspect-FictionalMFASettings 检测到所有未设置 MFA 的用户,报告 ZIP 中的文件 "Inspect-FictionalMFASettings" 将每行包含一个未设置 MFA 的用户。此信息仅在发现超过 15 个受影响对象时转储到文件。如果发现少于 15 个受影响对象,这些对象会直接列在主要 HTML 报告正文中。
  • Report.zip:此整个目录的压缩版本,用于在检查器模块生成了大量发现时方便分发结果。
  • Log directory:365Inspect 将在 Log 目录中记录脚本执行期间遇到的任何错误的带时间戳日志文件。

CSV 输出

由于某些返回项目的性质,CSV 报告使用脱字符 (^) 作为分隔符。 建议在文本编辑器中打开 CSV 报告,而不是 Excel,因为 Excel 默认使用逗号 (,) 分隔符,会导致报告显示错误。 在文本编辑器中打开后,数据可以粘贴到 Excel 中。

即将推出!

  • 告诉我们!

变更日志

  • 添加了对应用程序身份验证降低角色要求的支持 - 服务主体现在可以分配全局读取者角色,代价是某些检查器无法执行。
  • 减少了应用程序权限范围 - DelegatedPermissionGrant.ReadWrite.All 已替换为 DelegatedPermissionGrant.Read.All,这是一个以前不可用的 API 权限。
旧版变更

旧版变更

  • 支持设备身份验证

  • 支持国家云部署

  • 365Inspect 现在支持应用程序身份验证

  • 365Inspect 的 HTML 报告格式已更改

    • 新增两个图表形式的风险视觉指示器 风险图表
    • 将 PowerShell 命令与修复步骤分开,并添加了语法高亮 PowerShell 命令
    • 将执行的检查器列表移至报告底部的附录中 附录

必要权限

除非您用于身份验证的 M365 账户具有适当的权限,否则 365Inspect 无法正常运行。365Inspect 至少需要以下权限:

  • 全局管理员
  • SharePoint 管理员

我们知道这些是极其宽松的角色,不幸的是,由于使用了 Microsoft Graph,我们受到 Microsoft 的限制,无法使用较低的权限。应用程序和云应用程序管理员角色(用于授予委托和应用程序权限)被限制为 Microsoft Graph 或 Azure AD PowerShell 模块授予权限。Microsoft Docs - 应用程序管理员

如果使用应用程序身份验证参数执行 365Inspect,必须授予其他角色以允许应用程序执行所有任务。请参见应用程序身份验证要求

应用程序身份验证要求

在使用 365Inspect 之前,必须准备好所有其他必要组件。

先决条件准备

为了最有效地利用时间,建议按以下顺序执行必要功能:

  1. 准备客户端机器
    1. 客户端机器__必须__是 Microsoft Windows 操作系统
    2. 安装上方设置部分列出的所需 PowerShell 模块
    3. 确保正确的访问控制已就位
  2. 创建必要的证书
    1. 为 Azure 应用程序身份验证创建自签名证书
  3. 创建 Azure 应用程序
    1. 创建服务主体
    2. 为应用程序分配必要的权限 API 权限
    3. 为应用程序的服务主体分配所需角色
      1. 全局管理员或全局读取者
      2. Exchange 管理员
      3. Teams 管理员
      4. SharePoint 管理员
    4. 上传证书
    5. 记录必要信息
  4. 获取 365Inspect 工具
    1. 下载并将工具解压到客户端上的所需位置

请参考以下资料:

  • 教程:使用 Microsoft Entra ID 注册应用程序
  • Exchange Online PowerShell 和安全与合规 PowerShell 中无人值守脚本的仅应用身份验证
  • Microsoft Entra ID 中的应用程序和服务主体对象

所需权限

展开

所需权限

  • User.Read.All
  • Calendars.Read
  • Mail.Read
  • Contacts.Read
  • TeamMember.Read.All
  • Place.Read.All
  • Chat.UpdatePolicyViolation.All
  • Policy.Read.ConditionalAccess
  • AppCatalog.Read.All
  • TeamsAppInstallation.ReadForUser.All
  • eDiscovery.Read.All
  • UserShiftPreferences.Read.All
  • CustomSecAttributeDefinition.Read.All
  • AgreementAcceptance.Read.All
  • ExternalConnection.Read.All
  • EduRoster.Read.All
  • ServicePrincipalEndpoint.Read.All
  • CloudPC.Read.All
  • DeviceManagementManagedDevices.Read.All
  • OnlineMeetings.Read.All
  • Device.Read.All
  • TeamsTab.Read.All
  • DelegatedAdminRelationship.Read.All
  • UserAuthenticationMethod.Read.All
  • TeamsActivity.Read.All
  • Printer.Read.All
  • OrgContact.Read.All
  • TeamsAppInstallation.ReadForChat.All
  • Policy.Read.PermissionGrant
  • OnlineMeetingArtifact.Read.All
  • SharePointTenantSettings.Read.All
  • ChannelSettings.Read.All
  • SecurityEvents.Read.All
  • DelegatedPermissionGrant.Read.All
  • OnlineMeetingRecording.Read.All
  • IdentityRiskyServicePrincipal.Read.All
  • CrossTenantUserProfileSharing.Read.All
  • Calendars.Read
  • Mail.ReadBasic.All
  • PrivilegedAccess.Read.AzureAD
  • RoleManagement.Read.Directory
  • Channel.ReadBasic.All
  • People.Read.All
  • SecurityAlert.Read.All
  • Group.Read.All
  • AdministrativeUnit.Read.All
  • MailboxSettings.Read
  • CrossTenantInformation.ReadBasic.All
  • EduAdministration.Read.All
  • Sites.Read.All
  • PrintJob.Read.All
  • DeviceManagementServiceConfig.Read.All
  • ServiceMessage.Read.All
  • PrintSettings.Read.All
  • DirectoryRecommendations.Read.All
  • Notes.Read.All
  • EntitlementManagement.Read.All
  • CallRecords.Read.All
  • IdentityUserFlow.Read.All
  • ChatMessage.Read.All

开发检查器模块

365Inspect 的设计易于扩展,希望它能使个人或组织能够在内部使用自己的 365Inspect 模块,或将这些模块发布给 M365 社区。

365Inspect 的所有检查器模块都存储在 .\inspectors 文件夹中。

创建一个检查器模块很简单。检查器有两个文件:

  • ModuleName.ps1:检查器模块的 PowerShell 源代码。应返回受特定问题影响的所有 M365 对象的列表,以字符串形式表示。
  • ModuleName.json:关于检查器本身的元数据。例如,发现名称、描述、修复信息和参考。

Templates 文件夹中包含模板。只需在相应位置添加您的代码和值即可。 PowerShell 和 JSON 文件名必须相同,以便 365Inspect 识别两者属于同一模块。365Inspect 内置的模块套件中有许多示例,但我们在此也提供一个示例。

示例 .ps1 文件,BypassingSafeAttachments.ps1:```powershell # Define a function that we will later invoke. # 365Inspect's built-in modules all follow this pattern. function Inspect-BypassingSafeAttachments { # Query some element of the M365 environment to inspect. Note that we did not have to authenticate to Exchange # to fetch these transport rules within this module; assume main 365Inspect harness has logged us in already. $safe_attachment_bypass_rules = (Get-TransportRule | Where { $_.SetHeaderName -eq "X-MS-Exchange-Organization-SkipSafeAttachmentProcessing" }).Identity
root@kitploit:~
# If some of the parsed M365 objects were found to have the security flaw this module is inspecting for,
# return a list of strings representing those objects. This is what will end up as the "Affected Objects"
# field in the report.
If ($safe_attachment_bypass_rules.Count -ne 0) {
	return $safe_attachment_bypass_rules
}

# If none of the parsed M365 objects were found to have the security flaw this module is inspecting for,
# returning $null indicates to 365Inspect that there were no findings for this module.
return $null

}

Return the results of invoking the inspector function.

return Inspect-BypassingSafeAttachments

root@kitploit:~
</details>

<details>
<summary>示例 .json 文件:BypassingSafeAttachments.json:</summary>```json
{
    "FindingName": "Do Not Bypass the Safe Attachments Filter",
    "Description": "In Exchange, it is possible to create mail transport rules that bypass the Safe Attachments detection capability. The rules listed above bypass the Safe Attachments capability. Consider reviewing these rules, as bypassing the Safe Attachments capability even for a subset of senders could be considered insecure depending on the context or may be an indicator of compromise.",
    "Remediation": "Navigate to the Mail Flow &rarr; Rules screen in the Exchange Admin Center. Look for the offending rules and begin the process of assessing who created them and whether they are necessary to the continued function of the organization. If they are not, remove the rules.",
    "DefaultValue": "None",
    "ExpectedValue": "None",
    "Impact": "Critical",
    "AffectedObjects": "",
    "Service": "Exchange",  // Valid values are Exchange, SharePoint, Teams, Intune, AzureAD, SecurityandCompliance, Tenant //
    "PowerShell": "", // Any PowerShell remediation command examples should be placed here //
    "References": [
        {
            "Url": "https://docs.microsoft.com/en-us/exchange/security-and-compliance/mail-flow-rules/manage-mail-flow-rules",
            "Text": "Manage Mail Flow Rules in Exchange Online"
        },
        {
            "Url": "https://www.undocumented-features.com/2018/05/10/atp-safe-attachments-safe-links-and-anti-phishing-policies-or-all-the-policies-you-can-shake-a-stick-at/#Bypass_Safe_Attachments_Processing",
            "Text": "Undocumented Features: Safe Attachments, Safe Links, and Anti-Phishing Policies"
        }
    ]
}

将这两个文件放入 .\inspectors 文件夹后,它们即被视为 365Inspect 模块清单的一部分,并将在您下次运行 365Inspect 时执行。

您已成功创建 BypassingSafeAttachments Inspector 模块。就这样!

如果您的模块中存在任何不符合 365Inspect 约定或无法正常工作的问题,365Inspect 会在命令行输出中抛出相当明显且刺眼的错误信息,因此请留意命令行输出。

贡献

我们鼓励社区参与和贡献! 请查看我们的贡献指南

关于安全性

365Inspect 是一个脚本框架,用于运行存储在 .\inspectors 文件夹中的其他检查脚本模块。与任何其他可能以提升权限运行的脚本一样,您应遵循一定的安全卫生实践:

  • 任何不受信任的用户都不应具有对 365Inspect 文件夹/文件的写入权限,否则该用户可能覆盖其中的脚本或模板,诱使您运行恶意代码。
  • 除非您信任某个脚本模块的来源,否则不应将其放入 .\inspectors 文件夹。

关于 Soteria

Soteria 提供广泛的安全与咨询解决方案,包括事件响应、托管检测与响应、安全评估、渗透测试等。如有任何需求,请联系我们!

下载工具
  • Default - 默认 Microsoft 365 租户授权终结点。如果未指定 Environment 参数,这是默认参数。
  • USGovGCCHigh - 美国政府 GCC High 租户
  • USGovDoD - 美国政府 DoD 租户
  • Germany - Microsoft 365 Azure Germany 托管的租户
  • China - Microsoft 365 中国/Vianet 托管的租户

注意: 使用应用程序身份验证执行 365Inspect 存在先决条件。前往应用程序身份验证要求

365Inspect 现在支持将报告输出为 HTML(默认值)、CSV 和 XML 格式。

例如,通过调用 -ReportType 参数生成 CSV 报告:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth MFA -ReportType CSV

365Inspect 可以仅运行指定的检查器模块,或者相反,排除指定的模块。

例如,通过浏览器输入凭据并支持 MFA 登录:

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -UserPrincipalName [email protected] -Auth MFA -SelectedInspectors inspector1, inspector2

或者

root@kitploit:~
    .\365Inspect.ps1 -OutPath ..\365_report -Auth MFA -ExcludedInspectors inspector1, inspector2, inspector3

进一步分解参数:

  • OutPath 是放置 365Inspect 生成的报告的文件夹路径。

    • 是否必需?是
  • Auth 是一个选择器,应为字面值 "MFA" 或 "ALREADY_AUTHED"。

    • Auth 控制 365Inspect 如何对所有 Microsoft 365 服务进行身份验证。
    选项
    • Auth MFA 会产生一个图形弹出窗口,您可以在其中输入凭据,甚至为启用了 MFA 的账户输入 MFA 代码。
    • Auth ALREADY_AUTHED 指示 365Inspect 在扫描前不进行身份验证。如果从已具有所有所述服务有效会话的 PowerShell 提示符执行 365Inspect(例如已执行过 365Inspect 的提示符),这可能是首选。
    • Auth APP 指示 365Inspect 提示输入 Microsoft Entra ID 应用程序服务主体信息。必需的参数变量包括:
      • AppId - 注册应用程序的应用程序 ID
      • Certificate Thumbprint - 创建的自签名证书的指纹
      • Domain - 要扫描的租户的邮件域([email protected] 或 company.com)或租户域(company.onmicrosoft.com)。
    * 是否必需?是
  • SelectedInspectors 是您希望与 365Inspect 一起运行的一个或多个检查器的名称。如果选择多个检查器,它们必须用逗号分隔。仅运行指定的检查器。

    • 是否必需?否
  • ExcludedInspectors 是您希望阻止与 365Inspect 一起运行的一个或多个检查器的名称。如果选择多个检查器,它们必须用逗号分隔。将运行所有其他包含的模块。

    • 是否必需?否
  • UserPrincipalName - 评估者的用户主体名称,这有助于减少在受支持的模块中输入凭据的次数。

    • 是否必需?是
  • ReportType - 生成报告的输出格式。当前支持的值包括 HTML(默认)、CSV 和 XML。

    • 是否必需?否
  • Environment - 指定要连接的非标准/消费者 Microsoft 365 租户的 Azure 云实例。

    • 是否必需?否

当您使用 -Auth MFA 执行 365Inspect 时,可能会产生多个图形登录提示,您需要依次登录。这是正常行为,因为 Exchange、SharePoint 等具有独立的管理模块,每个模块都需要不同的登录会话。如果您只是按提示次数登录,365Inspect 应开始执行。这不太有趣,我们正在寻找解决方案,但不用说,我们觉得花费时间查看 MFA 代码所得到的结果是值得的。

  • Directory.Read.All
  • ConsentRequest.Read.All
  • RoleManagement.Read.All
  • CallRecord*PstnCalls.Read.All
  • PrivilegedAccess.Read.AzureResources
  • User.Read.All
  • Domain.Read.All
  • EduAssignments.ReadBasic.All
  • EduRoster.ReadBasic.All
  • Agreement.Read.All
  • OnlineMeetingTranscript.Read.All
  • ChannelMember.Read.All
  • Schedule.Read.All
  • SecurityIncident.Read.All
  • GroupMember.Read.All
  • DeviceManagementRBAC.Read.All
  • RoleManagement.Read.CloudPC
  • Files.Read.All
  • CustomSecAttributeAssignment.Read.All
  • SearchConfiguration.Read.All
  • DeviceManagementConfiguration.Read.All
  • Team.ReadBasic.All
  • APIConnectors.Read.All
  • Mail.Read
  • Chat.Read.All
  • ExternalItem.Read.All
  • ChannelMessage.Read.All
  • EduAssignments.Read.All
  • SecurityActions.Read.All
  • ThreatAssessment.Read.All
  • IdentityProvider.Read.All
  • TeamSettings.Read.All
  • IdentityRiskyUser.Read.All
  • AccessReview.Read.All
  • LicenseAssignment.ReadWrite.All
  • TermStore.Read.All
  • TeamworkTag.Read.All
  • PrivilegedAccess.Read.AzureADGroup
  • InformationProtectionPolicy.Read.All
  • Organization.Read.All
  • Contacts.Read
  • IdentityRiskEvent.Read.All
  • Mail.ReadBasic
  • AuditLog.Read.All
  • Policy.Read.All
  • Policy.ReadWrite.CrossTenantAccess
  • Member.Read.Hidden
  • Chat.ReadBasic.All
  • Application.Read.All
  • ProgramControl.Read.All
  • ServiceHealth.Read.All
  • ChatMember.Read.All
  • DeviceManagementApps.Read.All
  • ThreatIndicators.Read.All
  • TeamsAppInstallation.ReadForTeam.All
  • ShortNotes.Read.All
  • Reports.Read.All
  • PrintJob.ReadBasic.All
  • TrustFrameworkKeySet.Read.All
  • ThreatHunting.Read.All
  • TeamworkDevice.Read.All
  • Synchronization.Read.All
  • AuthenticationContext.Read.All
  • CustomAuthenticationExtension.Read.All
  • ThreatSubmission.Read.All
  • LifecycleWorkflows.Read.All
  • ReportSettings.Read.All
  • RecordsManagement.Read.All
  • RoleManagementAlert.Read.Directory