Powershell Token Obfuscation - Powershell
Detects TOKEN OBFUSCATION technique from Invoke-Obfuscation
Sigma rule (View on GitHub)
1title: Powershell Token Obfuscation - Powershell
2id: f3a98ce4-6164-4dd4-867c-4d83de7eca51
3related:
4 - id: deb9b646-a508-44ee-b7c9-d8965921c6b6
5 type: similar
6status: test
7description: Detects TOKEN OBFUSCATION technique from Invoke-Obfuscation
8references:
9 - https://github.com/danielbohannon/Invoke-Obfuscation
10author: frack113
11date: 2022-12-27
12modified: 2023-03-24
13tags:
14 - attack.defense-evasion
15 - attack.t1027.009
16logsource:
17 product: windows
18 category: ps_script
19 definition: 'Requirements: Script Block Logging must be enabled'
20detection:
21 selection:
22 # Examples:
23 # IN`V`o`Ke-eXp`ResSIOn (Ne`W-ob`ject Net.WebClient).DownloadString
24 # &('In'+'voke-Expressi'+'o'+'n') (.('New-Ob'+'jec'+'t') Net.WebClient).DownloadString
25 # &("{2}{3}{0}{4}{1}"-f 'e','Expression','I','nvok','-') (&("{0}{1}{2}"-f'N','ew-O','bject') Net.WebClient).DownloadString
26 - ScriptBlockText|re: '\w+`(\w+|-|.)`[\w+|\s]'
27 # - ScriptBlockText|re: '\((\'(\w|-|\.)+\'\+)+\'(\w|-|\.)+\'\)' TODO: fixme
28 - ScriptBlockText|re: '"(\{\d\}){2,}"\s*-f' # trigger on at least two placeholders. One might be used for legitimate string formatting
29 # ${e`Nv:pATh}
30 - ScriptBlockText|re: '(?i)\$\{`?e`?n`?v`?:`?p`?a`?t`?h`?\}'
31 filter_envpath:
32 ScriptBlockText|contains: '${env:path}' # TODO: Fix this. See https://github.com/SigmaHQ/sigma/pull/4964
33 filter_chocolatey:
34 ScriptBlockText|contains:
35 - 'it will return true or false instead' # Chocolatey install script https://github.com/chocolatey/chocolatey
36 - 'The function also prevents `Get-ItemProperty` from failing' # https://docs.chocolatey.org/en-us/create/functions/get-uninstallregistrykey
37 filter_exchange:
38 Path|startswith: 'C:\Program Files\Microsoft\Exchange Server\'
39 Path|endswith: '\bin\servicecontrol.ps1'
40 ScriptBlockText|contains: '`r`n'
41 condition: selection and not 1 of filter_*
42falsepositives:
43 - Unknown
44level: high
References
Related rules
- Powershell Token Obfuscation - Process Creation
- AD Object WriteDAC Access
- ADS Zone.Identifier Deleted By Uncommon Application
- AMSI Bypass Pattern Assembly GetType
- APT PRIVATELOG Image Load Pattern