
Office 365 및 Azure 로그 수집을 위한 PowerShell 모듈

DFIR-O365RC는 SSTIC 2021(정보통신기술 보안 심포지엄)에서 발표되었습니다. 프랑스어로 된 발표 슬라이드와 녹화 영상은 여기에서 확인할 수 있습니다.
⚠️ 2024년 3월 31일, Microsoft는 DFIR-O365RC에서 사용하던 인증 방법을 더 이상 사용하지 않기로 했습니다. 이에 따라 2024년 8월 버전 2.0.0이 출시되었으며, 인증 방식과 코드 전반의 **주요 변경 사항(breaking changes)**이 포함되었습니다. ⚠️
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)는 사서함 감사 로그(Mailbox Audit Log)도 가져옵니다. 단, Search-MailboxAuditLog cmdlet은 더 이상 사용되지 않습니다(deprecated).
DFIR-O365RC를 사용하여 다른 Azure 리소스를 조사하는 경우:
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
애플리케이션을 만들려면 권한이 높은 계정을 사용하여 Azure에 여러 번 로그인해야 합니다.
애플리케이션이 생성되면 다음과 유사한 출력이 나타납니다: ```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
### 애플리케이션 업데이트