Security Software Discovery via Grep

Identifies the use of the grep command to discover known third-party macOS and Linux security tools, such as Antivirus or Host Firewall details.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/12/20"
  3integration = ["endpoint"]
  4maturity = "production"
  5updated_date = "2024/05/21"
  6
  7[rule]
  8author = ["Elastic"]
  9description = """
 10Identifies the use of the grep command to discover known third-party macOS and Linux security tools, such as Antivirus
 11or Host Firewall details.
 12"""
 13false_positives = ["Endpoint Security installers, updaters and post installation verification scripts."]
 14from = "now-9m"
 15index = ["logs-endpoint.events.*", "auditbeat-*"]
 16language = "eql"
 17license = "Elastic License v2"
 18name = "Security Software Discovery via Grep"
 19note = """## Triage and analysis
 20
 21### Investigating Security Software Discovery via Grep
 22
 23After successfully compromising an environment, attackers may try to gain situational awareness to plan their next steps. This can happen by running commands to enumerate network resources, users, connections, files, and installed security software.
 24
 25This rule looks for the execution of the `grep` utility with arguments compatible to the enumeration of the security software installed on the host. Attackers can use this information to decide whether or not to infect a system, disable protections, use bypasses, etc.
 26
 27#### Possible investigation steps
 28
 29- Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
 30- Investigate other alerts associated with the user/host during the past 48 hours.
 31- Investigate any abnormal account behavior, such as command executions, file creations or modifications, and network connections.
 32- Investigate any abnormal behavior by the subject process such as network connections, file modifications, and any spawned child processes.
 33- Inspect the host for suspicious or abnormal behavior in the alert timeframe.
 34- Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.
 35
 36### False positive analysis
 37
 38- Discovery activities are not inherently malicious if they occur in isolation. As long as the analyst did not identify suspicious activity related to the user or host, such alerts can be dismissed.
 39
 40### Response and remediation
 41
 42- Initiate the incident response process based on the outcome of the triage.
 43- Isolate the involved hosts to prevent further post-compromise behavior.
 44- Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
 45- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 46- Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
 47- Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).
 48"""
 49risk_score = 47
 50rule_id = "870aecc0-cea4-4110-af3f-e02e9b373655"
 51setup = """## Setup
 52
 53If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 54events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 55Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 56`event.ingested` to @timestamp.
 57For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 58"""
 59severity = "medium"
 60tags = [
 61    "Domain: Endpoint",
 62    "OS: macOS",
 63    "OS: Linux",
 64    "Use Case: Threat Detection",
 65    "Tactic: Discovery",
 66    "Resources: Investigation Guide",
 67    "Data Source: Elastic Defend",
 68]
 69timestamp_override = "event.ingested"
 70type = "eql"
 71
 72query = '''
 73process where event.type == "start" and
 74process.name : "grep" and user.id != "0" and
 75 not process.parent.executable : ("/Library/Application Support/*", "/opt/McAfee/agent/scripts/ma") and
 76   process.args :
 77         ("Little Snitch*",
 78          "Avast*",
 79          "Avira*",
 80          "ESET*",
 81          "BlockBlock*",
 82          "360Sec*",
 83          "LuLu*",
 84          "KnockKnock*",
 85          "kav",
 86          "KIS",
 87          "RTProtectionDaemon*",
 88          "Malware*",
 89          "VShieldScanner*",
 90          "WebProtection*",
 91          "webinspectord*",
 92          "McAfee*",
 93          "isecespd*",
 94          "macmnsvc*",
 95          "masvc*",
 96          "kesl*",
 97          "avscan*",
 98          "guard*",
 99          "rtvscand*",
100          "symcfgd*",
101          "scmdaemon*",
102          "symantec*",
103          "sophos*",
104          "osquery*",
105          "elastic-endpoint*"
106          ) and
107   not (
108     (process.args : "Avast" and process.args : "Passwords") or
109     (process.parent.args : "/opt/McAfee/agent/scripts/ma" and process.parent.args : "checkhealth") or
110     (process.command_line : (
111       "grep ESET Command-line scanner, version %s -A2",
112       "grep -i McAfee Web Gateway Core version:",
113       "grep --color=auto ESET Command-line scanner, version %s -A2"
114       )
115     ) or
116     (process.parent.command_line : (
117       """sh -c printf "command_start_%s"*; perl -pe 's/[^ -~]/\n/g' < /opt/eset/esets/sbin/esets_scan | grep 'ESET Command-line scanner, version %s' -A2 | tail -1; printf "command_done_%s*""",
118       """bash -c perl -pe 's/[^ -~]/\n/g' < /opt/eset/esets/sbin/esets_scan | grep 'ESET Command-line scanner, version %s' -A2 | tail -1"""
119       )
120     )
121    )
122'''
123
124
125[[rule.threat]]
126framework = "MITRE ATT&CK"
127[[rule.threat.technique]]
128id = "T1518"
129name = "Software Discovery"
130reference = "https://attack.mitre.org/techniques/T1518/"
131[[rule.threat.technique.subtechnique]]
132id = "T1518.001"
133name = "Security Software Discovery"
134reference = "https://attack.mitre.org/techniques/T1518/001/"
135
136
137
138[rule.threat.tactic]
139id = "TA0007"
140name = "Discovery"
141reference = "https://attack.mitre.org/tactics/TA0007/"

Triage and analysis

Investigating Security Software Discovery via Grep

After successfully compromising an environment, attackers may try to gain situational awareness to plan their next steps. This can happen by running commands to enumerate network resources, users, connections, files, and installed security software.

This rule looks for the execution of the grep utility with arguments compatible to the enumeration of the security software installed on the host. Attackers can use this information to decide whether or not to infect a system, disable protections, use bypasses, etc.

Possible investigation steps

  • Investigate the process execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence and whether they are located in expected locations.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Investigate any abnormal account behavior, such as command executions, file creations or modifications, and network connections.
  • Investigate any abnormal behavior by the subject process such as network connections, file modifications, and any spawned child processes.
  • Inspect the host for suspicious or abnormal behavior in the alert timeframe.
  • Validate the activity is not related to planned patches, updates, network administrator activity, or legitimate software installations.

False positive analysis

  • Discovery activities are not inherently malicious if they occur in isolation. As long as the analyst did not identify suspicious activity related to the user or host, such alerts can be dismissed.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Isolate the involved hosts to prevent further post-compromise behavior.
  • Investigate credential exposure on systems compromised or used by the attacker to ensure all compromised accounts are identified. Reset passwords for these accounts and other potentially compromised credentials, such as email, business systems, and web services.
  • Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
  • Determine the initial vector abused by the attacker and take action to prevent reinfection via the same vector.
  • Using the incident response data, update logging and audit policies to improve the mean time to detect (MTTD) and the mean time to respond (MTTR).

Related rules

to-top