Latest alertCVE-2018-11776 in Apache Struts Confirmed Exploited in the WildRead
Search all news in the platform

Detection rule

PSEXEC Remote Execution File Artefact

HighTest-data validatedSigmaHQ (community)T1136.002T1543.003T1570

Overview

Detects creation of the PSEXEC key file. Which is created anytime a PsExec command is executed. It gets written to the file system and will be recorded in the USN Journal on the target system

Rule id
304afd73-55a5-4bb9-8c21-0b1fc84ea9e4
ATT&CK techniques
T1136.002 Create Account: Domain Account, T1543.003 Create or Modify System Process: Windows Service, T1570 Lateral Tool Transfer
Severity
High
Confidence
Low
Origin
SigmaHQ (community)
SigmaHQ status
test
Used in defense packs
The Gentlemen, qilin, INC Ransom, Akira, safepay, Play, nightspire, majinahanashi

Validation

  1. ExperimentalSyntax checked only. Not yet tested on events.
  2. Test-data validatedMatched positive test events and ignored near-miss events. Not yet run in a production SIEM.
  3. SIEM-validatedRun in a real SIEM, with a recorded result.

1 of 1 positive test events matched; 1 of 1 near-miss events were correctly ignored. Community rule reused unmodified from SigmaHQ. OffSet7 converted it and tested it on synthetic events.

Detection logic and queries

Queries are shown exactly as generated. Test them in your environment before you deploy them.

Sigma

Sigma (YAML) · 304afd73-55a5-4bb9-8c21-0b1fc84ea9e4

Download
title: PSEXEC Remote Execution File Artefact
id: 304afd73-55a5-4bb9-8c21-0b1fc84ea9e4
status: test
description: Detects creation of the PSEXEC key file. Which is created anytime a PsExec command is executed. It gets written to the file system and will be recorded in the USN Journal on the target system
references:
    - https://aboutdfir.com/the-key-to-identify-psexec/
    - https://twitter.com/davisrichardg/status/1616518800584704028
author: Nasreddine Bencherchali (Nextron Systems)
date: 2023-01-21
modified: 2023-02-23
tags:
    - attack.lateral-movement
    - attack.privilege-escalation
    - attack.execution
    - attack.persistence
    - attack.t1136.002
    - attack.t1543.003
    - attack.t1570
    - attack.s0029
logsource:
    category: file_event
    product: windows
detection:
    selection:
        TargetFilename|startswith: 'C:\Windows\PSEXEC-'
        TargetFilename|endswith: '.key'
    condition: selection
falsepositives:
    - Unlikely
level: high
regression_tests_path: regression_data/rules/windows/file/file_event/file_event_win_sysinternals_psexec_service_key/info.yml

QRadar AQL

IBM QRadar AQL (hunting query)Hunting query

Hunting search for the Log Activity tab or the API. It is not a QRadar rule.

AQL search for the Log Activity tab or the API. It is NOT a deployable QRadar rule: real-time detection in QRadar is a CRE (Custom Rule Engine) rule, for which this build only writes a design specification (qradar_cre).

SELECT * FROM events WHERE devicetype=12 AND LOWER(Filename) LIKE 'c:\windows\psexec-%' AND LOWER(Filename) LIKE '%.key'

QRadar CRE

Design for the QRadar Rule Wizard. It is not importable and has not been tested in QRadar.

Rule name
OffSet7: PSEXEC Remote Execution File Artefact
Rule type
Event rule (Local)
Log source types
Microsoft Windows Security Event Log DSM: Sysmon EID 11 (FileCreate)

Building blocks

  • BB:OffSet7:PSEXEC Remote Execution File Artefact:selection (match)
    All test lines must match (AND).
    • Filename starts with: C:\Windows\PSEXEC-
    • Filename ends with: .key

Main rule, option A (building blocks)

  1. when the event(s) were detected by one or more of these log source types: Microsoft Windows Security Event Log DSM: Sysmon EID 11 (FileCreate)
  2. when an event matches the condition built from these building blocks: BB:OffSet7:PSEXEC Remote Execution File Artefact:selection

Main rule, option B (AQL filter test)

  1. when the event matches this AQL filter query: devicetype=12 AND LOWER(Filename) LIKE 'c:\windows\psexec-%' AND LOWER(Filename) LIKE '%.key'

Rule response

  • Severity 7, credibility 6, relevance 7
  • Ensure the detected event is part of an offense; index offense on Log Source (host) and annotate with the rule title and OffSet7 rule id
  • Respond no more than once per 30 minutes per Log Source (tune per environment)

Limitations

  • QRadar AQL LIKE / CRE string tests are case-sensitive unless the property is lower-cased; the AQL option uses LOWER() where the backend applied it.

Splunk

Splunk SPLSearch

Search for Splunk with Windows/Sysmon field names. A scheduled search or ES correlation search also needs a schedule, time range, throttling and an adaptive response, set in your environment.

TargetFilename="C:\\Windows\\PSEXEC-*" TargetFilename="*.key"

Splunk savedsearches.conf stanzaScheduled search template

Template stanza. Review schedule, alert actions and index/sourcetype for your environment before enabling.

[default]
dispatch.earliest_time = -30d
dispatch.latest_time = now

[PSEXEC Remote Execution File Artefact]
description = Detects creation of the PSEXEC key file. Which is created anytime a PsExec command is executed. It gets written to the file system and will be recorded in the USN Journal on the target system
search = TargetFilename="C:\\Windows\\PSEXEC-*" TargetFilename="*.key"

Microsoft Sentinel

Microsoft Sentinel KQL (ASIM)Hunting query

Hunting query over ASIM-normalized tables. An analytics rule also needs a schedule, entity mapping and alert grouping.

imFileEvent
| where TargetFileName startswith "C:\\Windows\\PSEXEC-" and TargetFileName endswith ".key"

Defender XDR

Microsoft Defender XDR KQLHunting query

Advanced hunting query. A custom detection rule also needs a frequency, impacted entities and actions.

DeviceFileEvents
| where FolderPath startswith "C:\\Windows\\PSEXEC-" and FolderPath endswith ".key"

Elastic

Elastic Lucene (ECS)Hunting query

Lucene query over ECS fields (Winlogbeat/Elastic Agent Windows mappings). A detection rule also needs an index pattern, schedule and actions.

file.path:C\:\\Windows\\PSEXEC\-* AND file.path:*.key

Elastic EQL (ECS)Hunting query

EQL query over ECS fields. Usable in an Elastic Security EQL rule after review; index pattern and schedule are set per environment.

any where file.path:"C:\\Windows\\PSEXEC-*" and file.path:"*.key"

Elastic ES|QL (ECS)Hunting query

ES|QL query over ECS fields; the FROM clause uses * and must be narrowed to your indices.

from * metadata _id, _index, _version | where starts_with(file.path, "C:\\Windows\\PSEXEC-") and ends_with(file.path, ".key")

Required telemetry

Log source
product: windows · category: file_event
Fields used
TargetFilename

False positives

  • Unlikely

Investigation and response

No OffSet7 investigation guidance has been written for this rule yet. Start from the false positives above and the ATT&CK technique pages.

References

Author and attribution

Author
Nasreddine Bencherchali (Nextron Systems)
Source
SigmaHQ · rules/windows/file/file_event/file_event_win_sysinternals_psexec_service_key.yml
Upstream commit
9688134317a2
Licence
Detection Rule License (DRL) 1.1

Version history

  1. Version 1Imported from SigmaHQ
  2. OffSet7 build · SigmaHQ 9688134317a2

Related rules