Detection rules › Elastic

Suspicious Scheduled Task Creation

Source
github.com/elastic/protections-artifacts

Identifies the creation of a scheduled task with suspicious argument such as task path or parent process. This behavior is consistent with an adversary attempting to establish persistence.

MITRE ATT&CK coverage

Rule body

[rule]
description = """
Identifies the creation of a scheduled task with suspicious argument such as task path or parent process. This behavior
is consistent with an adversary attempting to establish persistence.
"""
id = "beebd95c-93f4-46d2-a902-053bfe78686b"
license = "Elastic License v2"
name = "Suspicious Scheduled Task Creation"
os_list = ["windows"]
reference = ["https://docs.microsoft.com/en-us/windows/win32/taskschd"]
version = "1.0.34"

query = '''
process where event.action == "start" and
  process.pe.original_file_name : "schtasks.exe" and
  not process.Ext.token.integrity_level_name == "system" and
  process.args : ("/create", "-create") and process.args : "/tr" and
  not process.command_line : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*") and
  not process.Ext.token.integrity_level_name == "system" and
  (
   process.args : ("*Users\\Public\\*", "*:\\Windows\\Tasks\\*", "*:\\Windows\\system32\\Tasks\\*") or 
   
   (process.args : "minute" and process.args : "/mo" and
    process.args : ("*\\AppData\\*", "*\\ProgramData\\*", "*Users\\Public\\*")) or

   (process.args : "HIGHEST" and process.args : "ONLOGON" and
    process.parent.name : ("wmiprvse.exe", "rundll32.exe", "regsvr32.exe") and
    not process.parent.command_line : "*rundll32*zzzzInvokeManagedCustomActionOutOfProc*") or

   (process.args : ("onlogon", "minute", "onstart", "daily", "once") and
    process.parent.name : "cmd.exe" and process.parent.command_line : "*schtasks*" and
    descendant of [process where event.action == "start" and not process.code_signature.trusted == true]) or

   (process.args : ("SYSTEM", "NT AUTHORITY\\SYSTEM") and process.args : "/ru" and
    process.command_line : ("*vssadmin*Delete*Shadows*", "*wmic*shadowcopy*", "*regsvr32*-s*")) or 
    
   process.command_line : ("*comspec*", "*cmd.exe*/c*", "*^*^*^*", "*powershell*", "*http*://*", "*mshta*", "* curl.exe*")
  ) and 
  
  not process.command_line : ("*\\bmx\\* shutdown.exe *", "*powershell.exe*Task*rubrik_vmware*") and
  not (process.parent.args : "C:\\ProgramData\\Prognos_Scripts\\OneDriveMapper\\OneDriveMapper.ps1" and process.command_line : "*powershell*") and
  not process.args :  ("'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe' -NonInteractive -WindowStyle Hidden -ExecutionPolicy RemoteSigned -File C:\\Windows\\TEMP\\rubrik_vmware*\\post-restore.ps1 ",
                       "'C:\\ProWin22\\32bit\\ProSeriesBackgroundUpdater.exe' -p 'C:\\ProWin22' -y 22 -s Core", 
                       "C:\\ModentoBridge\\ModentoPowershellProxy\\schedulePSP.bat", 
                       "C:\\ModentoBridge\\ModentoPowershellProxy\\startProxy.bat", 
                       "C:\\ModentoBridge_1\\ModentoPowershellProxy\\startProxy.bat", 
                       "C:\\PROGRA~2\\*\\EXAQUA~1\\DEVELO~1\\EQPERF~1\\Config\\EQPERF~1.BAT",
                       "c:\\dona_adm\\admin\\*.exe") and
  not (process.parent.name : "powershell.exe" and process.args : "Rubrik Post Restore Task") and
  not process.command_line : "*\\ProgramData\\Atos\\custom-scanner\\scan_sox.cmd*" and
  not (process.parent.name : "wsmprovhost.exe" and process.command_line : "*TempGPUpdate*" and process.command_line : "*gpupdate*") and
  not (process.args : "& \"\\\\*" and process.args : "powershell") and 
  not (process.parent.name : "cmd.exe" and (process.parent.args :  "\\\\*" or process.parent.command_line : "\"C:\\WINDOWS\\system32\\cmd.exe\""))
'''

min_endpoint_version = "7.15.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 = "T1053"
name = "Scheduled Task/Job"
reference = "https://attack.mitre.org/techniques/T1053/"
[[threat.technique.subtechnique]]
id = "T1053.005"
name = "Scheduled Task"
reference = "https://attack.mitre.org/techniques/T1053/005/"



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

[internal]
min_endpoint_version = "7.15.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and
  process.pe.original_file_name : "schtasks.exe" and
  not process.Ext.token.integrity_level_name == "system" and
  process.args : ("/create", "-create") and process.args : "/tr" and
  not process.command_line : ("*:\\Program Files\\*", "*:\\Program Files (x86)\\*") and
  not process.Ext.token.integrity_level_name == "system" and
  (
   process.args : ("*Users\\Public\\*", "*:\\Windows\\Tasks\\*", "*:\\Windows\\system32\\Tasks\\*") or 
   
   (process.args : "minute" and process.args : "/mo" and
    process.args : ("*\\AppData\\*", "*\\ProgramData\\*", "*Users\\Public\\*")) or

   (process.args : "HIGHEST" and process.args : "ONLOGON" and
    process.parent.name : ("wmiprvse.exe", "rundll32.exe", "regsvr32.exe") and
    not process.parent.command_line : "*rundll32*zzzzInvokeManagedCustomActionOutOfProc*") or

   (process.args : ("onlogon", "minute", "onstart", "daily", "once") and
    process.parent.name : "cmd.exe" and process.parent.command_line : "*schtasks*" and
    descendant of [process where event.action == "start" and not process.code_signature.trusted == true]) or

   (process.args : ("SYSTEM", "NT AUTHORITY\\SYSTEM") and process.args : "/ru" and
    process.command_line : ("*vssadmin*Delete*Shadows*", "*wmic*shadowcopy*", "*regsvr32*-s*")) or 
    
   process.command_line : ("*comspec*", "*cmd.exe*/c*", "*^*^*^*", "*powershell*", "*http*://*", "*mshta*", "* curl.exe*")
  ) and 
  
  not process.command_line : ("*\\bmx\\* shutdown.exe *", "*powershell.exe*Task*rubrik_vmware*") and
  not (process.parent.args : "C:\\ProgramData\\Prognos_Scripts\\OneDriveMapper\\OneDriveMapper.ps1" and process.command_line : "*powershell*") and
  not process.args :  ("'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe' -NonInteractive -WindowStyle Hidden -ExecutionPolicy RemoteSigned -File C:\\Windows\\TEMP\\rubrik_vmware*\\post-restore.ps1 ",
                       "'C:\\ProWin22\\32bit\\ProSeriesBackgroundUpdater.exe' -p 'C:\\ProWin22' -y 22 -s Core", 
                       "C:\\ModentoBridge\\ModentoPowershellProxy\\schedulePSP.bat", 
                       "C:\\ModentoBridge\\ModentoPowershellProxy\\startProxy.bat", 
                       "C:\\ModentoBridge_1\\ModentoPowershellProxy\\startProxy.bat", 
                       "C:\\PROGRA~2\\*\\EXAQUA~1\\DEVELO~1\\EQPERF~1\\Config\\EQPERF~1.BAT",
                       "c:\\dona_adm\\admin\\*.exe") and
  not (process.parent.name : "powershell.exe" and process.args : "Rubrik Post Restore Task") and
  not process.command_line : "*\\ProgramData\\Atos\\custom-scanner\\scan_sox.cmd*" and
  not (process.parent.name : "wsmprovhost.exe" and process.command_line : "*TempGPUpdate*" and process.command_line : "*gpupdate*") and
  not (process.args : "& \"\\\\*" and process.args : "powershell") and 
  not (process.parent.name : "cmd.exe" and (process.parent.args :  "\\\\*" or process.parent.command_line : "\"C:\\WINDOWS\\system32\\cmd.exe\""))

Exclusions

The rule actively suppresses these predicates.

FieldKindExcluded valuesSearch
process.parent.argsstarts_with\\excludes:process.parent.args field:"process.parent.args" value:"\\"
process.parent.command_lineeq"C:\WINDOWS\system32\cmd.exe"excludes:process.parent.command_line
process.parent.nameeqcmd.exeexcludes:process.parent.name field:"process.parent.name" value:"cmd.exe"
process.argseqRubrik Post Restore Taskexcludes:process.args field:"process.args" value:"Rubrik Post Restore Task"
process.parent.nameeqpowershell.exeexcludes:process.parent.name field:"process.parent.name" value:"powershell.exe"
process.argseqpowershellexcludes:process.args field:"process.args" value:"powershell"
process.argsstarts_with& "\\excludes:process.args
process.command_linematchTempGPUpdateexcludes:process.command_line field:"process.command_line" value:"TempGPUpdate"
process.command_linematchgpupdateexcludes:process.command_line field:"process.command_line" value:"gpupdate"
process.parent.nameeqwsmprovhost.exeexcludes:process.parent.name field:"process.parent.name" value:"wsmprovhost.exe"
process.command_linematchpowershellexcludes:process.command_line field:"process.command_line" value:"powershell"
process.parent.argseqC:\ProgramData\Prognos_Scripts\OneDriveMapper\OneDriveMapper.ps1excludes:process.parent.args field:"process.parent.args" value:"C:\ProgramData\Prognos_Scripts\OneDriveMapper\OneDriveMapper.ps1"
process.Ext.token.integrity_level_nameeqsystemexcludes:process.Ext.token.integrity_level_name field:"process.Ext.token.integrity_level_name" value:"system"
process.argswildcard'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' -NonInteractive -WindowStyle Hidden -ExecutionPolicy RemoteSigned -File C:\Windows\TEMP\rubrik_vmware*\post-restore.ps1 , 'C:\ProWin22\32bit\ProSeriesBackgroundUpdater.exe' -p 'C:\ProWin22' -y 22 -s Core, C:\ModentoBridge\ModentoPowershellProxy\schedulePSP.bat, C:\ModentoBridge\ModentoPowershellProxy\startProxy.bat, C:\ModentoBridge_1\ModentoPowershellProxy\startProxy.bat, C:\PROGRA~2\*\EXAQUA~1\DEVELO~1\EQPERF~1\Config\EQPERF~1.BAT, c:\dona_adm\admin\*.exeexcludes:process.args
process.command_linematch:\Program Files\, :\Program Files (x86)\excludes:process.command_line field:"process.command_line" value:":\Program Files\" field:"process.command_line" value:":\Program Files (x86)\"
process.command_linematch\ProgramData\Atos\custom-scanner\scan_sox.cmdexcludes:process.command_line field:"process.command_line" value:"\ProgramData\Atos\custom-scanner\scan_sox.cmd"
process.command_linewildcard*\bmx\* shutdown.exe *, *powershell.exe*Task*rubrik_vmware*excludes:process.command_line field:"process.command_line" value:"*\bmx\* shutdown.exe *" field:"process.command_line" value:"*powershell.exe*Task*rubrik_vmware*"

Indicators

These rows show field, operator, and value matches.

FieldKindValuesSearch
event.actioneq
  • start corpus 391 (elastic 391)
field:"EventType" kind:eq value:"start"
process.argswildcard
  • *:\Windows\Tasks\*
  • *:\Windows\system32\Tasks\*
  • *Users\Public\*
  • *\AppData\*
  • *\ProgramData\*
  • -create corpus 6 (elastic 6)
  • /create corpus 7 (elastic 7)
  • /mo
  • /ru corpus 2 (elastic 2)
  • /tr corpus 4 (elastic 4)
  • HIGHEST
  • NT AUTHORITY\SYSTEM
  • ONLOGON
  • SYSTEM
  • daily
  • minute
  • once
  • onlogon
  • onstart
field:"process.args" kind:wildcard
process.command_linewildcard
  • * curl.exe*
  • *^*^*^* corpus 2 (elastic 2)
  • *cmd.exe*/c*
  • *comspec*
  • *http*://* corpus 2 (elastic 2)
  • *mshta* corpus 14 (sigma 14)
  • *powershell* corpus 25 (sigma 24, chronicle 1)
  • *regsvr32*-s*
  • *vssadmin*Delete*Shadows*
  • *wmic*shadowcopy*
field:"CommandLine" kind:wildcard
process.parent.command_linewildcard
  • *schtasks*
field:"ParentCommandLine" kind:wildcard value:"*schtasks*"
process.parent.namewildcard
  • cmd.exe corpus 36 (elastic 31, splunk 4, kusto 1)
  • regsvr32.exe corpus 13 (elastic 13)
  • rundll32.exe corpus 20 (elastic 20)
  • wmiprvse.exe corpus 25 (elastic 19, splunk 5, kusto 1)
field:"parent_process_name" kind:wildcard
process.pe.original_file_namewildcard
  • schtasks.exe corpus 31 (sigma 18, elastic 9, splunk 4)
field:"OriginalFileName" kind:wildcard value:"schtasks.exe"