CHAPTER 05 35 MIN READ INTERMEDIATE

Process and Network Internals: /proc, Process Trees & Socket Visibility

Once persistence has launched something, or an attacker is actively on a box, this is where you find it: live process state, network connections, and open files. Everything in this chapter reads the running system directly rather than a log or a saved artifact, which makes it the fastest path to ground truth during an active investigation.

/proc filesystem process tree analysis network visibility lsof

The /proc Filesystem

/proc is a virtual filesystem. It is generated live by the kernel rather than stored on disk, and it exposes process and system state as if it were a normal directory tree you can cd into and read with everyday tools.

Every running process gets its own numbered directory under /proc, named after its PID. Inside that directory sit files and symlinks that describe exactly what the process is doing right now.

PathReveals
/proc/[pid]/cmdlineThe exact command line a process was launched with, including arguments
/proc/[pid]/exeA symlink to the actual binary that's running, useful when a process name alone is misleading
/proc/[pid]/fd/Every file descriptor the process currently has open
/proc/net/Kernel-level network state, the socket tables netstat reads directly and that ss reports on via the faster netlink interface
Why this matters live: a process can rename itself in the process list, but /proc/[pid]/exe still points at the real binary on disk. That mismatch between claimed identity and actual binary is a recurring way disguised processes get caught.

Process Tree Analysis

Chapter 1 introduced PID and PPID as the identifiers that link a process to its parent. Applied practically, that ancestry chain is one of the most reliable things you can check on a live system, because for a given service it usually looks the same every single time.

A web server process is expected to have a predictable parent, and its children are expected to be predictable too, worker processes, not interactive shells. An unexpected parent, such as a web server process spawning a shell, is one of the strongest anomaly signals available, because it means something outside the service's normal behavior caused that execution. Legitimate application code does not usually need to hand control to a shell.

ObservationWhat It Suggests
Service process with an unfamiliar parentThe service may have been started or re-launched outside its normal supervision path
Web server or database process spawning a shellLikely command execution through an application vulnerability
Long-lived process with a very recent start timePossible replacement, injection, or process masquerading as something older
Cron or init-owned process with an odd ancestryWorth checking against the persistence mechanisms covered in chapter 4

Network Visibility: ss and netstat

Once a process looks suspicious, the next question is usually who it's talking to. Two tools answer that on Linux, and they overlap heavily in what they can show.

ToolNotes
ssThe modern socket-statistics tool, faster and the current standard on most distributions
netstatThe older tool, still present on many systems but considered legacy

Both show listening ports and established connections, the two states that matter most during triage. With the right options, both can also show which process owns each connection, which is what turns "something is talking to this IP" into "this specific process is talking to this IP."

Practical habit: reach for ss first on any modern distribution. Treat netstat as a fallback for older or minimal systems where ss isn't installed.

Open File Visibility with lsof

lsof lists every file descriptor held open by every process. On Linux that scope is wider than it sounds, since sockets and pipes are file descriptors too, not just regular files on disk.

That breadth is why lsof is often used alongside ss and /proc: it can confirm which process owns a given socket, what regular files a suspicious process is reading or writing, and what a process is holding open that nothing else on the system references anymore.

Deleted-but-open files: a process can keep a file handle open even after that file has been deleted from the filesystem. The contents still exist as long as the process keeps the handle open, invisible to a normal directory listing. This is both a real technique malware uses to hide its own binary from disk and a real way an investigator can recover that binary through the still-open descriptor.

Putting It Together

These tools are rarely used in isolation. A live investigation usually moves through them in the same order, narrowing from "something looks off" to a specific, evidenced conclusion.

1
Notice an unexpected process
Something in the process tree doesn't match the ancestry you'd expect.
2
Check its command line and binary path via /proc
Read /proc/[pid]/cmdline and /proc/[pid]/exe to confirm what's really running.
3
Check its network connections via ss
Identify who it's talking to and whether that traffic makes sense.
4
Check its open files via lsof
Look for deleted-but-open handles, unexpected sockets, or unusual files.
5
Correlate with persistence mechanisms
Check the chapter 4 persistence locations that might have launched this process.

That workflow covers what a process is doing right now, but a lot of live tradecraft happens inside a shell before a process ever looks this suspicious, which is exactly where chapter 6 picks up.

Key Takeaways

  • /proc is a live, kernel-generated view of process and system state, not a stored filesystem, with per-PID directories exposing command lines, real binary paths, and open file descriptors.
  • Process ancestry (PID/PPID) is predictable for a given service, so an unexpected parent, like a web server spawning a shell, is a strong anomaly signal.
  • ss is the modern, faster socket-statistics tool and the current standard; netstat is older but still found on many systems.
  • Both ss and netstat can tie a connection to the specific process that owns it, not just the remote IP involved.
  • lsof reveals every file descriptor a process holds, including sockets and pipes, and can expose files that were deleted from disk but are still held open, a real hiding and recovery technique.
  • Live investigation follows a repeatable sequence: spot the process, verify it via /proc, check its network activity via ss, check its open files via lsof, then correlate with known persistence mechanisms.

Knowledge Check

Click an answer to reveal the explanation.

What does /proc/[pid]/exe show for a running process?

Correct answer: B. /proc/[pid]/exe is a symlink pointing to the real binary behind a process, which matters when a process name alone is misleading.

Why is ss generally preferred over netstat on modern Linux distributions?

Correct answer: C. ss is faster and is the current standard socket-statistics tool on most distributions; netstat still exists on many systems but is considered legacy.

During an lsof review, you find a process holding open a file that no longer appears anywhere on the filesystem. What does this indicate?

Correct answer: C. A deleted-but-open file handle is a well-known technique malware uses to hide its own binary from disk, and it's also a real way an investigator can recover that binary through the still-open descriptor.