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

Detection rule

HackTool - Potential Impacket Lateral Movement Activity

HighTest-data validatedSigmaHQ (community)T1021.003T1047

Overview

Detects wmiexec/dcomexec/atexec/smbexec from Impacket framework

Rule id
10c14723-61c7-4c75-92ca-9af245723ad2
ATT&CK techniques
T1021.003 Remote Services: Distributed Component Object Model, T1047 Windows Management Instrumentation
Severity
High
Confidence
Medium
Origin
SigmaHQ (community)
SigmaHQ status
stable
Used in defense packs
The Gentlemen, qilin, INC Ransom, Akira, safepay, nightspire

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.

2 of 2 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) · 10c14723-61c7-4c75-92ca-9af245723ad2

Download
title: HackTool - Potential Impacket Lateral Movement Activity
id: 10c14723-61c7-4c75-92ca-9af245723ad2
related:
    - id: e31f89f7-36fb-4697-8ab6-48823708353b
      type: obsolete
status: stable
description: Detects wmiexec/dcomexec/atexec/smbexec from Impacket framework
references:
    - https://github.com/SecureAuthCorp/impacket/blob/8b1a99f7c715702eafe3f24851817bb64721b156/examples/wmiexec.py
    - https://github.com/SecureAuthCorp/impacket/blob/8b1a99f7c715702eafe3f24851817bb64721b156/examples/atexec.py
    - https://github.com/SecureAuthCorp/impacket/blob/8b1a99f7c715702eafe3f24851817bb64721b156/examples/smbexec.py
    - https://github.com/SecureAuthCorp/impacket/blob/8b1a99f7c715702eafe3f24851817bb64721b156/examples/dcomexec.py
    - https://www.elastic.co/guide/en/security/current/suspicious-cmd-execution-via-wmi.html
author: Ecco, oscd.community, Jonhnathan Ribeiro, Tim Rauch
date: 2019-09-03
modified: 2023-02-21
tags:
    - attack.execution
    - attack.t1047
    - attack.lateral-movement
    - attack.t1021.003
logsource:
    category: process_creation
    product: windows
detection:
    selection_other:
        # *** wmiexec.py
        #    parent is wmiprvse.exe
        #    examples:
        #       cmd.exe /Q /c whoami 1> \\127.0.0.1\ADMIN$\__1567439113.54 2>&1
        #       cmd.exe /Q /c cd  1> \\127.0.0.1\ADMIN$\__1567439113.54 2>&1
        # *** dcomexec.py -object MMC20
        #   parent is mmc.exe
        #   example:
        #       "C:\Windows\System32\cmd.exe" /Q /c cd  1> \\127.0.0.1\ADMIN$\__1567442499.05 2>&1
        # *** dcomexec.py -object ShellBrowserWindow
        #  runs %SystemRoot%\System32\rundll32.exe shell32.dll,SHCreateLocalServerRunDll {c08afd90-f2a1-11d1-8455-00a0c91f3880} but parent command is explorer.exe
        #  example:
        #   "C:\Windows\System32\cmd.exe" /Q /c cd \ 1> \\127.0.0.1\ADMIN$\__1567520103.71 2>&1
        # *** smbexec.py
        #   parent is services.exe
        #   example:
        #       C:\Windows\system32\cmd.exe /Q /c echo tasklist ^> \\127.0.0.1\C$\__output 2^>^&1 > C:\Windows\TEMP\execute.bat & C:\Windows\system32\cmd.exe /Q /c C:\Windows\TEMP\execute.bat & del C:\Windows\TEMP\execute.bat
        ParentImage|endswith:
            - '\wmiprvse.exe'        # wmiexec
            - '\mmc.exe'        # dcomexec MMC
            - '\explorer.exe'        # dcomexec ShellBrowserWindow
            - '\services.exe'        # smbexec
        CommandLine|contains|all:
            - 'cmd.exe'
            - '/Q'
            - '/c'
            - '\\\\127.0.0.1\\'
            - '&1'
    selection_atexec:
        ParentCommandLine|contains:
            - 'svchost.exe -k netsvcs'       # atexec on win10 (parent is "C:\Windows\system32\svchost.exe -k netsvcs")
            - 'taskeng.exe'       # atexec on win7 (parent is "taskeng.exe {AFA79333-694C-4BEE-910E-E57D9A3518F6} S-1-5-18:NT AUTHORITY\System:Service:")
            # cmd.exe /C tasklist /m > C:\Windows\Temp\bAJrYQtL.tmp 2>&1
        CommandLine|contains|all:
            - 'cmd.exe'
            - '/C'
            - 'Windows\Temp\'
            - '&1'
    condition: 1 of selection_*
falsepositives:
    - Unknown
level: high

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("Parent Process Path") LIKE '%\wmiprvse.exe' OR LOWER("Parent Process Path") LIKE '%\mmc.exe' OR LOWER("Parent Process Path") LIKE '%\explorer.exe' OR LOWER("Parent Process Path") LIKE '%\services.exe') AND (LOWER(Command) LIKE '%cmd.exe%' AND LOWER(Command) LIKE '%/q%' AND LOWER(Command) LIKE '%/c%' AND LOWER(Command) LIKE '%\\127.0.0.1\%' AND LOWER(Command) LIKE '%&1%')) OR ((LOWER("Parent Command") LIKE '%svchost.exe -k netsvcs%' OR LOWER("Parent Command") LIKE '%taskeng.exe%') AND (LOWER(Command) LIKE '%cmd.exe%' AND LOWER(Command) LIKE '%/c%' AND LOWER(Command) LIKE '%windows\temp\%' AND LOWER(Command) LIKE '%&1%')))

QRadar CRE

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

Rule name
OffSet7: HackTool - Potential Impacket Lateral Movement Activity
Rule type
Event rule (Local)
Log source types
Microsoft Windows Security Event Log DSM: Security 4688 (with command-line auditing) or Sysmon EID 1

Building blocks

  • BB:OffSet7:HackTool Potential Impacket Lateral Movement Act:selection_other (match)
    All test lines must match (AND).
    • Parent Process Path ends with: \wmiprvse.exe, \mmc.exe, \explorer.exe, \services.exe
    • Command contains: cmd.exe, /Q, /c, \\\\127.0.0.1\\, &1
  • BB:OffSet7:HackTool Potential Impacket Lateral Movement Act:selection_atexec (match)
    All test lines must match (AND).
    • Parent Command contains: svchost.exe -k netsvcs, taskeng.exe
    • Command contains: cmd.exe, /C, Windows\Temp\, &1

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: Security 4688 (with command-line auditing) or Sysmon EID 1
  2. when an event matches the condition built from these building blocks: (ANY of [BB:OffSet7:HackTool Potential Impacket Lateral Movement Act:selection_other, BB:OffSet7:HackTool Potential Impacket Lateral Movement Act:selection_atexec])

Main rule, option B (AQL filter test)

  1. when the event matches this AQL filter query: devicetype=12 AND (((LOWER("Parent Process Path") LIKE '%\wmiprvse.exe' OR LOWER("Parent Process Path") LIKE '%\mmc.exe' OR LOWER("Parent Process Path") LIKE '%\explorer.exe' OR LOWER("Parent Process Path") LIKE '%\services.exe') AND (LOWER(Command) LIKE '%cmd.exe%' AND LOWER(Command) LIKE '%/q%' AND LOWER(Command) LIKE '%/c%' AND LOWER(Command) LIKE '%\\127.0.0.1\%' AND LOWER(Command) LIKE '%&1%')) OR ((LOWER("Parent Command") LIKE '%svchost.exe -k netsvcs%' OR LOWER("Parent Command") LIKE '%taskeng.exe%') AND (LOWER(Command) LIKE '%cmd.exe%' AND LOWER(Command) LIKE '%/c%' AND LOWER(Command) LIKE '%windows\temp\%' AND LOWER(Command) LIKE '%&1%')))

Rule response

  • Severity 7, credibility 8, 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.

((ParentImage IN ("*\\wmiprvse.exe", "*\\mmc.exe", "*\\explorer.exe", "*\\services.exe")) CommandLine="*cmd.exe*" CommandLine="*/Q*" CommandLine="*/c*" CommandLine="*\\\\127.0.0.1\\*" CommandLine="*&1*") OR ((ParentCommandLine IN ("*svchost.exe -k netsvcs*", "*taskeng.exe*")) CommandLine="*cmd.exe*" CommandLine="*/C*" CommandLine="*Windows\\Temp\\*" CommandLine="*&1*")

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

[HackTool - Potential Impacket Lateral Movement Activity]
description = Detects wmiexec/dcomexec/atexec/smbexec from Impacket framework
search = ((ParentImage IN ("*\\wmiprvse.exe", "*\\mmc.exe", "*\\explorer.exe", "*\\services.exe")) CommandLine="*cmd.exe*" CommandLine="*/Q*" CommandLine="*/c*" CommandLine="*\\\\127.0.0.1\\*" CommandLine="*&1*") OR ((ParentCommandLine IN ("*svchost.exe -k netsvcs*", "*taskeng.exe*")) CommandLine="*cmd.exe*" CommandLine="*/C*" CommandLine="*Windows\\Temp\\*" CommandLine="*&1*")

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.

imProcessCreate
| where (((ParentProcessName endswith "\\wmiprvse.exe" or ParentProcessName endswith "\\mmc.exe" or ParentProcessName endswith "\\explorer.exe" or ParentProcessName endswith "\\services.exe") or (ActingProcessName endswith "\\wmiprvse.exe" or ActingProcessName endswith "\\mmc.exe" or ActingProcessName endswith "\\explorer.exe" or ActingProcessName endswith "\\services.exe")) and (TargetProcessCommandLine contains "cmd.exe" and TargetProcessCommandLine contains "/Q" and TargetProcessCommandLine contains "/c" and TargetProcessCommandLine contains "\\\\127.0.0.1\\" and TargetProcessCommandLine contains "&1")) or ((ActingProcessCommandLine contains "svchost.exe -k netsvcs" or ActingProcessCommandLine contains "taskeng.exe") and (TargetProcessCommandLine contains "cmd.exe" and TargetProcessCommandLine contains "/C" and TargetProcessCommandLine contains "Windows\\Temp\\" and TargetProcessCommandLine contains "&1"))

Defender XDR

Microsoft Defender XDR KQLHunting query

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

DeviceProcessEvents
| where ((InitiatingProcessFolderPath endswith "\\wmiprvse.exe" or InitiatingProcessFolderPath endswith "\\mmc.exe" or InitiatingProcessFolderPath endswith "\\explorer.exe" or InitiatingProcessFolderPath endswith "\\services.exe") and (ProcessCommandLine contains "cmd.exe" and ProcessCommandLine contains "/Q" and ProcessCommandLine contains "/c" and ProcessCommandLine contains "\\\\127.0.0.1\\" and ProcessCommandLine contains "&1")) or ((InitiatingProcessCommandLine contains "svchost.exe -k netsvcs" or InitiatingProcessCommandLine contains "taskeng.exe") and (ProcessCommandLine contains "cmd.exe" and ProcessCommandLine contains "/C" and ProcessCommandLine contains "Windows\\Temp\\" and ProcessCommandLine contains "&1"))

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.

((process.parent.executable:(*\\wmiprvse.exe OR *\\mmc.exe OR *\\explorer.exe OR *\\services.exe)) AND (process.command_line:*cmd.exe* AND process.command_line:*\/Q* AND process.command_line:*\/c* AND process.command_line:*\\\\127.0.0.1\\* AND process.command_line:*\&1*)) OR ((process.parent.command_line:(*svchost.exe\ \-k\ netsvcs* OR *taskeng.exe*)) AND (process.command_line:*cmd.exe* AND process.command_line:*\/C* AND process.command_line:*Windows\\Temp\\* AND process.command_line:*\&1*))

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 ((process.parent.executable like~ ("*\\wmiprvse.exe", "*\\mmc.exe", "*\\explorer.exe", "*\\services.exe")) and (process.command_line:"*cmd.exe*" and process.command_line:"*/Q*" and process.command_line:"*/c*" and process.command_line:"*\\\\127.0.0.1\\*" and process.command_line:"*&1*")) or ((process.parent.command_line like~ ("*svchost.exe -k netsvcs*", "*taskeng.exe*")) and (process.command_line:"*cmd.exe*" and process.command_line:"*/C*" and process.command_line:"*Windows\\Temp\\*" and process.command_line:"*&1*"))

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 (ends_with(process.parent.executable, "\\wmiprvse.exe") or ends_with(process.parent.executable, "\\mmc.exe") or ends_with(process.parent.executable, "\\explorer.exe") or ends_with(process.parent.executable, "\\services.exe")) and process.command_line like "*cmd.exe*" and process.command_line like "*/Q*" and process.command_line like "*/c*" and process.command_line like "*\\\\\\\\127.0.0.1\\\\*" and process.command_line like "*&1*" or (process.parent.command_line like "*svchost.exe -k netsvcs*" or process.parent.command_line like "*taskeng.exe*") and process.command_line like "*cmd.exe*" and process.command_line like "*/C*" and process.command_line like "*Windows\\\\Temp\\\\*" and process.command_line like "*&1*"

Required telemetry

Log source
product: windows · category: process_creation
Fields used
CommandLine ParentCommandLine ParentImage

False positives

  • Unknown

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
Ecco, oscd.community, Jonhnathan Ribeiro, Tim Rauch
Source
SigmaHQ · rules/windows/process_creation/proc_creation_win_hktl_impacket_lateral_movement.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