Detection rules › Elastic

Suspicious Execution via SQL PowerShell

Source
github.com/elastic/protections-artifacts

Detects attempts to execute suspicious powershell commands using the Microsoft SQL Powershell Helper Tools.

MITRE ATT&CK coverage

Rule body

[rule]
description = "Detects attempts to execute suspicious powershell commands using the Microsoft SQL Powershell Helper Tools."
id = "d111e88f-c5d2-41b4-b294-1f9cfea93b6c"
license = "Elastic License v2"
name = "Suspicious Execution via SQL PowerShell"
os_list = ["windows"]
reference = ["https://lolbas-project.github.io/lolbas/OtherMSBinaries/Sqltoolsps/"]
version = "1.0.4"

query = '''
process where event.action == "start" and 
 process.name : ("SQLToolsPS.exe", "sqlps.exe") and 
 process.args : ("-e", "-enc", "-ep", "-encoded", "*;iex", "*start-process*", "*WebClient*", 
                "*DownloadFile*", "*DownloadString*", "*BitsTransfer*", "*Reflection.Assembly*")
'''

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

[[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.tactic]
id = "TA0002"
name = "Execution"
reference = "https://attack.mitre.org/tactics/TA0002/"

[internal]
min_endpoint_version = "7.16.0"

Stages and Predicates

Stage 1: process

process where event.action == "start" and 
 process.name : ("SQLToolsPS.exe", "sqlps.exe") and 
 process.args : ("-e", "-enc", "-ep", "-encoded", "*;iex", "*start-process*", "*WebClient*", 
                "*DownloadFile*", "*DownloadString*", "*BitsTransfer*", "*Reflection.Assembly*")

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
  • *;iex
  • *BitsTransfer*
  • *DownloadFile*
  • *DownloadString*
  • *Reflection.Assembly*
  • *WebClient*
  • *start-process*
  • -e corpus 46 (elastic 46)
  • -enc corpus 2 (elastic 2)
  • -encoded
  • -ep
field:"process.args" kind:wildcard
process.namewildcard
  • SQLToolsPS.exe
  • sqlps.exe corpus 2 (elastic 2)
field:"process_name" kind:wildcard