Encrypting Files with WinRar or 7z

Identifies use of WinRar or 7z to create an encrypted files. Adversaries will often compress and encrypt data in preparation for exfiltration.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2020/12/04"
  3integration = ["endpoint", "windows"]
  4maturity = "production"
  5min_stack_comments = "New fields added: required_fields, related_integrations, setup"
  6min_stack_version = "8.3.0"
  7updated_date = "2024/03/28"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Identifies use of WinRar or 7z to create an encrypted files. Adversaries will often compress and encrypt data in
 13preparation for exfiltration.
 14"""
 15from = "now-9m"
 16index = ["logs-endpoint.events.process-*", "winlogbeat-*", "logs-windows.*", "endgame-*"]
 17language = "eql"
 18license = "Elastic License v2"
 19name = "Encrypting Files with WinRar or 7z"
 20note = """## Triage and analysis
 21
 22### Investigating Encrypting Files with WinRar or 7z
 23
 24Attackers may compress and/or encrypt data collected before exfiltration. Compressing the data can help obfuscate the collected data and minimize the amount of data sent over the network. Encryption can be used to hide information that is being exfiltrated from detection or make exfiltration less apparent upon inspection by a defender.
 25
 26These steps are usually done in preparation for exfiltration, meaning the attack may be in its final stages.
 27
 28#### Possible investigation steps
 29
 30- Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
 31- Retrieve the encrypted file.
 32- Investigate other alerts associated with the user/host during the past 48 hours.
 33- Check if the password used in the encryption was included in the command line.
 34- Decrypt the `.rar`/`.zip` and check if the information is sensitive.
 35- If the password is not available, and the format is `.zip` or the option used in WinRAR is not the `-hp`, list the file names included in the encrypted file.
 36- Investigate if the file was transferred to an attacker-controlled server.
 37
 38### False positive analysis
 39
 40- Backup software can use these utilities. Check the `process.parent.executable` and `process.parent.command_line` fields to determine what triggered the encryption.
 41
 42### Response and remediation
 43
 44- Initiate the incident response process based on the outcome of the triage.
 45- Prioritize cases that involve personally identifiable information (PII) or other classified data.
 46- Isolate the involved hosts to prevent further post-compromise behavior.
 47- 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.
 48- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 49- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 50- 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).
 51"""
 52references = ["https://www.welivesecurity.com/2020/12/02/turla-crutch-keeping-back-door-open/"]
 53risk_score = 47
 54rule_id = "45d273fb-1dca-457d-9855-bcb302180c21"
 55setup = """## Setup
 56
 57If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 58events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 59Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 60`event.ingested` to @timestamp.
 61For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 62"""
 63severity = "medium"
 64tags = ["Domain: Endpoint", "OS: Windows", "Use Case: Threat Detection", "Tactic: Collection", "Resources: Investigation Guide", "Data Source: Elastic Endgame", "Data Source: Elastic Defend"]
 65timestamp_override = "event.ingested"
 66type = "eql"
 67
 68query = '''
 69process where host.os.type == "windows" and event.type == "start" and
 70(
 71  (
 72    (
 73      process.name:"rar.exe" or ?process.code_signature.subject_name == "win.rar GmbH" or
 74      ?process.pe.original_file_name == "Command line RAR"
 75    ) and
 76    process.args == "a" and process.args : ("-hp*", "-p*", "/hp*", "/p*")
 77  ) or
 78  (
 79    ?process.pe.original_file_name in ("7z.exe", "7za.exe") and
 80    process.args == "a" and process.args : "-p*"
 81  )
 82) and
 83  not process.parent.executable : (
 84        "C:\\Program Files\\*.exe",
 85        "C:\\Program Files (x86)\\*.exe",
 86        "?:\\ManageEngine\\*\\jre\\bin\\java.exe",
 87        "?:\\Nox\\bin\\Nox.exe"
 88      )
 89'''
 90
 91
 92[[rule.threat]]
 93framework = "MITRE ATT&CK"
 94[[rule.threat.technique]]
 95id = "T1560"
 96name = "Archive Collected Data"
 97reference = "https://attack.mitre.org/techniques/T1560/"
 98[[rule.threat.technique.subtechnique]]
 99id = "T1560.001"
100name = "Archive via Utility"
101reference = "https://attack.mitre.org/techniques/T1560/001/"
102
103[[rule.threat.technique]]
104id = "T1005"
105name = "Data from Local System"
106reference = "https://attack.mitre.org/techniques/T1005/"
107
108
109
110[rule.threat.tactic]
111id = "TA0009"
112name = "Collection"
113reference = "https://attack.mitre.org/tactics/TA0009/"

Triage and analysis

Investigating Encrypting Files with WinRar or 7z

Attackers may compress and/or encrypt data collected before exfiltration. Compressing the data can help obfuscate the collected data and minimize the amount of data sent over the network. Encryption can be used to hide information that is being exfiltrated from detection or make exfiltration less apparent upon inspection by a defender.

These steps are usually done in preparation for exfiltration, meaning the attack may be in its final stages.

Possible investigation steps

  • Investigate the script execution chain (parent process tree) for unknown processes. Examine their executable files for prevalence, whether they are located in expected locations, and if they are signed with valid digital signatures.
  • Retrieve the encrypted file.
  • Investigate other alerts associated with the user/host during the past 48 hours.
  • Check if the password used in the encryption was included in the command line.
  • Decrypt the .rar/.zip and check if the information is sensitive.
  • If the password is not available, and the format is .zip or the option used in WinRAR is not the -hp, list the file names included in the encrypted file.
  • Investigate if the file was transferred to an attacker-controlled server.

False positive analysis

  • Backup software can use these utilities. Check the process.parent.executable and process.parent.command_line fields to determine what triggered the encryption.

Response and remediation

  • Initiate the incident response process based on the outcome of the triage.
  • Prioritize cases that involve personally identifiable information (PII) or other classified data.
  • 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 through 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).

References

Related rules

to-top