Command and Scripting Interpreter: Python T1059.006

Tactic: Execution

Adversaries may abuse Python commands and scripts for execution. Python is a very popular scripting/programming language, with capabilities to perform many functions. Python can be executed interactively from the command-line (via the python.exe interpreter) or via scripts (.py) that can be written and distributed to different systems. Python code can also be compiled into binary executables.

Events covered

12 catalog events are tagged with this technique by at least one rule.

Authoring guide

Patterns shared across the 54 rules above: which fields they filter on, what specific values they look for, and what they exclude. The catalog normalizes field names across vendors so Sigma's Image, Elastic's process.name, and Splunk's process_name collapse into one row. Each rule contributes at most once per row.

Fields filtered most (54 distinct)

The fields most rules look at when detecting this technique. The How column shows the operators authors use (eq, wildcard, regex_match, match) and how often each appears. Sample values are concrete examples to start from, not an exhaustive list.

FieldRulesHowSample values
event.type38eq 34, in 4start, process_started, change, creation
process_name36in 18, starts_with 18, wildcard 14, eq 13, match 2bash, csh, python, base64, awk
host.os.type33eq 30, in 3
EventType30eq 19, in 12, ne 1exec, ProcessRollup2, exec_event, start, connection_accepted
process.args18eq 12, contains 8, wildcard 8, in 5, starts_with 3, ne 1-c, */bin/*sh*, *import*pty*spawn*, *import*subprocess*call*, *-*d*
parent_process_name16eq 8, in 4, starts_with 4, wildcard 3bash, node, python, Google Chrome, Google Chrome Helper*
CommandLine14contains 12, wildcard 5, is_not_null 1 -c, *-*d*, .decode, b16decode, b64decode
Image14ends_with 5, contains 3, starts_with 3, is_not_null 2, ne 1\cmd.exe, \powershell.exe, /dev/shm/, ./, /bin/lua
ParentImage6ends_with 3, is_not_null 1, ne 1, starts_with 1/bun, /etc/update-motd.d/, /node, /usr/lib/systemd/systemd, \cmd.exe
ParentCommandLine5contains 2, wildcard 2, ne 1 server.js, */sap.com*/servlet_jsp/irj/*, *\sap.com*\servlet_jsp\irj\*, *runner*entrypoint.sh, --experimental-https
TargetFilename5ends_with 3, regex_match 3, wildcard 2.pth, (?i)/lib/python3\.([5-9]|[0-9]{2})/site-packages/, (?i)\\(venv|python(.+)?)\\lib\\site-packages\\, /home/*/.config/python/usercustomize.py, /home/*/.local/lib/python*/site-packages/*
DestinationHostname4is_null 2, wildcard 2, ends_with 1, starts_with 1*.s3*.amazonaws.com, .cloudfront.net, calendar.app.google, eth-mainnet*, eth.*.com
process.args_count4eq 3, ge 21, 3, 2
Esql.event_count3lt 35, 15
container.id3starts_with 3?

Top indicator values (787 distinct)

Specific (field, operator, value) combinations the rules check for, ranked by how many rules under this technique use each one. The Corpus reach column counts how many rules across the entire catalog (any technique) check the same combination. High numbers point to widely-used indicators that are likely noisy on their own; combine them with another condition for useful signal. Blank means the combination is specific to rules under this technique. Click a value to expand the rules under this technique that use it.

FieldKindValueRules (here)Corpus reach
event.typeeq
start
33606
process_namestarts_with
python
1731
process_namestarts_with
ruby
1021
process_namestarts_with
perl
920
process_namewildcard
python*
1424
process_namewildcard
bash
1114
process_namewildcard
php*
1116
process_namewildcard
sh
1114
process_namewildcard
zsh
1013
process_namewildcard
dash
910
process_namewildcard
ksh
910
process_namewildcard
perl*
911
process_namewildcard
tcsh
910
process_namewildcard
curl
816
process_namewildcard
csh
78
process_namewildcard
fish
78
process_namewildcard
lua*
710
EventTypeeq
exec
13171
EventTypein
exec
11171
EventTypein
start
8134
process.argseq
-c
1130
process.argseq
-e
815
process_namein
bash
1188
process_namein
sh
1183
process_namein
zsh
1182
process_namein
dash
978
process_namein
csh
871
process_namein
fish
872
process_namein
ksh
873
process_namein
tcsh
869

Exclusions (223 distinct)

Field/operator/value combinations excluded by rules under this technique (top-level not() clauses), sorted by how many rules exclude each. These are the false-positive paths the community has learned to filter out. A new rule that ignores the high-count entries here will likely fire on the same noisy paths. Click a value to expand the rules under this technique that exclude it.

FieldKindValueRules excluding
dest_ipcidr_match
127.0.0.0/8
4
dest_ipcidr_match
169.254.0.0/16
4
dest_ipcidr_match
224.0.0.0/4
4
dest_ipcidr_match
::1
4
CurrentDirectorywildcard
/opt/zeek
2
CurrentDirectorywildcard
/proc/self/fd/*/usr/local/zeek
2
CurrentDirectorywildcard
/usr/local/zeek
2
CurrentDirectorywildcard
/usr/local/zeek_old_install
2
CurrentDirectorywildcard
/var/lib/docker/overlay2/*/opt/zeek
2
CurrentDirectorywildcard
/var/lib/docker/overlay2/*/usr/local/zeek
2
Imagein
./usr/bin/podman
2
Imagein
/kaniko/executor
2
Imagein
/usr/bin/crio
2
Imagein
/usr/bin/dockerd
2
Imagein
/usr/bin/pacman
2

Rules under this technique

Every rule in the catalog tagged with this technique, grouped by vendor. Click a rule title for its full predicates, exclusions, and indicators.

Platform (all)
Domain (all)

Sigma 11 rules

Elastic 42 rules

Splunk 1 rule