
Analyzing Office 365 Audit Logs
FreeDetect account compromises through audit log analysis.
Free · Opens the source repo
What Analyzing Office 365 Audit Logs does
This skill is designed for security professionals and SOC analysts who need to investigate potential compromises within Office 365 environments. By leveraging the Microsoft Graph API, it parses the Unified Audit Logs to identify suspicious activities such as the creation of email forwarding rules, changes to mailbox delegation, and unauthorized OAuth app grants. These indicators are critical in recognizing Business Email Compromise (BEC) attacks, which often exploit Office 365 features to facilitate unauthorized access and data exfiltration.
The skill begins by authenticating to Microsoft Graph using a client credentials flow, ensuring secure access to the necessary audit log data. Once authenticated, it queries the Unified Audit Log for specific operations that may indicate malicious behavior, such as Set-Mailbox and New-InboxRule. It systematically enumerates inbox rules across mailboxes to flag any forwarding configurations that direct emails to external addresses, which is a common tactic used by attackers.
In addition to monitoring inbox rules, the skill detects changes in mailbox delegation, which can signify unauthorized access to user accounts. It also identifies OAuth consent grants to suspicious applications, providing insights into potential misuse of permissions. The output is a comprehensive JSON report that lists these findings along with risk scores and a timeline of compromise indicators, enabling analysts to prioritize their response efforts effectively.
This skill is particularly useful in scenarios where organizations need to validate their security monitoring coverage and build detection rules for future threat hunting. It serves as a structured approach to analyzing Office 365 audit logs, making it an essential tool for those tasked with safeguarding enterprise email environments.
When to use it
Use this skill when investigating potential security incidents involving Office 365 or when building detection rules for email compromise.
When not to use it
This skill may not be suitable for environments that do not utilize Office 365 or for general-purpose log analysis outside of email security.
What you can build with it
Investigating a Security Incident
Use this skill to analyze audit logs when a potential compromise is suspected in an Office 365 account.
Building Detection Rules
Leverage the skill to create detection rules for identifying future email compromise attempts.
Validating Security Monitoring Coverage
Employ this skill to ensure that your security monitoring effectively covers potential attack vectors in Office 365.
How to install Analyzing Office 365 Audit Logs
View source1. Install with the skills CLI
npx skills add mukul975/anthropic-cybersecurity-skills/analyzing-office365-audit-logs-for-compromise --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by mukul975Analyzing Office 365 Audit Logs for Compromise
Overview
Business Email Compromise (BEC) attacks often leave traces in Office 365 audit logs: suspicious inbox rule creation, email forwarding to external addresses, mailbox delegation changes, and unauthorized OAuth application consent grants. This skill uses the Microsoft Graph API to query the Unified Audit Log, enumerate inbox rules across mailboxes, detect forwarding configurations, and identify compromised account indicators.
When to Use
- When investigating security incidents that require analyzing office365 audit logs for compromise
- When building detection rules or threat hunting queries for this domain
- When SOC analysts need structured procedures for this analysis type
- When validating security monitoring coverage for related attack techniques
Prerequisites
- Azure AD app registration with
AuditLog.Read.All,MailboxSettings.Read,Mail.Read(application permissions) - Python 3.9+ with
msal,requests - Client secret or certificate for authentication
- Global Reader or Security Reader role
Steps
- Authenticate to Microsoft Graph using MSAL client credentials flow
- Query Unified Audit Log for suspicious operations (Set-Mailbox, New-InboxRule)
- Enumerate inbox rules across mailboxes and flag forwarding rules
- Detect mailbox delegation changes (Add-MailboxPermission)
- Identify OAuth consent grants to suspicious applications
- Check for suspicious sign-in patterns from audit logs
- Generate compromise indicator report with timeline
Expected Output
- JSON report listing forwarding rules, delegation changes, OAuth grants, and suspicious audit events with risk scores
- Timeline of compromise indicators with affected mailboxes
Frequently asked questions about Analyzing Office 365 Audit Logs
Similar skills
Asset Criticality Scoring for Vulns
Prioritize vulnerabilities based on asset criticality.
Performing Alert Triage with Elastic SIEM
Streamline alert triage processes in Elastic Security.
Active Directory Vulnerability Assessment
Secure your Active Directory with comprehensive assessments.
Active Directory Investigation
Streamline your Active Directory compromise investigations.
Parsing Artifacts with Eric Zimmerman Tools
Efficiently parse Windows forensic artifacts for analysis.
Operationalizing MISP Threat Feeds
Enhance threat detection with curated MISP feeds.
