T1059.006 Google Chronicle · YARA-L

Detect Python in Google Chronicle

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/

YARA-L Detection Query

Google Chronicle (YARA-L)
yaral
rule t1059_006_python_suspicious_execution {
  meta:
    author = "Argus Detection Engineering"
    description = "Detects suspicious Python interpreter execution patterns associated with MITRE ATT&CK T1059.006 including reverse shells, download-and-execute, subprocess abuse, and dynamic code execution."
    mitre_attack_tactic = "Execution"
    mitre_attack_technique = "T1059.006"
    severity = "HIGH"
    confidence = "MEDIUM"
    version = "1.0"
    created = "2026-04-17"

  events:
    $e.metadata.event_type = "PROCESS_LAUNCH"
    $e.principal.process.file.full_path = /(?i)(python|python3|python3\.exe|python\.exe|pythonw\.exe)$/
    (
      $e.target.process.command_line = /(?i)(socket\.socket|pty\.spawn|\/bin\/sh|\/bin\/bash|reverse_shell|reverse_tcp)/ or
      $e.target.process.command_line = /(?i)(urllib|requests\.get|requests\.post|http\.client)/ or
      $e.target.process.command_line = /(?i)(subprocess\.(call|popen|run)|os\.system|os\.popen)/ or
      $e.target.process.command_line = /(?i)(exec\(|eval\(|compile\(|__import__)/ or
      $e.target.process.command_line = /(?i)(base64\.b64decode|codecs\.decode)/ or
      $e.target.process.command_line = /(?i)(pyinstaller|py2exe|nuitka)/
    )

  condition:
    $e
}
high severity medium confidence

Chronicle YARA-L 2.0 rule detecting suspicious Python interpreter invocations for T1059.006. Matches PROCESS_LAUNCH events where the executing binary is a Python interpreter and the command line contains patterns associated with reverse shells (socket.socket, pty.spawn), network download-and-execute (urllib, requests), subprocess abuse (os.system, subprocess.Popen), dynamic code execution (exec, eval, compile, __import__), obfuscation (base64, codecs), or binary packing (pyinstaller, py2exe, nuitka). Uses UDM principal/target process fields.

Data Sources

Google Chronicle UDM PROCESS_LAUNCH eventsEndpoint telemetry forwarded to Chronicle via forwarders (Windows Sysmon, CrowdStrike, Carbon Black)Linux auditd process execution events normalized to UDM

Required Tables

UDM events (metadata.event_type = PROCESS_LAUNCH)

False Positives & Tuning

  • Legitimate DevOps automation using Ansible, SaltStack, or Fabric that execute subprocess calls or network requests as part of infrastructure management
  • Data engineering pipelines using Python to download and process datasets using urllib or requests (ETL jobs, ML training workflows)
  • Application packaging workflows in CI/CD environments using PyInstaller or Nuitka to compile Python apps into distributable binaries
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