Detection rules › Sigma

SQL server sqlcmd utility abuse for privilege escalation

Status
experimental
Severity
high
Log source
product windows, category process_creation
Author
mdecrevoisier
Source
github.com/mdecrevoisier/SIGMA-detection-rules

Detects scenarios where an attacker uses sqlcmd utility to escalate privileges or introduce weaknesses.

MITRE ATT&CK coverage

Event coverage

Rule body yaml

title: SQL server sqlcmd utility abuse for privilege escalation
description: Detects scenarios where an attacker uses sqlcmd utility to escalate privileges or introduce weaknesses.
references:
- https://github.com/mdecrevoisier/EVTX-to-MITRE-Attack/tree/master/TA0003-Persistence/T1505.001-SQL%20Stored%20Procedures
- https://blog.netspi.com/when-databases-attack-hacking-with-the-osql-utility/
- http://travisaltman.com/pen-test-and-hack-microsoft-sql-server-mssql/
- https://thedfirreport.com/2021/12/13/diavol-ransomware/
- https://twitter.com/TheDFIRReport/status/1498804631090208777?t=TKMbiJINaLoJqQqXIF5mCA&s=09
- https://blog.talosintelligence.com/breaking-the-silence-recent-truebot-activity/
- https://unit42.paloaltonetworks.com/espionage-campaign-targets-south-asian-entities/
tags:
- attack.persistence
- attack.t1505.001
- 
author: mdecrevoisier
status: experimental
logsource:
  product: windows
  category: process_creation
detection:
  selection:
    NewProcessName|endswith:
      - '\sqlcmd.exe'     # used in recent SQL Server versions
      - '\osql.exe'       # used in old SQL server version
    CommandLine|contains: # specify the database\instance'
      - /S
      - -S
    CommandLine|contains: # runs a query and immediately exists
      - /Q
      - -Q
  condition: selection
falsepositives:
- Master database restore procedure
- Maintenance operation
- Legitim SA account password recovery
level: high

Stages and Predicates

Stage 0: condition

selection

Stage 1: selection

selection:
  NewProcessName|endswith:
    - '\sqlcmd.exe'
    - '\osql.exe'
  CommandLine|contains:
    - /S
    - -S
  CommandLine|contains:
    - /Q
    - -Q

Indicators

Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.

FieldKindValues
CommandLinematch
  • -Q corpus 9 (sigma 6, kusto 2, splunk 1)
  • /Q corpus 8 (sigma 7, splunk 1)
NewProcessNameends_with
  • \osql.exe
  • \sqlcmd.exe corpus 5 (sigma 5)