Suspicious Powershell Keylogging (via ps_script)

This rule detects threat actors may log user keystrokes to intercept credentials as the user types them.

SigmamediumWindowsv1
sigma
title: Suspicious Powershell Keylogging (via ps_script)
id: 299c3858-8eb9-5cb2-a971-68019691801e
status: stable
description: This rule detects threat actors may log user keystrokes to intercept credentials as the user types them.
references:
    - https://attack.mitre.org/techniques/T1056/001/
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1218/T1218.md
    - https://github.com/redcanaryco/atomic-red-team/blob/f339e7da7d05f6057fdfcdd3742bfcf365fee2a9/atomics/T1056.001/src/Get-Keystrokes.ps1
author: Huntrule Team
date: 2026-04-24
tags:
    - attack.credential-access
    - attack.collection
    - attack.t1056.001
logsource:
    product: windows
    category: ps_script
    definition: 'Requirements: Script Block Logging must be enabled'
detection:
    selection_basic:
        ScriptBlockText|contains: 'Get-Keystrokes'
    selection_high:
        ScriptBlockText|contains|all:
            - 'Get-ProcAddress user32.dll GetAsyncKeyState'
            - 'Get-ProcAddress user32.dll GetForegroundWindow'
    condition: 1 of selection_*
falsepositives:
    - Unknown
level: medium

Known false positives

  • Unknown

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.