Detect Mail Protocols in IBM QRadar
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.
MITRE ATT&CK
- Tactic
- Command and Control
- Technique
- T1071 Application Layer Protocol
- Sub-technique
- T1071.003 Mail Protocols
- Canonical reference
- https://attack.mitre.org/techniques/T1071/003/
QRadar Detection Query
SELECT
sourceip,
destinationip,
destinationport,
username,
"Process Name",
COUNT(*) AS ConnectionCount,
SUM(LONG("Bytes Sent")) AS TotalBytesSent,
MIN(starttime) AS FirstSeen,
MAX(starttime) AS LastSeen,
CASE
WHEN destinationport IN (25, 465, 587) THEN 'SMTP'
WHEN destinationport IN (110, 995) THEN 'POP3'
WHEN destinationport IN (143, 993) THEN 'IMAP'
ELSE 'Unknown'
END AS MailProtocol
FROM events
WHERE
starttime > NOW() - 86400000
AND destinationport IN (25, 465, 587, 110, 995, 143, 993)
AND "Event Direction" = 'L2R'
AND LOWER("Process Name") NOT IN (
'outlook.exe', 'thunderbird.exe', 'mailclient.exe',
'em client.exe', 'msedge.exe', 'chrome.exe', 'firefox.exe'
)
GROUP BY
sourceip, destinationip, destinationport,
username, "Process Name", MailProtocol
HAVING ConnectionCount > 2
ORDER BY ConnectionCount DESC IBM QRadar AQL query detecting outbound connections to mail protocol ports from non-standard processes. Filters L2R (local-to-remote) events on mail ports from the past 24 hours, excludes known legitimate mail clients, classifies by protocol, and aggregates by source/destination/process to surface repeated suspicious connections indicative of T1071.003 C2 activity.
Data Sources
Required Tables
False Positives & Tuning
- Automated scripts and scheduled tasks using SMTP for system alerting, such as cron jobs invoking sendmail or Python scripts using smtplib, where the parent process name (bash, python3.exe) does not match known mail clients
- Database server processes configured to send SMTP alerts directly (e.g., Oracle UTL_MAIL running under oracle.exe, SQL Server Database Mail running under sqlservr.exe)
- Mail archiving or eDiscovery solutions connecting via IMAP/POP3 using proprietary service process names not included in the exclusion filter
Other platforms for T1071.003
Testing Methodology
Validate this detection against 3 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 1SMTP C2 Exfiltration via PowerShell
Expected signal: Sysmon Event ID 1: PowerShell process creation with Send-MailMessage in command line. Sysmon Event ID 3: Network connection attempt to 127.0.0.1:25. PowerShell ScriptBlock Log Event ID 4104 with SMTP command details.
- Test 2POP3 Command Retrieval Simulation
Expected signal: Sysmon for Linux Event ID 3: Network connection from nc to 127.0.0.1:110. Process creation event for nc with POP3 commands piped via stdin.
- Test 3IMAP C2 Channel Simulation
Expected signal: Sysmon for Linux Event ID 3: Network connection from curl to 127.0.0.1:143. Process creation event for curl with imap:// URL and credentials in command line.
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.