Detection rules › Elastic

Suspicious File Rename via SMB

Time window
3s
Source
github.com/elastic/protections-artifacts

Identifies an incoming SMB connection followed by a suspicious file rename operation. This may indicate a remote ransomware attack via the SMB protocol.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies an incoming SMB connection followed by a suspicious file rename operation. This may indicate a remote
ransomware attack via the SMB protocol.
"""
id = "58b7beb4-0b8a-4196-a17d-7317620ef495"
license = "Elastic License v2"
name = "Suspicious File Rename via SMB"
os_list = ["windows"]
version = "1.0.6"

query = '''
sequence with maxspan=3s
 [network where event.action == "connection_accepted" and destination.port == 445 and source.port >= 49152 and
  process.pid == 4 and network.type == "ipv4" and not endswith(source.address, destination.address) and
  source.ip != "127.0.0.1" and source.ip != "::1" ]
 [file where event.action == "rename" and process.pid == 4 and user.id like ("S-1-5-21*", "S-1-12-*") and
  file.extension != null and file.Ext.entropy >= 6 and file.path : "C:\\Users\\*" and
  file.Ext.original.name : ("*.jpg", "*.bmp", "*.png", "*.pdf", "*.doc", "*.docx", "*.xls", "*.xlsx", "*.ppt", "*.pptx", "*.lnk", "*.txt") and
  not file.extension in~ ("jpg", "bmp", "png", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "lnk", "txt")]
 [file where event.action == "rename" and process.pid == 4 and user.id like ("S-1-5-21*", "S-1-12-*") and
  file.extension != null and file.Ext.entropy >= 6 and file.path : "C:\\Users\\*" and
  file.Ext.original.name : ("*.jpg", "*.bmp", "*.png", "*.pdf", "*.doc", "*.docx", "*.xls", "*.xlsx", "*.ppt", "*.pptx", "*.lnk", "*.txt") and
  not file.extension in~ ("jpg", "bmp", "png", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "lnk", "txt")]
'''

actions = []
min_endpoint_version = "8.4.0"
[[optional_actions]]
action = "rollback"
field = "process.entity_id"
state = 0

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1486"
name = "Data Encrypted for Impact"
reference = "https://attack.mitre.org/techniques/T1486/"

[[threat.technique]]
id = "T1490"
name = "Inhibit System Recovery"
reference = "https://attack.mitre.org/techniques/T1490/"


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

[internal]
min_endpoint_version = "8.4.0"

Stages and Predicates

Stage 1: network

[network where event.action == "connection_accepted" and destination.port == 445 and source.port >= 49152 and
  process.pid == 4 and network.type == "ipv4" and not endswith(source.address, destination.address) and
  source.ip != "127.0.0.1" and source.ip != "::1" ]

Stage 2: file

[file where event.action == "rename" and process.pid == 4 and user.id like ("S-1-5-21*", "S-1-12-*") and
  file.extension != null and file.Ext.entropy >= 6 and file.path : "C:\\Users\\*" and
  file.Ext.original.name : ("*.jpg", "*.bmp", "*.png", "*.pdf", "*.doc", "*.docx", "*.xls", "*.xlsx", "*.ppt", "*.pptx", "*.lnk", "*.txt") and
  not file.extension in~ ("jpg", "bmp", "png", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "lnk", "txt")]

Stage 3: file

[file where event.action == "rename" and process.pid == 4 and user.id like ("S-1-5-21*", "S-1-12-*") and
  file.extension != null and file.Ext.entropy >= 6 and file.path : "C:\\Users\\*" and
  file.Ext.original.name : ("*.jpg", "*.bmp", "*.png", "*.pdf", "*.doc", "*.docx", "*.xls", "*.xlsx", "*.ppt", "*.pptx", "*.lnk", "*.txt") and
  not file.extension in~ ("jpg", "bmp", "png", "pdf", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "lnk", "txt")]

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
source.addressends_withdestination.addressexcludes:source.address field:"source.address" value:"destination.address"
file.extensioninbmp, doc, docx, jpg, lnk, pdf, png, ppt, pptx, txt, xls, xlsxexcludes:file.extension

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
destination.porteq
  • 445 transforms: number corpus 10 (elastic 7, splunk 2, sigma 1)
field:"DestinationPort" kind:eq value:"445"
event.actioneq
  • connection_accepted corpus 6 (elastic 6)
  • rename corpus 22 (elastic 21, sigma 1)
field:"EventType" kind:eq
file.Ext.entropyge
  • 6 transforms: number corpus 4 (elastic 4)
field:"file.Ext.entropy" kind:ge value:"6"
file.Ext.original.namewildcard
  • *.bmp corpus 6 (elastic 6)
  • *.doc corpus 6 (elastic 6)
  • *.docx corpus 6 (elastic 6)
  • *.jpg corpus 6 (elastic 6)
  • *.lnk corpus 2 (elastic 2)
  • *.pdf corpus 6 (elastic 6)
  • *.png corpus 6 (elastic 6)
  • *.ppt corpus 6 (elastic 6)
  • *.pptx corpus 6 (elastic 6)
  • *.txt
  • *.xls corpus 6 (elastic 6)
  • *.xlsx corpus 6 (elastic 6)
field:"file.Ext.original.name" kind:wildcard
file.extensionis_not_null
  • (no value, null check)
field:"file.extension" kind:is_not_null
file.pathwildcard
  • C:\Users\* corpus 13 (sigma 9, elastic 4)
field:"TargetFilename" kind:wildcard value:"C:\Users\*"
network.typeeq
  • ipv4 corpus 3 (elastic 3)
field:"network.type" kind:eq value:"ipv4"
process.pideq
  • 4 transforms: number corpus 19 (elastic 19)
field:"process_id" kind:eq value:"4"
source.ipne
  • 127.0.0.1 corpus 23 (elastic 22, splunk 1)
  • ::1 corpus 21 (elastic 20, splunk 1)
field:"src_ip" kind:ne
source.portge
  • 49152 transforms: number corpus 16 (elastic 16)
field:"SourcePort" kind:ge value:"49152"
user.idwildcard
  • S-1-12-* corpus 46 (elastic 46)
  • S-1-5-21* corpus 47 (elastic 47)
field:"user.id" kind:wildcard