T1059.006 Sumo Logic CSE · Sumo

Detect Python in Sumo Logic CSE

Adversaries may abuse Python commands and scripts for execution. Python is a cross-platform scripting language that can be executed interactively from the command-line (via python.exe/python3), via scripts (.py), or compiled into binary executables. Python's built-in libraries for file operations, networking (socket, urllib, requests), and system interaction make it a powerful tool for adversaries. Threat actors including APT31, APT37, MuddyWater, and Contagious Interview have used Python-based implants, reverse shells, and backdoors across Windows, Linux, macOS, and ESXi environments.

MITRE ATT&CK

Tactic
Execution
Technique
T1059 Command and Scripting Interpreter
Sub-technique
T1059.006 Python
Canonical reference
https://attack.mitre.org/techniques/T1059/006/

Sumo Detection Query

Sumo Logic CSE (Sumo)
sql
(_sourceCategory="*windows*sysmon*" OR _sourceCategory="*linux*audit*" OR _sourceCategory="*endpoint*")
| where EventID = 1 OR type = "EXECVE"
| parse field=CommandLine "*" as cmdline nodrop
| parse field=Image "*" as image nodrop
| where (
    image matches "*python*" OR
    image matches "*python3*" OR
    image matches "*pythonw*"
  )
| toLowerCase(cmdline) as cmdline_lower
| if(cmdline_lower matches "*(socket.socket|pty.spawn|/bin/sh|reverse_shell|reverse_tcp)*", 1, 0) as reverse_shell
| if(cmdline_lower matches "*(urllib|requests.get|http.client)*", 1, 0) as download_exec
| if(cmdline_lower matches "*(subprocess.call|subprocess.popen|subprocess.run|os.system|os.popen)*", 1, 0) as subprocess_exec
| if(cmdline_lower matches "*(exec(|eval(|compile(|__import__)*", 1, 0) as code_exec
| if(cmdline_lower matches "*(base64.b64decode|codecs.decode)*", 1, 0) as obfuscation
| (reverse_shell * 3 + download_exec * 2 + subprocess_exec + code_exec * 2 + obfuscation * 2) as suspicion_score
| where suspicion_score > 0
| fields _messagetime, _sourceHost, user, image, cmdline, ParentImage, reverse_shell, download_exec, subprocess_exec, code_exec, obfuscation, suspicion_score
| sort by suspicion_score desc, _messagetime desc
high severity medium confidence

Detects malicious Python interpreter usage (T1059.006) by correlating Sysmon process create events and Linux auditd EXECVE records. Implements a weighted suspicion scoring model: reverse shell indicators score 3, download-and-execute and dynamic code execution score 2, subprocess abuse scores 1, and obfuscation techniques (base64/codecs) score 2. Only events with a score above 0 are surfaced.

Data Sources

Windows Sysmon via Sumo Logic Installed Collector (Event ID 1)Linux auditd EXECVE events via Sumo Logic Installed CollectorSumo Logic Cloud SIEM (CSE) normalized process events

Required Tables

_sourceCategory=*windows*sysmon*_sourceCategory=*linux*audit*_sourceCategory=*endpoint*

False Positives & Tuning

  • Python-based infrastructure automation scripts (Boto3 AWS SDK usage, Azure SDK) making legitimate API calls via urllib or requests
  • Security scanning tools written in Python (Impacket utilities run by authorized pentesters, Nmap scripting via Python wrappers)
  • Software build pipelines invoking Python packaging tools (PyInstaller, py2exe, Nuitka) for legitimate application compilation
Download portable Sigma rule (.yml)

Other platforms for T1059.006


Testing Methodology

Validate this detection against 3 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.

  1. Test 1Python Reverse Shell One-Liner

    Expected signal: Auditd: EXECVE record for python3 with -c flag and socket.socket in arguments. Network connection attempt to 127.0.0.1:4444. MDE DeviceProcessEvents and DeviceNetworkEvents on managed endpoints.

  2. Test 2Python Download and Execute

    Expected signal: Sysmon Event ID 1: Process Create for python.exe with urllib in CommandLine. Sysmon Event ID 3: Network Connection to 127.0.0.1:8080 (will fail without listener). The exec() call triggers even though download fails.

  3. Test 3Python Subprocess Command Execution

    Expected signal: Sysmon Event ID 1: Process Create for python.exe with subprocess.Popen in CommandLine. Child process event for cmd.exe spawned by python.exe.

Unlock Pro Content

Get the full detection package for T1059.006 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections