Detection rules › Elastic

Unusual File Written or Modified in Startup Folder

Source
github.com/elastic/protections-artifacts

Identifies suspicious file extensions or names written to the startup folder. Adversaries may use this technique to maintain persistence.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies suspicious file extensions or names written to the startup folder. Adversaries may use this technique to
maintain persistence.
"""
id = "30a90136-7831-41c3-a2aa-1a303c1186ac"
license = "Elastic License v2"
name = "Unusual File Written or Modified in Startup Folder"
os_list = ["windows"]
version = "1.0.41"

query = '''
file where event.action != "deletion" and
  process.pid != 4 and process.executable != null and
  file.name != null and not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
  file.path : ("?:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*",
               "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*") and
  (
   /* file extensions rarely written to Startup folder by legit installers */
   file.extension : ("exe", "com", "scr", "dll", "hta", "ps1", "cmd", "url", "wsh", "wsf", "vbe", "jse", "sick", "png", "jpg", "manifest", "ahk", "jar") or

   /* suspicious file names */
   length(file.name) <= 6 or
   file.name :
        ("*Microsoft*",
         "*fuck*",
         "*:*",
         "*.*.",
         "*update*",
         "*windows*",
         "*setup*",
         "*googl*",
         "*adobe*",
         "*chrome*")
   ) and
   not process.executable :
               ("?:\\Windows\\SysWOW64\\msiexec.exe",
                "?:\\Windows\\system32\\msiexec.exe",
                "?:\\Windows\\explorer.exe",
                "?:\\Windows\\System32\\svchost.exe",
                "?:\\Windows\\System32\\dllhost.exe",
                "?:\\Windows\\System32\\xcopy.exe",
                "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*.exe",
                "?:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\Platform\\*.exe",
                "?:\\Program Files\\Windows Defender Advanced Threat Protection\\*.exe",
                "\\Device\\Mup\\*\\SysVol\\*") and
    not (process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and not process.name : "javaw.exe") and
    not (process.name : "cmd.exe" and file.extension : "cmd") and
    not (process.code_signature.subject_name :
                 ("Intercontinental Exchange, Inc.", "Chocolatey Software, Inc.", "ONELAUNCH TECHNOLOGIES INC.", 
                  "Notepad++", "Ghisler Software GmbH", "Western Union Holdings Inc.", "AnyDesk Software GmbH", "Learnpulse SAS") and
         process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*")) and
    not (process.executable : "?:\\Windows\\System32\\notepad.exe" and file.extension : ("bat", "cmd")) and
    not (process.executable : "C:\\Windows\\SysWOW64\\cscript.exe" and file.name : "WUPOSStartup.exe") and
    not (process.name : "cmd.exe" and file.name : "MonitorES.exe")
'''

min_endpoint_version = "8.0.0"
[[actions]]
action = "kill_process"
field = "process.entity_id"
state = 0

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

[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1547"
name = "Boot or Logon Autostart Execution"
reference = "https://attack.mitre.org/techniques/T1547/"
[[threat.technique.subtechnique]]
id = "T1547.001"
name = "Registry Run Keys / Startup Folder"
reference = "https://attack.mitre.org/techniques/T1547/001/"



[threat.tactic]
id = "TA0003"
name = "Persistence"
reference = "https://attack.mitre.org/tactics/TA0003/"
[[threat]]
framework = "MITRE ATT&CK"
[[threat.technique]]
id = "T1036"
name = "Masquerading"
reference = "https://attack.mitre.org/techniques/T1036/"
[[threat.technique.subtechnique]]
id = "T1036.005"
name = "Match Legitimate Resource Name or Location"
reference = "https://attack.mitre.org/techniques/T1036/005/"



[threat.tactic]
id = "TA0005"
name = "Defense Evasion"
reference = "https://attack.mitre.org/tactics/TA0005/"

[internal]
min_endpoint_version = "8.0.0"

Stages and Predicates

Stage 1: file

file where event.action != "deletion" and
  process.pid != 4 and process.executable != null and
  file.name != null and not user.id : ("S-1-5-18", "S-1-5-19", "S-1-5-20") and
  file.path : ("?:\\Users\\*\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Startup\\*",
               "?:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs\\StartUp\\*") and
  (
   file.extension : ("exe", "com", "scr", "dll", "hta", "ps1", "cmd", "url", "wsh", "wsf", "vbe", "jse", "sick", "png", "jpg", "manifest", "ahk", "jar") or
   length(file.name) <= 6 or
   file.name :
        ("*Microsoft*",
         "*fuck*",
         "*:*",
         "*.*.",
         "*update*",
         "*windows*",
         "*setup*",
         "*googl*",
         "*adobe*",
         "*chrome*")
   ) and
   not process.executable :
               ("?:\\Windows\\SysWOW64\\msiexec.exe",
                "?:\\Windows\\system32\\msiexec.exe",
                "?:\\Windows\\explorer.exe",
                "?:\\Windows\\System32\\svchost.exe",
                "?:\\Windows\\System32\\dllhost.exe",
                "?:\\Windows\\System32\\xcopy.exe",
                "?:\\ProgramData\\Microsoft\\Windows Defender\\Platform\\*.exe",
                "?:\\ProgramData\\Microsoft\\Windows Defender Advanced Threat Protection\\Platform\\*.exe",
                "?:\\Program Files\\Windows Defender Advanced Threat Protection\\*.exe",
                "\\Device\\Mup\\*\\SysVol\\*") and
    not (process.executable : ("?:\\Program Files\\*.exe", "?:\\Program Files (x86)\\*.exe") and not process.name : "javaw.exe") and
    not (process.name : "cmd.exe" and file.extension : "cmd") and
    not (process.code_signature.subject_name :
                 ("Intercontinental Exchange, Inc.", "Chocolatey Software, Inc.", "ONELAUNCH TECHNOLOGIES INC.",
                  "Notepad++", "Ghisler Software GmbH", "Western Union Holdings Inc.", "AnyDesk Software GmbH", "Learnpulse SAS") and
         process.code_signature.status : ("trusted", "errorExpired", "errorCode_endpoint*")) and
    not (process.executable : "?:\\Windows\\System32\\notepad.exe" and file.extension : ("bat", "cmd")) and
    not (process.executable : "C:\\Windows\\SysWOW64\\cscript.exe" and file.name : "WUPOSStartup.exe") and
    not (process.name : "cmd.exe" and file.name : "MonitorES.exe")

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.nameeqjavaw.exeexcludes:process.name field:"process.name" value:"javaw.exe"
process.executablewildcard?:\Program Files\*.exe, ?:\Program Files (x86)\*.exeexcludes:process.executable field:"process.executable" value:"?:\Program Files\*.exe" field:"process.executable" value:"?:\Program Files (x86)\*.exe"
file.extensioneqbat, cmdexcludes:file.extension field:"file.extension" value:"bat" field:"file.extension" value:"cmd"
process.executableeq?:\Windows\System32\notepad.exeexcludes:process.executable field:"process.executable" value:"?:\Windows\System32\notepad.exe"
file.extensioneqcmdexcludes:file.extension field:"file.extension" value:"cmd"
process.nameeqcmd.exeexcludes:process.name field:"process.name" value:"cmd.exe"
file.nameeqMonitorES.exeexcludes:file.name field:"file.name" value:"MonitorES.exe"
file.nameeqWUPOSStartup.exeexcludes:file.name field:"file.name" value:"WUPOSStartup.exe"
process.executableeqC:\Windows\SysWOW64\cscript.exeexcludes:process.executable field:"process.executable" value:"C:\Windows\SysWOW64\cscript.exe"
process.code_signature.statuswildcardtrusted, errorExpired, errorCode_endpoint*excludes:process.code_signature.status field:"process.code_signature.status" value:"trusted" field:"process.code_signature.status" value:"errorExpired" field:"process.code_signature.status" value:"errorCode_endpoint*"
process.code_signature.subject_nameeqIntercontinental Exchange, Inc., Chocolatey Software, Inc., ONELAUNCH TECHNOLOGIES INC., Notepad++, Ghisler Software GmbH, Western Union Holdings Inc., AnyDesk Software GmbH, Learnpulse SASexcludes:process.code_signature.subject_name
process.executablewildcard?:\Windows\SysWOW64\msiexec.exe, ?:\Windows\system32\msiexec.exe, ?:\Windows\explorer.exe, ?:\Windows\System32\svchost.exe, ?:\Windows\System32\dllhost.exe, ?:\Windows\System32\xcopy.exe, ?:\ProgramData\Microsoft\Windows Defender\Platform\*.exe, ?:\ProgramData\Microsoft\Windows Defender Advanced Threat Protection\Platform\*.exe, ?:\Program Files\Windows Defender Advanced Threat Protection\*.exe, \Device\Mup\*\SysVol\*excludes:process.executable
user.ideqS-1-5-18, S-1-5-19, S-1-5-20excludes:user.id field:"user.id" value:"S-1-5-18" field:"user.id" value:"S-1-5-19" field:"user.id" value:"S-1-5-20"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actionne
  • deletion corpus 86 (elastic 86)
field:"EventType" kind:ne value:"deletion"
file.extensionwildcard
  • ahk
  • cmd corpus 15 (elastic 15)
  • com corpus 16 (elastic 16)
  • dll corpus 33 (elastic 33)
  • exe corpus 32 (elastic 32)
  • hta corpus 20 (elastic 20)
  • jar corpus 2 (elastic 2)
  • jpg corpus 3 (elastic 3)
  • jse corpus 18 (elastic 18)
  • manifest corpus 2 (elastic 2)
  • png corpus 4 (elastic 4)
  • ps1 corpus 9 (elastic 9)
  • scr corpus 17 (elastic 17)
  • sick
  • url corpus 5 (elastic 5)
  • vbe corpus 18 (elastic 18)
  • wsf corpus 10 (elastic 10)
  • wsh corpus 16 (elastic 16)
field:"file.extension" kind:wildcard
file.nameis_not_null
  • (no value, null check)
field:"file.name" kind:is_not_null
file.namewildcard
  • *.*.
  • *:*
  • *Microsoft*
  • *adobe*
  • *chrome*
  • *fuck*
  • *googl*
  • *setup*
  • *update*
  • *windows*
field:"file.name" kind:wildcard
file.pathwildcard
  • ?:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp\*
  • ?:\Users\*\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup\* corpus 13 (elastic 13)
field:"TargetFilename" kind:wildcard
process.executableis_not_null
  • (no value, null check)
field:"Image" kind:is_not_null
process.namewildcard
  • javaw.exe corpus 9 (elastic 9)
field:"process_name" kind:wildcard value:"javaw.exe"
process.pidne
  • 4 transforms: number corpus 44 (elastic 44)
field:"process_id" kind:ne value:"4"