Detection rules › Sigma

Potential Remote PowerShell Session Initiated

Status
test
Severity
high
Log source
product windows, category network_connection
Author
Roberto Rodriguez @Cyb3rWard0g
Source
github.com/SigmaHQ/sigma

Detects a process that initiated a network connection over ports 5985 or 5986 from a non-network service account. This could potentially indicates a remote PowerShell connection.

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 3Network connection

Rule body yaml

title: Potential Remote PowerShell Session Initiated
id: c539afac-c12a-46ed-b1bd-5a5567c9f045
status: test
description: |
    Detects a process that initiated a network connection over ports 5985 or 5986 from a non-network service account.
    This could potentially indicates a remote PowerShell connection.
references:
    - https://threathunterplaybook.com/hunts/windows/190511-RemotePwshExecution/notebook.html
author: Roberto Rodriguez @Cyb3rWard0g
date: 2019-09-12
modified: 2024-02-02
tags:
    - attack.execution
    - attack.t1059.001
    - attack.lateral-movement
    - attack.t1021.006
logsource:
    category: network_connection
    product: windows
detection:
    selection:
        DestinationPort:
            - 5985
            - 5986
        Initiated: 'true' # only matches of the initiating system can be evaluated
        SourceIsIpv6: 'false'
    filter_main_service_users:
        - User|contains: # covers many language settings for Network Service. Please expand
              - 'NETWORK SERVICE'
              - 'NETZWERKDIENST'
              - 'SERVICIO DE RED'
              - 'SERVIZIO DI RETE'
        - User|contains|all:
              - 'SERVICE R'
              - 'SEAU'
    filter_main_localhost:
        SourceIp:
            - '::1'
            - '127.0.0.1'
        DestinationIp:
            - '::1'
            - '127.0.0.1'
    filter_optional_avast:
        Image:
            - 'C:\Program Files\Avast Software\Avast\AvastSvc.exe'
            - 'C:\Program Files (x86)\Avast Software\Avast\AvastSvc.exe'
    condition: selection and not 1 of filter_main_* and not 1 of filter_optional_*
falsepositives:
    - Legitimate usage of remote PowerShell, e.g. remote administration and monitoring.
    - Network Service user name of a not-covered localization
level: high

Stages and Predicates

Stage 0: condition

selection and not 1 of filter_main_* and not 1 of filter_optional_*

Stage 1: selection

selection:
    DestinationPort:
        - 5985
        - 5986
    Initiated: 'true'
    SourceIsIpv6: 'false'

Stage 2: not filter_main_*

filter_main_service_users:
    - User|contains:
          - 'NETWORK SERVICE'
          - 'NETZWERKDIENST'
          - 'SERVICIO DE RED'
          - 'SERVIZIO DI RETE'
    - User|contains|all:
          - 'SERVICE R'
          - 'SEAU'
filter_main_localhost:
    SourceIp:
        - '::1'
        - '127.0.0.1'
    DestinationIp:
        - '::1'
        - '127.0.0.1'

Stage 3: not filter_optional_avast

filter_optional_avast:
    Image:
        - 'C:\Program Files\Avast Software\Avast\AvastSvc.exe'
        - 'C:\Program Files (x86)\Avast Software\Avast\AvastSvc.exe'

Exclusions

Top-level NOT(...) conjuncts: predicates this rule actively suppresses.

FieldKindExcluded values
DestinationIpeq127.0.0.1
DestinationIpeq::1
SourceIpeq127.0.0.1
SourceIpeq::1
UsermatchSEAU
UsermatchSERVICE R
UsermatchNETWORK SERVICE
UsermatchNETZWERKDIENST
UsermatchSERVICIO DE RED
UsermatchSERVIZIO DI RETE
ImageeqC:\Program Files (x86)\Avast Software\Avast\AvastSvc.exe
ImageeqC:\Program Files\Avast Software\Avast\AvastSvc.exe

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
DestinationPorteq
  • 5985 corpus 3 (sigma 2, chronicle 1)
  • 5986 corpus 3 (sigma 2, chronicle 1)
Initiatedeq
  • true corpus 50 (sigma 50)
SourceIsIpv6eq
  • false