Discovery: normal commands, hard detections
Unit 2 of 5 in Adversary emulation and purple teaming.
You will be able to write and measure detections for Discovery techniques on a VM you own, say what each rule cannot see, and correlate several weak signals into one alert.
Lesson
Discovery is made of ordinary commands
MITRE describes the Discovery tactic as techniques an adversary may use to gain knowledge about the system and internal network, to observe the environment and orient before deciding how to act, and notes that native operating system tools are often used. The techniques in this unit show it. System Owner/User Discovery (T1033) is identifying the primary or logged-in user. System Information Discovery (T1082) is finding details of the operating system and hardware. Account Discovery of local accounts (T1087.001) is listing the accounts on a system. System Network Configuration Discovery (T1016) is looking at addresses and settings, and System Network Connections Discovery (T1049) is listing connections.
The problem for a detection author follows directly: every one of those is something an administrator or a script runs every day. A rule that fires on the command alone will fire constantly, and one that fires constantly gets switched off.
Choose what the rule watches
The labs write several versions of a rule and compare them: a rule on the program that runs, a rule on reads of the file that holds the information (such as the account file), and a rule that uses the login user to remove background noise. The Linux audit documentation helps here. It describes the auid field as the original ID the user logged in with, sometimes called the login uid, so a rule can tell what a person did even when the command ran under another identity, and it describes keys, labels you put on a rule so you can find its events later.
The same man page says that the older watch form of rule (the -w option) is deprecated because of poor performance, and that watches should be converted to the syscall form. If you use watches in a lab to keep a rule short, that is a thing to say in your report: it is a teaching convenience, and the production form is different.
Measure noise as a number
The way out of the noise problem is measurement. The labs have you use the machine normally for a few minutes first, then run the documented test, then count: how many events did each candidate rule produce on normal use, and did it catch the test? A rule on a very common program is too noisy to keep. A narrow rule on the exact executables you care about is quieter but easy to step around. A file-read rule is quieter than a program rule but only sees what reads that file.
Writing the decision down is part of the job: keep, tune or drop, and the number that supports it. ATT&CK's own detection strategies for these techniques, for example behavioural detection of user discovery through local and remote enumeration, describe the same idea: look at the combination, not the single command.
What your rules cannot see
Every rule has blind spots, and a purple report lists them. A rule on program names does not see a program you did not list, or the same information read another way. The network discovery lab starts with an inventory of which tools exist on the VM, writes one rule per tool that exists, runs the tests and then writes down what the rules could not see. The point is that coverage needs more than one kind of rule: program, file, and, as the next units show, a before-and-after snapshot.
Correlate weak signals
One whoami is nothing. Several different discovery commands from one login within a few minutes is a pattern. The last lab of this series reloads the four detections together, runs every test in one sitting, writes a short script that groups events by login user and time window, and tests it twice, once against the full run and once against quiet normal use. A good correlation rule alerts on the first and stays silent on the second, and the report records both counts.
Key points
- Discovery uses normal tools, so single-command rules are noisy; measure and decide with numbers.
- Watch the program, the file that holds the information, or the original login user; each sees different things.
- The audit man page marks watch rules as deprecated; say so when a lab uses them for brevity.
- List blind spots; correlate weak signals by user and time window and test against normal use.
Sources
- MITRE ATT&CK: Discovery (TA0007)
- MITRE ATT&CK: System Owner/User Discovery (T1033)
- MITRE ATT&CK: System Information Discovery (T1082)
- MITRE ATT&CK: Account Discovery, Local Account (T1087.001)
- MITRE ATT&CK: System Network Configuration Discovery (T1016)
- MITRE ATT&CK: System Network Connections Discovery (T1049)
- Linux man page: auditctl(8)
Practice in the labs
Four techniques, one lab each, then a correlation and a purple report. Every test is documented and read-only, and every lab ends with the project's cleanup.
- Catch ATT&CK T1033 System Owner/User Discovery with an auditd rule (Purple Discovery 2 of 6): You read the atomic test, load a broad rule, narrow it to the executables that matter and validate by running the test again.
- Catch ATT&CK T1082 System Information Discovery and measure the noise (Purple Discovery 3 of 6): You compare three candidate rules by what they caught and what they cost, and record noise as a number.
- Catch ATT&CK T1087.001 local account discovery and watch who reads the account file (Purple Discovery 4 of 6): You write a file-read rule, use the login user to remove background noise and see which program read the file.
- Catch ATT&CK T1016 and T1049 network discovery, and find what your rules cannot see (Purple Discovery 5 of 6): You inventory the tools on your VM, write a rule per tool and write down the blind spots of a program-name rule.
- Correlate discovery commands into one alert and write the purple report (Purple Discovery 6 of 6): You run every discovery test in one sitting, correlate by login user and time window, test against quiet use and write the purple report.
Also try, in the simulators
- Find one workstation sweeping others on the file-sharing port (Detection Lab task): You write the rule that finds one workstation sweeping others on a file-sharing port, network discovery seen from the defender's side.
Knowledge check
- Why is a detection that fires on every use of a discovery command usually a bad detection? Answer: Administrators and scripts run those commands all the time, so it produces constant noise and gets switched off. Discovery uses native tools, so context (who, where, how many) matters more than the command alone.
- What is the auid field in a Linux audit rule or event? Answer: The original ID the user logged in with, so you can see who did it even if the command ran as another user. The auditctl man page describes auid as the original login ID, sometimes called loginuid.
- You keep a short -w watch rule in a lab. What should your report say about it? Answer: That the man page marks the watch form deprecated for performance and that production rules use the syscall form. The man page says watches are deprecated due to poor performance and should be converted to the syscall form.
- A correlation rule alerts on the full test run and also on a quiet baseline. What should you do? Answer: Tune it: a rule that alerts on normal use will be ignored, so adjust the window, count or user until the baseline is silent. Validation includes testing against normal use and recording both counts in the report.
Back to the syllabus or see all classes.
Related
- Adversary emulation and purple teaming
- Catch ATT&CK T1033 System Owner/User Discovery with an auditd rule (Purple Discovery 2 of 6)
- Catch ATT&CK T1082 System Information Discovery and measure the noise (Purple Discovery 3 of 6)
- Catch ATT&CK T1087.001 local account discovery and watch who reads the account file (Purple Discovery 4 of 6)
- Catch ATT&CK T1016 and T1049 network discovery, and find what your rules cannot see (Purple Discovery 5 of 6)
- Correlate discovery commands into one alert and write the purple report (Purple Discovery 6 of 6)
- All classes
- Free cyber labs