Awesome
<h3>MIA</h3> MIA makes it possible to extract Sessions, MessageID(s) and find emails belonging to the MessageID(s). This script utilizes the MailItemsAccessed features from the Office 365 Audit Log. The goal of this script is to help investigators answer the question: <b>What email data was accessed by the threat actor?</b><br><br>The script supports three actions, you can configure the action with the -Action flag.
- Sessions
- MessageID
You have to be assigned the View-Only Audit Logs or Audit Logs role in Exchange Online to search the Office 365 audit log. By default, these roles are assigned to the Compliance Management and Organization Management role groups on the Permissions page in the Exchange admin center. To give a user the ability to search the Office 365 audit log with the minimum level of privileges, you can create a custom role group in Exchange Online, add the View-Only Audit Logs or Audit Logs role, and then add the user as a member of the new role group. For more information, see Manage role groups in Exchange Online. https://docs.microsoft.com/en-us/office365/securitycompliance/search-the-audit-log-in-security-and-compliance)<br>
<h3>How to use the script</h3> 1. Download MIA.ps1<br> 2. Run the script with Powershell 3. ./MIA -Actions [Sessions|MessageID|Emails] <h3>Frequently Asked Questions</h3> <b>I logged into a mailbox with auditing turned on but I don't see my events?</b><br> It can take up to 24 hours before an event is stored in the UAL. <br> <br> <b>What about timestamps?</b><br> The audit logs are in UTC, and they will be exported as such<br> <br><b>What is the retention period?</b><br> Office 365 E3 - Audit records are retained for 90 days. That means you can search the audit log for activities that were performed within the last 90 days.
Office 365 E5 - Audit records are retained for 365 days (one year). That means you can search the audit log for activities that were performed within the last year. Retaining audit records for one year is also available for users that are assigned an E3/Exchange Online Plan 1 license and have an Office 365 Advanced Compliance add-on license. <br>
<h3>Known errors</h3> <b>Import-PSSession : No command proxies have been created, because all of the requested remote....</b><br> This error is caused when the script did not close correctly and an active session will be running in the background. The script tries to import/load all modules again, but this is not necessary since it is already loaded. This error message has no impact on the script and will be gone when the open session gets closed. This can be done by restarting the PowerShell Windows or entering the following command: Get-PSSession | Remove-PSSession <br><b>Audit logging is enabled in the Office 365 environment but no logs are getting displayed?</b><br> The user must be assigned an Office 365 E5 license. Alternatively, users with an Office 365 E1 or E3 license can be assigned an Advanced eDiscovery standalone license. Administrators and compliance officers who are assigned to cases and use Advanced eDiscovery to analyze data don't need an E5 license.<br>
<b>Audit log search argument start date should be after</b><br> The start date should be earlier then the end date.
<b>New-PSSession: [outlook.office365.com] Connecting to remove server outlook.office365.com failed with the following error message: Access is denied.</b><br> The password/username combination are incorrect or the user has not enough privileges to extract the audit logging.<br> <br> <br> Custom script was developed by Joey Rentenaar and Korstiaan Stam from PwC Netherlands Incident Response team. <br>