Detection rules › Kusto

Detect Unknown process using SMB or WinRM

Author
Robbe Van den Daele
Source
github.com/HybridBrothers/Hunting-Queries-Detection-Rules

WinRM and SMB are popular network protocols to perform lateral movement by adversaries (while there are some others as well). When an unknown process is performing SMB or WinRM network connections, this might indicate that a malware process is trying to move laterally to other devices in your network. > [!WARNING] > This detection rule is the base for the detection. You will need to add environment specific finetuning in order to limit the BP detections on legitimate processes

MITRE ATT&CK coverage

References

Event coverage

Rule body yaml

DeviceNetworkEvents
| where TimeGenerated > ago(1h)
| where RemotePort in ("5985", "5986", "445")
| where ActionType in~ ("ConnectionSuccess", "ConnectionAttempt",
"ConnectionFailed", "ConnectionRequest")
| where isnotempty(InitiatingProcessSHA256)
| invoke FileProfile(InitiatingProcessSHA256)
| where isnotempty(GlobalPrevalence) and GlobalPrevalence < 1000

Stages and Predicates

Stage 1: source

DeviceNetworkEvents

Stage 2: where

| where TimeGenerated > ago(1h)

Stage 3: where

| where RemotePort in ("5985", "5986", "445")

Stage 4: where

| where ActionType in~ ("ConnectionSuccess", "ConnectionAttempt",
"ConnectionFailed", "ConnectionRequest")

Stage 5: where

| where isnotempty(InitiatingProcessSHA256)

Stage 6: invoke

| invoke FileProfile(InitiatingProcessSHA256)

Stage 7: where

| where isnotempty(GlobalPrevalence) and GlobalPrevalence < 1000

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
ActionTypein
  • ConnectionAttempt
  • ConnectionFailed
  • ConnectionRequest
  • ConnectionSuccess corpus 9 (kusto 9)
GlobalPrevalenceis_not_null
  • (no value, null check)
GlobalPrevalencelt
  • 1000 transforms: cased corpus 4 (kusto 4)
InitiatingProcessSHA256is_not_null
  • (no value, null check)
RemotePortin
  • 445 transforms: cased corpus 8 (elastic 5, splunk 2, sigma 1)
  • 5985 transforms: cased corpus 3 (sigma 2, chronicle 1)
  • 5986 transforms: cased corpus 3 (sigma 2, chronicle 1)