>_ IzzyLab

Hands-on task

This task is step 3 of the course “Investigating a server”

How many files a rogue process holds

medium~5 min

A process kswapd-helper is running on the server — it looks like a system one, but the kernel has no such thing. Before stopping it, collect evidence: count how many file descriptors it has open right now and write the number to /root/fd-count.txt. Don't touch the process.

What you'll practise:
  • file descriptors
  • /proc
  • pgrep
  • counting entries
  • investigation

Topic breakdown

A file descriptor is an entry in a process's table of open files: a regular file, a socket, a pipe, a device. The kernel exposes this table in /proc/PID/fd/ — one symbolic link per descriptor, and ls -l there immediately tells you where the process writes and what it reads. In an investigation it's one of the first pieces of evidence: the number and targets of a suspicious process's descriptors are recorded before it's stopped, because after kill they're gone. The approach: find the PID by name (pgrep -x), then count the entries in its fd; plain ls prints one line per entry, while ls -l adds a total line.

What's checked

  1. process kswapd-helper is alive
  2. descriptor count matches

What it looks like