Mail Protocols
Adversaries may communicate using application layer protocols associated with electronic mail delivery to avoid detection/network filtering by blending in with existing traffic. Commands to the remote system, and often the results of those commands, will be embedded within the protocol traffic between the client and server. Protocols such as SMTP/S, POP3/S, and IMAP that carry electronic mail may be very common in environments. Packets produced from these protocols may have many fields and headers in which data can be concealed. Data could also be concealed within the email messages themselves. An adversary may abuse these protocols to communicate with systems under their control within a victim network while also mimicking normal, expected traffic.
let TimeWindow = 24h;
// Detect non-mail-client processes connecting to mail protocol ports
DeviceNetworkEvents
| where Timestamp > ago(TimeWindow)
| where RemotePort in (25, 465, 587, 110, 995, 143, 993)
| where ActionType == "ConnectionSuccess"
| where InitiatingProcessFileName !in~ (
"outlook.exe", "thunderbird.exe", "OUTLOOK.EXE",
"MailClient.exe", "eM Client.exe",
"msedge.exe", "chrome.exe"
)
| extend Protocol = case(
RemotePort in (25, 465, 587), "SMTP",
RemotePort in (110, 995), "POP3",
RemotePort in (143, 993), "IMAP",
"Unknown")
| summarize
ConnectionCount = count(),
UniqueRemoteIPs = dcount(RemoteIP),
BytesSent = sum(SentBytes),
FirstSeen = min(Timestamp),
LastSeen = max(Timestamp)
by DeviceName, InitiatingProcessFileName, RemoteIP, RemotePort, Protocol, AccountName
| where ConnectionCount > 2
| project LastSeen, DeviceName, AccountName, InitiatingProcessFileName, RemoteIP, Protocol, RemotePort, ConnectionCount, UniqueRemoteIPs, BytesSent
| sort by ConnectionCount desc Data Sources
Required Tables
False Positives
- Scripted email sending tools used by IT for automated notifications (e.g., Python scripts using smtplib, PowerShell Send-MailMessage)
- Application servers with built-in email notification capabilities (monitoring alerts, report delivery)
- Email security gateways and spam filters that relay mail through non-standard processes
- Backup software that sends completion notifications via SMTP
References (6)
- https://attack.mitre.org/techniques/T1071/003/
- https://web.archive.org/web/20151022204649/https://www.fireeye.com/content/dam/fireeye-www/global/en/current-threats/pdfs/rpt-apt28.pdf
- https://www.welivesecurity.com/wp-content/uploads/2020/05/ESET_Turla_ComRAT.pdf
- https://www.welivesecurity.com/2019/05/29/turla-powershell-usage/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1071.003/T1071.003.md
- https://pwc.github.io/issues/2023/yellow-liderc.html
Unlock Pro Content
Get the full detection package for T1071.003 including response playbook, investigation guide, and atomic red team tests.