Windows Process Creation: Python Executed with the -c Inline Code Flag

Flags Windows executions of python.exe with -c inline code, excluding common installer/baseline and VS Code contexts.

FreeReviewedSigma · Medium · v1
Product
windows
Category
process_creation
Author
Nasreddine Bencherchali (Nextron Systems) (SigmaHQ), DRL 1.1
Published
2023-01-02
Updated
2026-07-30

ATT&CK techniques

Execution
  1. Recon

  2. Resource Dev

  3. Initial Access

  4. Persistence

  5. Priv Esc

  6. Defense Evasion

  7. Cred Access

  8. Discovery

  9. Lateral Movement

  10. Collection

  11. C2

  12. Exfiltration

  13. Impact

What it detects

This rule identifies process creation events where a Python interpreter executable is invoked with the -c option to execute inline Python code. Attackers can use this capability to run arbitrary code immediately from the command line, which can support malicious scripting and payload staging. The detection relies on Windows process creation telemetry, matching python.exe variants and requiring the command line to contain the -c flag while excluding known baseline and development/tooling parent contexts.

Related detections9 linkedT1059 — drag to rearrange
Suspicious Python Execution via Renamed Synaptics Binary
MSBuild Executing Non-Project File or Remote Payload
Possible Ivanti Pulse Connect Secure Command Injection via License Keys-Status Endpoint (via webserver)
Possible Craft CMS RCE via Query-String CLI Option Injection
Possible Aspera Faspex Pre-Auth RCE via YAML Deserialization in package_relay (via webserver)
Possible Sitecore Pre-Auth RCE via Report.ashx Insecure Deserialization (via webserver)
Possible WatchGuard Pre-Auth RCE via agent login XML-RPC CVE-2022-26318
Possible Oracle Opera CGI Webshell Command Execution via operabin
Suspicious tar Extraction of Staged Archive to Temp (via process_creation)
Windows Process Creation: Python Executed with the -c Inline Code Flag
Pivot detection · T1059 · 9 related

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.