process where host.os.type == "linux" and event.type == "start" and event.action in ("exec", "exec_event", "start") and
(
(process.parent.name : "python*" and process.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh",
"fish") and process.parent.args_count >= 3 and process.parent.args : "*pty.spawn*" and process.parent.args : "-c") or
(process.parent.name : "python*" and process.name in ("bash", "dash", "ash", "sh", "tcsh", "csh", "zsh", "ksh",
"fish") and process.args : "*sh" and process.args_count == 1 and process.parent.args_count == 1)
)
Install detection rules in Elastic Security
Detect Interactive Terminal Spawned via Python in the Elastic Security detection engine by installing this rule into your Elastic Stack.
To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(opens in a new tab or window).