Detection rules › Sigma

Invocation Of Crypto-Classes From The "Cryptography" PowerShell Namespace

Status
test
Severity
medium
Log source
product windows, category process_creation
Author
Andreas Braathen (mnemonic.io)
Source
github.com/SigmaHQ/sigma

Detects the invocation of PowerShell commands with references to classes from the "System.Security.Cryptography" namespace. The PowerShell namespace "System.Security.Cryptography" provides classes for on-the-fly encryption and decryption. These can be used for example in decrypting malicious payload for defense evasion.

MITRE ATT&CK coverage

Event coverage

ProviderEventTitle
SysmonEvent ID 1Process creation

Rule body yaml

title: Invocation Of Crypto-Classes From The "Cryptography" PowerShell Namespace
id: ad856965-f44d-42a8-945e-bbf7bd03d05a
status: test
description: |
    Detects the invocation of PowerShell commands with references to classes from the "System.Security.Cryptography" namespace.
    The PowerShell namespace "System.Security.Cryptography" provides classes for on-the-fly encryption and decryption.
    These can be used for example in decrypting malicious payload for defense evasion.
references:
    - https://learn.microsoft.com/en-us/dotnet/api/system.security.cryptography?view=net-8.0
    - https://blogs.vmware.com/security/2023/11/jupyter-rising-an-update-on-jupyter-infostealer.html
    - https://www.virustotal.com/gui/file/39102fb7bb6a74a9c8cb6d46419f9015b381199ea8524c1376672b30fffd69d2
author: Andreas Braathen (mnemonic.io)
date: 2023-12-01
tags:
    - attack.execution
    - attack.stealth
    - attack.t1059.001
    - attack.t1027.010
    - detection.threat-hunting
logsource:
    product: windows
    category: process_creation
detection:
    selection_img:
        - Image|endswith:
              - '\powershell.exe'
              - '\pwsh.exe'
        - OriginalFileName:
              - 'PowerShell.EXE'
              - 'pwsh.dll'
    selection_cmdlet_namespace:
        CommandLine|contains: 'System.Security.Cryptography.'
    selection_cmdlet_classes:
        CommandLine|contains:
            - '.AesCryptoServiceProvider'
            - '.DESCryptoServiceProvider'
            - '.DSACryptoServiceProvider'
            - '.RC2CryptoServiceProvider'
            - '.Rijndael'
            - '.RSACryptoServiceProvider'
            - '.TripleDESCryptoServiceProvider'
    condition: all of selection_*
falsepositives:
    - Classes are legitimately used, but less so when e.g. parents with low prevalence or decryption of content in temporary folders.
level: medium

Stages and Predicates

Stage 0: condition

all of selection_*

Stage 1: selection_img

selection_img:
    - Image|endswith:
          - '\powershell.exe'
          - '\pwsh.exe'
    - OriginalFileName:
          - 'PowerShell.EXE'
          - 'pwsh.dll'

Stage 2: selection_cmdlet_namespace

selection_cmdlet_namespace:
    CommandLine|contains: 'System.Security.Cryptography.'

Stage 3: selection_cmdlet_classes

selection_cmdlet_classes:
    CommandLine|contains:
        - '.AesCryptoServiceProvider'
        - '.DESCryptoServiceProvider'
        - '.DSACryptoServiceProvider'
        - '.RC2CryptoServiceProvider'
        - '.Rijndael'
        - '.RSACryptoServiceProvider'
        - '.TripleDESCryptoServiceProvider'

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
  • .AesCryptoServiceProvider
  • .DESCryptoServiceProvider
  • .DSACryptoServiceProvider
  • .RC2CryptoServiceProvider
  • .RSACryptoServiceProvider
  • .Rijndael
  • .TripleDESCryptoServiceProvider
  • System.Security.Cryptography.
Imageends_with
  • \powershell.exe corpus 182 (sigma 182)
  • \pwsh.exe corpus 168 (sigma 168)
OriginalFileNameeq
  • PowerShell.EXE corpus 120 (sigma 84, splunk 30, elastic 6)
  • pwsh.dll corpus 112 (sigma 79, splunk 30, elastic 3)