
DFIR-O365RC 在 SSTIC 2021(信息技术与通信安全研讨会)上进行了展示。演示文稿的幻灯片和录制视频(法文)可在此处获取:链接。
⚠️ 2024年3月31日,Microsoft 弃用了 我们用于 DFIR-O365RC 的身份验证方法。因此,我们于2024年8月发布了 2.0.0 版本,其中包含关于身份验证的重大变更以及全局代码重构。⚠️
DFIR-O365RC PowerShell 模块是一组函数,帮助取证分析师收集与 Microsoft 365 入侵相关的日志,并进行 Entra ID 调查。
日志以 JSON 格式生成,并从两个主要数据源获取:
这两个数据源可以通过不同的端点进行查询:
| 数据源 / 端点 | 保留期 | 性能 | 范围 |
|---|---|---|---|
| 统一审核日志 / Exchange Online PowerShell | 90 天 | 较差 | 所有 Microsoft 365 日志(含 Entra) |
| 统一审核日志 / Purview | 180 天 | 良好 | 所有 Microsoft 365 日志(含 Entra) |
| 统一审核日志 / Office 365 Management API * | 7 天 | 良好 | 所有 Microsoft 365 日志(含 Entra) |
| Microsoft Entra 日志 / Microsoft Graph PowerShell | 30 天 | 良好 | 仅限 Entra 登录和审核日志 |
| Microsoft Entra 日志 / Microsoft Graph REST API | 30 天 | 良好 | 仅限 Entra 登录和审核日志 |
* Office 365 Management API 旨在与 SIEM 实时分析数据。DFIR-O365RC 是取证工具,其目的并非实时监控 Microsoft 365 环境。
DFIR-O365RC 将从以下来源获取数据:
如果您正在调查 Microsoft 365 恶意活动,Search-O365(来自 Exchange Online PowerShell)还会获取邮箱审核日志,不过 Search-MailboxAuditLog cmdlet 即将被弃用。
如果您正在调查其他 Azure 资源,使用 DFIR-O365RC 可以:
这是推荐使用 DFIR-O365RC 的方式
只需输入:```bash sudo docker pull anssi/dfir-o365rc:latest sudo docker run --rm -v .:/mnt/host -it anssi/dfir-o365rc:latest
DFIR-O365RC 已准备好使用:```bash
PowerShell 7.4.2
DFIR-O365RC: PowerShell module for Microsoft 365 and Entra ID log collection
https://github.com/ANSSI-FR/DFIR-O365RC
PS /mnt/host/output>
如果您希望手动构建Docker镜像,请克隆仓库并使用 docker compose(或旧版 docker-compose)来构建镜像、运行容器并挂载卷(在 output/ 文件夹中):```bash
sudo docker compose build dfir-o365rc
sudo docker compose run dfir-o365rc
sudo docker-compose run dfir-o365rc
### 使用 PowerShell
您可以安装此模块到 *PowerShell Desktop*(桌面版)和 *PowerShell Core*(核心版)。
请注意,`Connect-ExchangeOnline` cmdlet [需要 Microsoft .NET Framework 4.7.2 或更高版本](https://learn.microsoft.com/en-us/powershell/exchange/exchange-online-powershell-v2?view=exchange-ps#windows)。
要从 PowerShell 库安装该模块:```powershell
Install-Module -Name DFIR-O365RC
您也可以通过克隆DFIR-O365RC仓库来手动安装模块,安装所需的依赖项(查看DFIR-O365RC.psd1),并将DFIR-O365RC目录添加到PowerShell的模块路径之一。
导入模块后,您需要创建一个Entra应用程序,该程序将为您处理日志收集过程。
步骤如下:
创建自签名证书并获取Base64编码的公共部分:
在Linux上,使用PowerShell Core或Docker容器: ```bash openssl req -new -x509 -newkey rsa:2048 -sha256 -days 365 -nodes -out exampleDFIRO365RC.crt -keyout exampleDFIRO365RC.key -batch openssl pkcs12 -inkey exampleDFIRO365RC.key -in exampleDFIRO365RC.crt -export -out exampleDFIRO365RC.pfx # Enter a password for the certificate openssl x509 -in exampleDFIRO365RC.crt -outform DER -out - | base64 | tr -d "\n"
在 Windows 上,使用 PowerShell: ```powershell $certificate = New-SelfSignedCertificate -Subject "CN=exampleDFIRO365RC" -KeySpec KeyExchange -NotBefore (Get-Date) -NotAfter (Get-Date).AddDays(365) $certificatePassword = Read-Host -MaskInput "Please enter a password for the certificate" $certificateSecurePassword = ConvertTo-SecureString -String $certificatePassword -AsPlainText -Force Export-PfxCertificate -Cert $certificate -FilePath exampleDFIRO365RC.pfx -Password $certificateSecurePassword Write-Host ([System.Convert]::ToBase64String($certificate.GetRawCertData()))
2) 使用 DFIR-O365RC 模块中的 `New-Application` cmdlet: ```powershell
$certificateb64="<base64-encoded public part from step 1>"
New-Application -certificateb64 $certificateb64
可选地,如果您希望能够在租户的订阅中收集日志(如果您不打算使用 Get-AzRMActivityLogs,则不需要此操作): ```powershell
New-Application -certificateb64 $certificateb64 -subscriptions
可选地,如果您希望能够收集租户的 Azure DevOps 组织中的日志(这可能需要很长时间,如果您不打算使用 `Get-AzDevOpsActivityLogs`,则不需要这样做): ```powershell
New-Application -certificateb64 $certificateb64 -organizations
To create the application, you will need to log in to Azure several times, using a highly privileged account.
One the application is created, you will get an output similar to: ```powershell Done creating the application with the required permissions Please use the following identifiers: WARNING: AppID: xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx WARNING: Tenant: example.onmicrosoft.com
### 更新应用程序
应用程序创建后,您仍然可以使用模块中的 `Update-Application` cmdlet 更新其凭据和权限:
- 您可以为应用程序添加新证书:
`Update-Application -certificateb64 <base64-encoded public part>`
- 您可以指定新的订阅,以便在其中收集日志:
`Update-Application -subscriptions`
- 您可以指定新的 Azure DevOps 组织,以便在其中收集日志:
`Update-Application -organizations`
- 您可以更新应用程序的权限,这在您拥有旧应用程序且权限自创建以来已更新时特别有用:
`Update-Application -permissions`
### 删除应用程序
完成日志收集后,您可以使用模块中的 `Remove-Application` cmdlet 删除应用程序。
要删除应用程序,您需要使用**高权限**帐户多次登录 Azure。
如果应用程序能够收集订阅或 Azure DevOps 组织的日志,您需要添加 `-organizations` 和/或 `-subscriptions` 开关。
## 权限和许可证要求
⚠️