T1059.004 Google Chronicle · YARA-L

Detect Unix Shell in Google Chronicle

Adversaries may abuse Unix shell commands and scripts for execution. Unix shells are the primary command prompt on Linux, macOS, and ESXi systems, though many variations exist (sh, ash, bash, zsh, etc.). Unix shells can control every aspect of a system, with certain commands requiring elevated privileges. Adversaries may abuse Unix shells to execute various commands or payloads, access interactive shells through C2 channels, leverage shell scripts for persistence, or use stripped-down shells via Busybox on embedded devices and ESXi servers.

MITRE ATT&CK

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

YARA-L Detection Query

Google Chronicle (YARA-L)
yaral
rule unix_shell_suspicious_execution {
  meta:
    author = "Argus Detection Engineering"
    description = "Detects suspicious Unix shell commands indicative of reverse shells, piped remote code execution, base64 payload delivery, SUID manipulation, and privilege escalation (MITRE ATT&CK T1059.004)"
    mitre_attack_technique = "T1059.004"
    mitre_attack_tactic = "Execution"
    severity = "HIGH"
    confidence = "HIGH"
    version = "1.0"

  events:
    $e.metadata.event_type = "PROCESS_LAUNCH"
    $e.target.process.file.full_path = /\/(bash|sh|zsh|dash|ash|ksh|csh|tcsh|busybox)$/
    (
      $e.target.process.command_line = /\/dev\/(tcp|udp)\/[0-9]+\.[0-9]+/ or
      $e.target.process.command_line = /bash\s+-i\s+>&\s+\/dev\/tcp/ or
      $e.target.process.command_line = /nc(at)?\s+-e\s+\/bin\// or
      $e.target.process.command_line = /socat\s+exec:/ or
      $e.target.process.command_line = /curl.+\|\s*(ba)?sh/ or
      $e.target.process.command_line = /wget.+\|\s*(ba)?sh/ or
      $e.target.process.command_line = /base64\s+(--decode|-d)/ or
      $e.target.process.command_line = /mkfifo\s+\/tmp\// or
      $e.target.process.command_line = /mknod\s+\/tmp\// or
      $e.target.process.command_line = /chmod\s+(\+s|4755|u\+s)/ or
      $e.target.process.command_line = /useradd|usermod\s+-aG/ or
      $e.target.process.command_line = /iptables\s+(-F|-P\s+ACCEPT)/ or
      $e.target.process.command_line = /python3?\s+-c\s+['"]import socket/ or
      $e.target.process.command_line = /perl\s+-e\s+['"]use Socket/
    )

  condition:
    $e
}
high severity high confidence

Chronicle YARA-L 2.0 rule detecting suspicious Unix shell command execution patterns matching T1059.004. Triggers on process launch events where bash, sh, zsh, dash, ash, ksh, csh, tcsh, or busybox is the executable and the command line contains indicators of reverse shell activity, piped remote code execution, base64 payload staging, named pipe creation, SUID bit manipulation, unauthorized user management, or firewall rule deletion.

Data Sources

Google Chronicle UDMLinux endpoint telemetry (via Chronicle forwarder)Syslog ingestion into ChronicleEDR integration (CrowdStrike, Carbon Black)

Required Tables

UDM Events (process launch type)

False Positives & Tuning

  • Automated deployment pipelines using curl | bash to pull and execute installer scripts for legitimate software such as Docker, Node.js, or Python virtual environments
  • Security testing tools like Metasploit or custom red team frameworks executing staged payloads during authorized penetration tests on systems in the environment
  • System administrators using netcat for legitimate network diagnostics or data transfer between trusted hosts on internal networks
Download portable Sigma rule (.yml)

Other platforms for T1059.004


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 1Bash Reverse Shell via /dev/tcp

    Expected signal: Auditd: EXECVE record for bash with /dev/tcp in arguments. Syslog: bash process creation. Network connection attempt to 127.0.0.1:4444 (will fail without listener). MDE DeviceProcessEvents on managed Linux endpoints.

  2. Test 2Curl Pipe to Bash

    Expected signal: Auditd: EXECVE records for curl and bash. Process tree shows curl piped to bash. Network connection attempt to 127.0.0.1:8080 (will fail without listener). The curl failure means no content reaches bash.

  3. Test 3Base64 Encoded Command Execution

    Expected signal: Auditd: EXECVE records for echo, base64, and bash. The decoded content 'whoami' will be executed. Syslog captures the process chain.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections