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", "m365_defender", "sentinel_one_cloud_funnel"]
  4maturity = "production"
  5updated_date = "2024/11/02"
  6min_stack_version = "8.14.0"
  7min_stack_comments = "Breaking change at 8.14.0 for the Windows Integration."
  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 = [
 17  "logs-endpoint.events.process-*",
 18  "winlogbeat-*",
 19  "logs-windows.sysmon_operational-*",
 20  "endgame-*",
 21  "logs-m365_defender.event-*",
 22  "logs-sentinel_one_cloud_funnel.*"
 23]
 24language = "eql"
 25license = "Elastic License v2"
 26name = "Encrypting Files with WinRar or 7z"
 27note = """## Triage and analysis
 28
 29### Investigating Encrypting Files with WinRar or 7z
 30
 31Attackers 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.
 32
 33These steps are usually done in preparation for exfiltration, meaning the attack may be in its final stages.
 34
 35#### Possible investigation steps
 36
 37- 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.
 38- Retrieve the encrypted file.
 39- Investigate other alerts associated with the user/host during the past 48 hours.
 40- Check if the password used in the encryption was included in the command line.
 41- Decrypt the `.rar`/`.zip` and check if the information is sensitive.
 42- 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.
 43- Investigate if the file was transferred to an attacker-controlled server.
 44
 45### False positive analysis
 46
 47- Backup software can use these utilities. Check the `process.parent.executable` and `process.parent.command_line` fields to determine what triggered the encryption.
 48
 49### Response and remediation
 50
 51- Initiate the incident response process based on the outcome of the triage.
 52- Prioritize cases that involve personally identifiable information (PII) or other classified data.
 53- Isolate the involved hosts to prevent further post-compromise behavior.
 54- 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.
 55- Run a full antimalware scan. This may reveal additional artifacts left in the system, persistence mechanisms, and malware components.
 56- Determine the initial vector abused by the attacker and take action to prevent reinfection through the same vector.
 57- 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).
 58"""
 59references = [
 60    "https://www.welivesecurity.com/2020/12/02/turla-crutch-keeping-back-door-open/",
 61    "https://www.elastic.co/security-labs/siestagraph-new-implant-uncovered-in-asean-member-foreign-ministry",
 62]
 63risk_score = 47
 64rule_id = "45d273fb-1dca-457d-9855-bcb302180c21"
 65setup = """## Setup
 66
 67If enabling an EQL rule on a non-elastic-agent index (such as beats) for versions <8.2,
 68events will not define `event.ingested` and default fallback for EQL rules was not added until version 8.2.
 69Hence for this rule to work effectively, users will need to add a custom ingest pipeline to populate
 70`event.ingested` to @timestamp.
 71For more details on adding a custom ingest pipeline refer - https://www.elastic.co/guide/en/fleet/current/data-streams-pipeline-tutorial.html
 72"""
 73severity = "medium"
 74tags = [
 75    "Domain: Endpoint",
 76    "OS: Windows",
 77    "Use Case: Threat Detection",
 78    "Tactic: Collection",
 79    "Resources: Investigation Guide",
 80    "Data Source: Elastic Endgame",
 81    "Data Source: Elastic Defend",
 82    "Data Source: Sysmon",
 83    "Data Source: Microsoft Defender for Endpoint",
 84    "Data Source: SentinelOne"
 85]
 86timestamp_override = "event.ingested"
 87type = "eql"
 88
 89query = '''
 90process where host.os.type == "windows" and event.type == "start" and
 91(
 92  (
 93    (
 94      process.name:"rar.exe" or ?process.code_signature.subject_name == "win.rar GmbH" or
 95      ?process.pe.original_file_name == "Command line RAR"
 96    ) and
 97    process.args == "a" and process.args : ("-hp*", "-p*", "/hp*", "/p*")
 98  ) or
 99  (
100    (process.name : ("7z.exe", "7za.exe") or ?process.pe.original_file_name in ("7z.exe", "7za.exe")) and
101    process.args == "a" and process.args : "-p*"
102  )
103) and
104  not process.parent.executable : (
105        "C:\\Program Files\\*.exe",
106        "C:\\Program Files (x86)\\*.exe",
107        "?:\\ManageEngine\\*\\jre\\bin\\java.exe",
108        "?:\\Nox\\bin\\Nox.exe",
109        "\\Device\\HarddiskVolume?\\Program Files\\*.exe",
110        "\\Device\\HarddiskVolume?\\Program Files (x86)\\*.exe",
111        "\\Device\\HarddiskVolume?\\ManageEngine\\*\\jre\\bin\\java.exe",
112        "\\Device\\HarddiskVolume?\\Nox\\bin\\Nox.exe"
113      )
114'''
115
116
117[[rule.threat]]
118framework = "MITRE ATT&CK"
119[[rule.threat.technique]]
120id = "T1005"
121name = "Data from Local System"
122reference = "https://attack.mitre.org/techniques/T1005/"
123
124[[rule.threat.technique]]
125id = "T1560"
126name = "Archive Collected Data"
127reference = "https://attack.mitre.org/techniques/T1560/"
128[[rule.threat.technique.subtechnique]]
129id = "T1560.001"
130name = "Archive via Utility"
131reference = "https://attack.mitre.org/techniques/T1560/001/"
132
133
134
135[rule.threat.tactic]
136id = "TA0009"
137name = "Collection"
138reference = "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