Detection rules › Elastic

Shell Execution via Windows Shortcut File

Time window
1m
Sequence by
process.entity_id, process.parent.entity_id
Source
github.com/elastic/protections-artifacts

Identifies the execution of a script or program extracted from within a Windows shortcut (lnk) file. Adversaries may embed malicious scripts or files in a shortcut file before delivering it to their target in order to trick them into executing the payload.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the execution of a script or program extracted from within a Windows shortcut (lnk) file. Adversaries may
embed malicious scripts or files in a shortcut file before delivering it to their target in order to trick them into
executing the payload.
"""
id = "1a88b997-bcae-430a-8a24-7378e8bf5cc4"
license = "Elastic License v2"
name = "Shell Execution via Windows Shortcut File"
os_list = ["windows"]
reference = ["https://docs.google.com/presentation/d/13SsBd0wI0PpyH5C8WlnE_DsJjy1KxAjZ5Dmke9FHfRE/"]
version = "1.0.35"

query = '''
sequence with maxspan=1m
  [file where event.action == "creation" and file.extension : ("lnk", "url") and
   (
    (process.name : ("winrar.exe", "7zFM.exe", "Bandizip.exe") and
     file.path : ("?:\\*\\Temp\\7z*\\*", "?:\\*\\Temp\\Rar$*\\*", "?:\\*\\Temp\\BNZ.*")) or
     /* Issue #374 */
    (process.name : "explorer.exe" and
     /* lowered file.size condition as it creates evasion opportunities */
     file.path : "?:\\*\\AppData\\Local\\Temp\\Temp?_*.lnk")
   )
  ] by process.entity_id
  [process where event.action == "start" and
   process.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "mshta.exe", "wmic.exe") and
   (process.parent.name : ("winrar.exe", "7zFM.exe") or
    /* Issue #374 */
    (process.parent.name : "explorer.exe" and process.args_count >= 5))
   ] by process.parent.entity_id
'''

min_endpoint_version = "7.15.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 1

[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 1

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1566"
name = "Phishing"
reference = "https://attack.mitre.org/techniques/T1566/"
[[threat.technique.subtechnique]]
id = "T1566.001"
name = "Spearphishing Attachment"
reference = "https://attack.mitre.org/techniques/T1566/001/"

[[threat.technique.subtechnique]]
id = "T1566.002"
name = "Spearphishing Link"
reference = "https://attack.mitre.org/techniques/T1566/002/"



[threat.tactic]
id = "TA0001"
name = "Initial Access"
reference = "https://attack.mitre.org/tactics/TA0001/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1059"
name = "Command and Scripting Interpreter"
reference = "https://attack.mitre.org/techniques/T1059/"
[[threat.technique.subtechnique]]
id = "T1059.001"
name = "PowerShell"
reference = "https://attack.mitre.org/techniques/T1059/001/"

[[threat.technique.subtechnique]]
id = "T1059.003"
name = "Windows Command Shell"
reference = "https://attack.mitre.org/techniques/T1059/003/"


[[threat.technique]]
id = "T1204"
name = "User Execution"
reference = "https://attack.mitre.org/techniques/T1204/"
[[threat.technique.subtechnique]]
id = "T1204.001"
name = "Malicious Link"
reference = "https://attack.mitre.org/techniques/T1204/001/"

[[threat.technique.subtechnique]]
id = "T1204.002"
name = "Malicious File"
reference = "https://attack.mitre.org/techniques/T1204/002/"



[threat.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Ordered sequence: each step below must occur in order within 1m, correlated by process.entity_id, process.parent.entity_id.

Stage 1: file

[file where event.action == "creation" and file.extension : ("lnk", "url") and
   (
    (process.name : ("winrar.exe", "7zFM.exe", "Bandizip.exe") and
     file.path : ("?:\\*\\Temp\\7z*\\*", "?:\\*\\Temp\\Rar$*\\*", "?:\\*\\Temp\\BNZ.*")) or
    (process.name : "explorer.exe" and
     file.path : "?:\\*\\AppData\\Local\\Temp\\Temp?_*.lnk")
   )
  ] by process.entity_id

Stage 2: process

[process where event.action == "start" and
   process.name : ("cmd.exe", "powershell.exe", "pwsh.exe", "mshta.exe", "wmic.exe") and
   (process.parent.name : ("winrar.exe", "7zFM.exe") or
    (process.parent.name : "explorer.exe" and process.args_count >= 5))
   ] by process.parent.entity_id

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • creation corpus 58 (elastic 58)
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq
file.extensionwildcard
  • lnk corpus 9 (elastic 9)
  • url corpus 5 (elastic 5)
field:"file.extension" kind:wildcard
file.pathwildcard
  • ?:\*\AppData\Local\Temp\Temp?_*.lnk
  • ?:\*\Temp\7z*\*
  • ?:\*\Temp\BNZ.*
  • ?:\*\Temp\Rar$*\*
field:"TargetFilename" kind:wildcard
process.args_countge
  • 5 transforms: number corpus 3 (elastic 3)
field:"process.args_count" kind:ge value:"5"
process.namewildcard
  • 7zFM.exe corpus 7 (elastic 7)
  • Bandizip.exe corpus 5 (elastic 5)
  • cmd.exe corpus 121 (elastic 92, splunk 29)
  • explorer.exe corpus 21 (elastic 19, splunk 2)
  • mshta.exe corpus 84 (elastic 79, splunk 5)
  • powershell.exe corpus 184 (elastic 140, splunk 44)
  • pwsh.exe corpus 77 (elastic 48, splunk 29)
  • winrar.exe corpus 9 (elastic 9)
  • wmic.exe corpus 66 (elastic 39, splunk 27)
field:"process_name" kind:wildcard
process.parent.namewildcard
  • 7zFM.exe corpus 12 (elastic 12)
  • explorer.exe corpus 51 (elastic 50, splunk 1)
  • winrar.exe corpus 15 (elastic 14, splunk 1)
field:"parent_process_name" kind:wildcard