Detection rules › Sigma
Python Inline Command Execution
Detects execution of python using the "-c" flag. This is could be used as a way to launch a reverse shell or execute live python code.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Execution | T1059 Command and Scripting Interpreter |
Event coverage
| Provider | Event ID | Title |
|---|---|---|
| Sysmon | 1 | Process creation |
Stages and Predicates
Stage 1: all of selection_img
or:
Image|endswith: python.exe
Image|endswith: python2.exe
Image|endswith: python3.exe
OriginalFileName: python.exe
Stage 2: all of selection_cli
CommandLine|contains: ' -c'
Stage 3: not 1 of filter_main_*
or:
or:
ParentImage|startswith: 'C:\Program Files (x86)\Python'
ParentImage|startswith: 'C:\Program Files\Python'
CommandLine|contains: '--upgrade', 'pip'
CommandLine|contains: '-W ignore::DeprecationWarning'
CommandLine|contains: '[''install'', ''--no-cache-dir'', ''--no-index'', ''--find-links'','
or:
ParentImage|startswith: 'C:\Program Files (x86)\Python'
ParentImage|startswith: 'C:\Program Files\Python'
ParentCommandLine|contains: '-E -s -m ensurepip -U --default-pip'
ParentImage|endswith: '\python.exe'
Stage 4: not 1 of filter_optional_*
or:
CommandLine|contains: '<pip-setuptools-caller>'
CommandLine|contains: 'exec(compile('
ParentImage|endswith: '\AppData\Local\Programs\Microsoft VS Code\Code.exe'
ParentImage: 'C:\Program Files (x86)\Microsoft VS Code\Code.exe'
ParentImage: 'C:\Program Files\Microsoft VS Code\Code.exe'
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
| Field | Kind | Values |
|---|---|---|
CommandLine | match |
|
Image | ends_with |
|
OriginalFileName | eq |
|
ParentCommandLine | match |
|
ParentImage | ends_with |
|
ParentImage | eq |
|
ParentImage | starts_with |
|