Sigma rule: Powershell Token Obfuscation - Powershell

A detection rule from the SigmaHQ repository, shown as its author published it. Dataset version ref-e8dd461d6854, updated 2025-10-19T00:00:00.000Z.

Rule

Title
Powershell Token Obfuscation - Powershell
Status
test
Level
medium
Author
frack113
Date
2022-12-27
Modified
2025-10-19
File
rules-threat-hunting/windows/powershell/powershell_script/posh_ps_token_obfuscation.yml
Commit
ccbb0369507f796db0b0ae6854c8a2be471b9d84

Detects TOKEN OBFUSCATION technique from Invoke-Obfuscation in Powershell scripts.
Use this rule as a threat-hunting baseline to find obfuscated scripts in your environment.
Once tested and tuned, consider deploying a production detection rule based on this hunting rule.

Log source

product
windows
category
ps_script
definition
Requirements: Script Block Logging must be enabled

Detection

selection:
    # Examples:
    #   IN`V`o`Ke-eXp`ResSIOn (Ne`W-ob`ject Net.WebClient).DownloadString
    #   &('In'+'voke-Expressi'+'o'+'n') (.('New-Ob'+'jec'+'t') Net.WebClient).DownloadString
    #   &("{2}{3}{0}{4}{1}"-f 'e','Expression','I','nvok','-') (&("{0}{1}{2}"-f'N','ew-O','bject') Net.WebClient).DownloadString
    - ScriptBlockText|re: '\w+`(\w+|-|.)`[\w+|\s]'
    # - ScriptBlockText|re: '\((\'(\w|-|\.)+\'\+)+\'(\w|-|\.)+\'\)' TODO: fixme
    - ScriptBlockText|re: '"(\{\d\}){2,}"\s*-f'  # trigger on at least two placeholders. One might be used for legitimate string formatting
    #   ${e`Nv:pATh}
    - ScriptBlockText|re: '(?i)\$\{`?e`?n`?v`?:`?p`?a`?t`?h`?\}'
filter_envpath:
    ScriptBlockText|contains: '${env:path}' # TODO: Fix this. See https://github.com/SigmaHQ/sigma/pull/4964
filter_chocolatey:
    ScriptBlockText|contains:
        - 'it will return true or false instead'  # Chocolatey install script https://github.com/chocolatey/chocolatey
        - 'The function also prevents `Get-ItemProperty` from failing' # https://docs.chocolatey.org/en-us/create/functions/get-uninstallregistrykey
filter_exchange:
    Path|startswith: 'C:\Program Files\Microsoft\Exchange Server\'
    Path|endswith: '\bin\servicecontrol.ps1'
    ScriptBlockText|contains: '`r`n'
condition: selection and not 1 of filter_*

False positives (as the rule lists them)

  • Edge case might be possible with heavy use of string formatting or obfuscation in legitimate scripts.

Tags

  • attack.stealth
  • attack.t1027.009
  • detection.threat-hunting

MITRE ATT&CK ids this rule names

Related rules

References

Read on 2026-11-03T00:58:21.399Z under licence sigma-drl-1.1@d5f4c36a from https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules-threat-hunting/windows/powershell/powershell_script/posh_ps_token_obfuscation.yml

Sources and licences

  • SigmaHQ

    "Powershell Token Obfuscation - Powershell" by frack113 (SigmaHQ). Rule: https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules-threat-hunting/windows/powershell/powershell_script/posh_ps_token_obfuscation.yml.
    Licensed under the Detection Rule License (DRL) 1.1: https://github.com/SigmaHQ/Detection-Rule-License

    Detection Rule License (DRL) 1.1

Cite this page

Dragons Eye Ransomware Tracker, "Sigma rule: Powershell Token Obfuscation - Powershell",
entity page, dataset version ref-e8dd461d6854, updated 2025-10-19T00:00:00.000Z,
https://ransomware-tracker.com/detections/sigma/f3a98ce4-6164-4dd4-867c-4d83de7eca51 (accessed 2026-11-03).
Underlying source: SigmaHQ rule f3a98ce4-6164-4dd4-867c-4d83de7eca51, commit ccbb0369507f796db0b0ae6854c8a2be471b9d84.

Pages change. The dataset version identifies the data, but no archive of old versions is kept, so this citation cannot be replayed later.