T1059.004 Splunk · SPL

Detect Unix Shell in Splunk

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/

SPL Detection Query

Splunk (SPL)
spl
index=linux OR index=syslog sourcetype="syslog" OR sourcetype="linux:auditd"
  ("bash" OR "sh" OR "zsh" OR "dash" OR "/bin/bash" OR "/bin/sh")
| eval ReverseShell=if(match(_raw, "(/dev/tcp/|nc\s+-e\s+/bin/|ncat\s+-e|socat\s+exec:)"), 1, 0)
| eval CurlPipe=if(match(_raw, "(curl.*\|\s*(ba)?sh|wget.*\|\s*(ba)?sh)"), 1, 0)
| eval Base64Decode=if(match(_raw, "(base64\s+(-d|--decode))"), 1, 0)
| eval PrivEsc=if(match(_raw, "(chmod\s+\+s|chmod\s+4755|useradd|usermod\s+-aG)"), 1, 0)
| eval SuspicionScore=ReverseShell*3 + CurlPipe*2 + Base64Decode + PrivEsc*2
| where SuspicionScore > 0
| table _time, host, user, _raw, ReverseShell, CurlPipe, Base64Decode, PrivEsc, SuspicionScore
| sort - SuspicionScore, - _time
high severity high confidence

Detects suspicious Unix shell activity from syslog or auditd logs. Identifies reverse shells, curl/wget pipe-to-shell execution, base64 decoding, and privilege escalation commands. Uses weighted suspicion scoring — reverse shells score highest (3) due to confirmed compromise, followed by privilege escalation (2) and curl-pipe (2).

Data Sources

Process: Process CreationCommand: Command ExecutionSyslogLinux auditd

Required Sourcetypes

sysloglinux:auditd

False Positives & Tuning

  • DevOps tools and CI/CD pipelines that use curl|bash patterns for software installation
  • System administrators running legitimate setup scripts that decode base64-encoded configuration
  • Configuration management tools (Ansible, Chef, Puppet, SaltStack) executing shell commands remotely
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