Detectionhightest
Potential WinAPI Calls Via PowerShell Scripts
Detects usage of WinAPI functions in PowerShell scripts. It may indicate attempts to perform actions such as process injection, token stealing, or other malicious activities that leverage Windows API calls. These techniques are commonly used to evade traditional file-based detections by loading and executing code directly in memory.
Nasreddine Bencherchali, Nikita Nazarov, oscd.communityCreated 2020-10-06Updated 2026-04-2903d83090-8cba-44a0-b02f-0b756a050306windows
Log Source
WindowsPowerShell Script
ProductWindows← raw: windows
CategoryPowerShell Script← raw: ps_script
Definition
Requirements: Script Block Logging must be enabled
Detection Logic
Detection Logic5 selectors
detection:
# Note: Add more suspicious combinations in the form of different selections
selection_injection:
ScriptBlockText|contains|all:
- 'VirtualAlloc'
- 'OpenProcess'
- 'WriteProcessMemory'
- 'CreateRemoteThread'
selection_token_steal:
ScriptBlockText|contains|all:
- 'OpenProcessToken'
- 'LookupPrivilegeValue'
- 'AdjustTokenPrivileges'
selection_duplicate_token:
ScriptBlockText|contains|all:
- 'OpenProcessToken'
- 'DuplicateTokenEx'
- 'CloseHandle'
selection_process_write_read:
ScriptBlockText|contains|all:
- 'WriteProcessMemory'
- 'VirtualAlloc'
- 'ReadProcessMemory'
- 'VirtualFree'
selection_local_shellcode_injection:
ScriptBlockText|contains|all:
- 'VirtualAlloc'
- 'GetDelegateForFunctionPointer'
- 'Marshal.Copy'
condition: 1 of selection_*False Positives
Unknown
False positive likelihood has not been assessed. Additional context may be needed during triage.
References
MITRE ATT&CK
Sub-techniques
Rule Metadata
Rule ID
03d83090-8cba-44a0-b02f-0b756a050306
Status
test
Level
high
Type
Detection
Created
2020-10-06
Modified
2026-04-29
Path
rules/windows/powershell/powershell_script/posh_ps_win_api_susp_access.yml
Raw Tags
attack.executionattack.t1059.001attack.t1106attack.stealthattack.t1620