LX1.2 Live Response — Volatile Data Collection
Live Response Commands: Capturing What Disappears
Learning objective: Master the live response command sequence for Linux systems — the specific commands that capture volatile evidence (running processes, network connections, open files, memory-mapped regions, loaded kernel modules) before it disappears. Understand what each command reveals, what it misses, and how to detect situations where the command output cannot be trusted.
The Live Response Sequence
When you have shell access to a compromised Linux system and need to collect volatile evidence manually — either because UAC is not available, because you need immediate answers before running UAC, or because you need to verify UAC’s output — the following command sequence captures the most critical volatile data in the correct order.
The principle: run the commands that reveal the attacker’s current activity first. Process state and network connections tell you what the attacker is doing right now. Everything else tells you what the attacker did in the past. Current activity is the most volatile and the most immediately actionable.
Step 1: Record the Timestamp
Before any collection command, record the current system time in UTC. Every artifact you collect will be timestamped, and you need a reference point to determine whether the timestamps on the compromised system are accurate (the attacker may have changed the system clock).
| |
If the system time is significantly different from your forensic workstation’s time, note the offset. All subsequent timestamp analysis must account for clock skew.
Step 2: Currently Logged-In Users
| |
The who output tells you whether the attacker is currently connected. If you see a session from an unexpected IP address, that is the attacker’s live session. The w command adds what each session is currently running — if the attacker is running wget, curl, or python, you can see it in real time.
Step 3: Running Processes
| |
The ps auxf output shows the process tree — critical for identifying suspicious parent/child relationships. A web server process (nginx, php-fpm, apache2) spawning a shell (/bin/bash, /bin/sh) is a strong indicator of web shell execution. A kernel thread name ([kworker/...]) appearing as a child of a user process is a disguised malicious process.
The /proc direct read loop is the most important live response command in your toolkit. It reads process information directly from the kernel’s /proc filesystem, bypassing any userspace hooks that a rootkit might have installed. If ps shows 150 processes but the /proc loop finds 153, three processes are hidden by a rootkit.
The EXE field (readlink -f /proc/$p/exe) reveals the actual binary being executed, even if the attacker renamed the process or deleted the binary from disk. A process showing EXE: /dev/shm/.cache/worker (deleted) tells you: the binary was stored in RAM-backed /dev/shm, the attacker deleted it after launching it, and the binary is still in memory and can be recovered.
Step 4: Network Connections
| |
The ss -tnp output shows every established TCP connection with the process that owns it. An established connection from a web server process to an external IP on port 4444, 8443, or 9001 is likely a reverse shell. A connection from any process to a known mining pool IP on port 3333, 4444, or 14444 is a cryptominer.
The /proc/net/tcp direct read is the kernel-level truth. Each line represents a TCP connection. The fields are hex-encoded (local address, remote address, state, PID). This data is harder to read than ss output but cannot be hidden by a userspace rootkit. LX12 covers the decoding in detail during memory forensics analysis, but during live response, the key technique is comparing the number of connections in /proc/net/tcp against the number shown by ss — a discrepancy indicates hidden connections.
Step 5: Open Files and File Descriptors
| |
The lsof +L1 command is forensically significant. When a process opens a file and the file is then deleted from the filesystem, the file remains accessible through the process’s file descriptor until the process closes it. An attacker who deletes their malware binary after launching it leaves the binary accessible through /proc/[pid]/fd/ — you can copy it out for analysis: cp /proc/[pid]/fd/[fd_number] /mnt/usb/recovered_binary.
Step 6: Loaded Kernel Modules
| |
Loadable kernel modules (LKMs) are the mechanism for kernel-level rootkits on Linux. A rootkit module hooks system calls to hide processes, files, and network connections from userspace tools. If lsmod shows a module you do not recognize — especially one without a description or with a generic name — it warrants investigation. Note that a sophisticated rootkit may hide itself from lsmod as well, which is why memory forensics (LX12) is the definitive method for detecting kernel-level rootkits.
Step 7: Volatile Filesystem Contents
| |
The find / -mtime -1 command identifies every file modified in the last 24 hours — a rapid scan for attacker activity. If the compromise occurred within the last day, this command surfaces the attacker’s files alongside legitimate system changes. The SUID file list is a baseline for privilege escalation investigation in LX6. The world-writable directory list identifies additional staging locations beyond /tmp and /dev/shm.
Myth: “Running forensic commands on a live system contaminates the evidence and makes it inadmissible.”
Reality: Live response is standard forensic practice and is accepted in legal proceedings worldwide. The key is documentation: record what commands you ran, when, and what they modified. The alternative — not collecting volatile evidence — results in permanent evidence loss. Courts and tribunals understand that some evidence modification is unavoidable during collection. What they require is that the modification is documented and the investigator can explain what changed.
Try it: On a test Linux VM (not a production system), run the full live response sequence from Steps 1–7. Save the output to a file: script /tmp/live-response-$(date +%Y%m%d).log. This records everything displayed on screen. After the collection, review the output: can you identify every running process? Can you identify every network connection? Are there any SUID files you do not recognize? This is the same review process you will perform on evidence from a compromised system.
Beyond This Investigation
The live response commands in this subsection are the foundation for the “how to extract” step of the six-step investigation method. In LX4, you will run these commands on BASTION-NGE01 to identify the attacker’s SSH session and post-compromise processes. In LX5, you will use the process tree to trace the web shell execution chain. In LX8, you will use the network connection commands to identify mining pool communications. In LX12, you will compare live response output against memory forensics output to detect rootkit-hidden processes and connections.
Check your understanding:
- Why should you read
/proc/[pid]/exedirectly instead of relying on the process name shown byps? - You run
ss -tnpand see 45 established connections. You runwc -l /proc/net/tcpand see 48 entries (minus the header). What does this discrepancy suggest? - An attacker’s binary at
/dev/shm/.hidden/payloadwas deleted, but the process is still running as PID 9921. How do you recover the binary? - What does
lsof +L1show, and why is it forensically significant?
You're reading the free modules of this course
The full course continues with advanced topics, production detection rules, worked investigation scenarios, and deployable artifacts. Premium subscribers get access to all courses.