Suspicious Python One-Liner with Encoded Payload Execution
Description
Identifies Python interpreters started with -c (inline code) where the command line suggests decoding obfuscated content (e.g. base64, binascii, codecs) and then executing it via exec, eval, compile, or dynamic import. Also identifies child processes spawned by a parent Python process whose command line matches the same suspicious python -c decode-and-exec pattern, when parent telemetry is present.
Query · eql
process where event.type == "start" and event.action in ("start", "exec") and
(
/* Inline malicious python -c one-liner on this process */
(
process.name : ("python*", "py.exe", "py", "pypy*") and
process.args : "-c" and
process.command_line : (
"*b64decode*",
"*b32decode*",
"*b85decode*",
"*a85decode*",
"*.read().decode(*",
"*binascii*",
"*codecs.decode*",
"*fromhex*",
"*zlib.decompress*",
"*marshal.loads*"
) and
process.command_line : (
"*exec(*",
"*eval(*",
"*__import__*",
"*compile(*",
"*types.FunctionType*",
"*runpy*",
"*importlib.util*",
"*importlib.import_module*"
)
)
or
/* Child of a parent Python process running the same suspicious -c pattern (parent fields populated) */
(
process.parent.name : ("python*", "py.exe", "py", "pypy*") and
process.parent.command_line != null and
process.parent.args : "-c" and
process.parent.command_line : (
"*b64decode*",
"*b32decode*",
"*b85decode*",
"*a85decode*",
"*.read().decode(*",
"*binascii*",
"*codecs.decode*",
"*fromhex*",
"*zlib.decompress*",
"*marshal.loads*"
) and
process.parent.command_line : (
"*exec(*",
"*eval(*",
"*__import__*",
"*compile(*",
"*types.FunctionType*",
"*runpy*",
"*importlib.util*",
"*importlib.import_module*"
)
and not process.executable : "?:\\Windows\\System32\\conhost.exe"
)
) and
not process.parent.executable like~ (
"*/opencode-ai/*/opencode*",
"*/opencode-darwin-arm64/bin/opencode",
"*/opencode-linux-*/bin/opencode"
) and
not process.parent.executable like~ "/Applications/Alfred*.app/*" and
not (process.command_line : (
"*runpy.run_module(\"pip\"*",
"*runpy.run_module('pip'*",
"*ensurepip*"
) and
process.executable like~ (
"*/Python.framework/Versions/*/bin/python*",
"*/Python.framework/Versions/*/Resources/Python.app/Contents/MacOS/Python",
"*/Python3.framework/Versions/*/Resources/Python.app/Contents/MacOS/Python",
"/opt/homebrew/Cellar/python*/*/bin/python*",
"/usr/local/Cellar/python*/*/bin/python*",
"/usr/bin/python*"
)) and
not (process.parent.command_line : (
"*runpy.run_module(\"pip\"*",
"*runpy.run_module('pip'*",
"*ensurepip*"
) and
process.parent.executable like~ (
"*/Python.framework/Versions/*/bin/python*",
"*/Python.framework/Versions/*/Resources/Python.app/Contents/MacOS/Python",
"*/Python3.framework/Versions/*/Resources/Python.app/Contents/MacOS/Python",
"/opt/homebrew/Cellar/python*/*/bin/python*",
"/usr/local/Cellar/python*/*/bin/python*",
"/usr/bin/python*"
)) and
not process.Ext.effective_parent.executable like~ (
"/Applications/Cursor.app/*",
"/Users/*/Applications/Cursor.app/*",
"/Applications/Codex.app/*",
"/Users/*/Applications/Codex.app/*",
"/Users/*/Library/Application Support/Claude/claude-code/*/claude.app/*",
"/Applications/Visual Studio Code.app/Contents/MacOS/Code"
) and
not process.parent.command_line like "*/Users/*/shell-snapshots/snapshot-*"