Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit a2b0b20

Browse files
authored
Merge pull request #191 from martyav/mailsniper
added MailSniper query
2 parents edc03cf + 4b7286a commit a2b0b20

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Detect activity by the penetration tool, MailSniper
2+
3+
This query was originally published in the threat analytics report, *MailSniper Exchange attack tool*.
4+
5+
[MaailSniper](https://github.com/dafthack/MailSniper) is a tool that targets Microsoft Exchange Server. The core function is to connect to Exchange Server and search through emails. In support of this, it can perform reconnaissance, collection, exfiltration, and credential theft. MailSniper is used both by red teams running penetration tests, and by malicious actors.
6+
7+
Microsoft Defender Security Center may record the following alerts during and after an attack:
8+
9+
* Global mail search on Exchange using MailSniper
10+
* Exchange mailbox or mail folder search using MailSniper
11+
* Enumeration of Active Directory usernames using MailSniper
12+
* Enumeration of the Exchange GAL using MailSniper
13+
* Access to Exchange inboxes using MailSniper
14+
* Password spraying using MailSniper
15+
* Enumeration of domains and user accounts using MailSniper
16+
17+
The following query detects activity commonly associated with attacks run with MailSniper.
18+
19+
## Query
20+
21+
```Kusto
22+
let dateRange = ago(10d);
23+
//
24+
let whoamiProcess = DeviceProcessEvents
25+
| where ProcessCreationTime >= dateRange
26+
| where FileName =~ 'whoami.exe' and InitiatingProcessParentFileName =~ 'powershell.exe'
27+
| project DeviceId, whoamiTime = ProcessCreationTime, whoamiProcessName = FileName,
28+
whoamiParentName = InitiatingProcessParentFileName, whoamiParentPID = InitiatingProcessParentId;
29+
//
30+
let netProcess = DeviceProcessEvents
31+
| where ProcessCreationTime >= dateRange
32+
| where FileName =~ 'net.exe' and InitiatingProcessParentFileName =~ 'powershell.exe'
33+
| project DeviceId, netTime = ProcessCreationTime, ProcessCreationTime = FileName,
34+
netParentName = InitiatingProcessParentFileName, netParentPID = InitiatingProcessParentId;
35+
//
36+
let mailServerEvents = DeviceNetworkEvents
37+
| where Timestamp >= dateRange
38+
| where InitiatingProcessFileName =~ 'powershell.exe'
39+
| where RemoteUrl contains 'onmicrosoft.com'
40+
or RemoteUrl contains 'outlook.com'
41+
| project DeviceId, mailTime = Timestamp, mailProcessName = InitiatingProcessFileName,
42+
mailPID = InitiatingProcessId;
43+
//
44+
mailServerEvents
45+
| join netProcess on DeviceId
46+
| where netParentPID == mailPID and netParentName == mailProcessName
47+
| join whoamiProcess on DeviceId
48+
| where whoamiParentPID == mailPID and whoamiParentName == mailProcessName
49+
| where netTime < mailTime + 4h and netTime > mailTime - 4h
50+
| where whoamiTime < mailTime + 4h and whoamiTime > mailTime - 4h
51+
| project DeviceId, EstimatedIncidentTime = mailTime, ProcessName = mailProcessName,
52+
ProcessID = mailPID
53+
```
54+
55+
## Category
56+
57+
This query can be used to detect the following attack techniques and tactics ([see MITRE ATT&CK framework](https://attack.mitre.org/)) or security configuration states.
58+
59+
| Technique, tactic, or state | Covered? (v=yes) | Notes |
60+
|------------------------|----------|-------|
61+
| Initial access | v | |
62+
| Execution | | |
63+
| Persistence | | |
64+
| Privilege escalation | | |
65+
| Defense evasion | | |
66+
| Credential Access | v | |
67+
| Discovery | | |
68+
| Lateral movement | | |
69+
| Collection | v | |
70+
| Command and control | | |
71+
| Exfiltration | v | |
72+
| Impact | | |
73+
| Vulnerability | | |
74+
| Misconfiguration | | |
75+
| Malware, component | | |
76+
77+
## Contributor info
78+
79+
**Contributor:** Microsoft Threat Protection team

0 commit comments

Comments
 (0)