43 lines
1.9 KiB
YAML
43 lines
1.9 KiB
YAML
title: Powershell Token Obfuscation - Powershell
|
|
id: f3a98ce4-6164-4dd4-867c-4d83de7eca51
|
|
related:
|
|
- id: deb9b646-a508-44ee-b7c9-d8965921c6b6
|
|
type: similar
|
|
status: experimental
|
|
description: Detects TOKEN OBFUSCATION technique from Invoke-Obfuscation
|
|
references:
|
|
- https://github.com/danielbohannon/Invoke-Obfuscation
|
|
author: frack113
|
|
date: 2022/12/27
|
|
modified: 2023/03/24
|
|
tags:
|
|
- attack.defense_evasion
|
|
- attack.t1027.009
|
|
logsource:
|
|
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
|
|
# ${e`Nv:pATh}
|
|
- 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
|
|
- ScriptBlockText|re: '\$\{((e|n|v)*`(e|n|v)*)+:path\}|\$\{((e|n|v)*`(e|n|v)*)+:((p|a|t|h)*`(p|a|t|h)*)+\}|\$\{env:((p|a|t|h)*`(p|a|t|h)*)+\}'
|
|
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_*
|
|
falsepositives:
|
|
- Unknown
|
|
level: high
|