Sigma rule: WinAPI Function Calls Via PowerShell Scripts
A detection rule from the SigmaHQ repository, shown as its author published it. Dataset version ref-cbe0387c43ba, updated 2023-07-21T00:00:00.000Z.
Rule
- Title
- WinAPI Function Calls Via PowerShell Scripts
- Status
- test
- Level
- medium
- Author
- Nikita Nazarov, oscd.community, Nasreddine Bencherchali (Nextron Systems)
- Date
- 2023-07-21
- File
- rules-threat-hunting/windows/powershell/powershell_script/posh_ps_win_api_library_access.yml
- Commit
- ccbb0369507f796db0b0ae6854c8a2be471b9d84
Detects calls to WinAPI functions from PowerShell scripts. Attackers can often leverage these APIs to avoid detection based on typical PowerShell function calls. Use this rule as a basis to hunt for interesting scripts.
Log source
- product
- windows
- category
- ps_script
- definition
- Requirements: Script Block Logging must be enabled
Detection
selection:
ScriptBlockText|contains:
- 'AddSecurityPackage'
- 'AdjustTokenPrivileges'
- 'CloseHandle'
- 'CreateProcessWithToken'
- 'CreateRemoteThread'
- 'CreateThread'
- 'CreateUserThread'
- 'DangerousGetHandle'
- 'DuplicateTokenEx'
- 'EnumerateSecurityPackages'
- 'FreeLibrary'
- 'GetDelegateForFunctionPointer'
- 'GetLogonSessionData'
- 'GetModuleHandle'
- 'GetProcAddress'
- 'GetProcessHandle'
- 'GetTokenInformation'
- 'ImpersonateLoggedOnUser'
- 'LoadLibrary'
- 'memcpy'
- 'MiniDumpWriteDump'
- 'OpenDesktop'
- 'OpenProcess'
- 'OpenProcessToken'
- 'OpenThreadToken'
- 'OpenWindowStation'
- 'QueueUserApc'
- 'ReadProcessMemory'
- 'RevertToSelf'
- 'RtlCreateUserThread'
- 'SetThreadToken'
- 'VirtualAlloc'
- 'VirtualFree'
- 'VirtualProtect'
- 'WaitForSingleObject'
- 'WriteInt32'
- 'WriteProcessMemory'
- 'ZeroFreeGlobalAllocUnicode'
condition: selectionFalse positives (as the rule lists them)
- This rule is mainly used for hunting and will generate quite a lot of false positives when applied in production. It's best combined with other fields such as the path of execution, the parent process, etc.
Tags
- attack.execution
- attack.t1059.001
- attack.t1106
- detection.threat-hunting
MITRE ATT&CK ids this rule names
Related rules
- ba3f5c1b-6272-4119-9dbd-0bc8d21c2702 (similar)
- 03d83090-8cba-44a0-b02f-0b756a050306 (similar)
- 19d65a1c-8540-4140-8062-8eb00db0bba5 (similar)
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_win_api_library_access.yml
Sources and licences
SigmaHQ
"WinAPI Function Calls Via PowerShell Scripts" by Nikita Nazarov, oscd.community, Nasreddine Bencherchali (Nextron Systems) (SigmaHQ). Rule: https://github.com/SigmaHQ/sigma/blob/ccbb0369507f796db0b0ae6854c8a2be471b9d84/rules-threat-hunting/windows/powershell/powershell_script/posh_ps_win_api_library_access.yml.
Licensed under the Detection Rule License (DRL) 1.1: https://github.com/SigmaHQ/Detection-Rule-License
Cite this page
Dragons Eye Ransomware Tracker, "Sigma rule: WinAPI Function Calls Via PowerShell Scripts",
entity page, dataset version ref-cbe0387c43ba, updated 2023-07-21T00:00:00.000Z,
https://ransomware-tracker.com/detections/sigma/9f22ccd5-a435-453b-af96-bf99cbb594d4 (accessed 2026-11-03).
Underlying source: SigmaHQ rule 9f22ccd5-a435-453b-af96-bf99cbb594d4, 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.