Linux memory forensics: from a LiME image to a full system snapshot
7 min read
Linux memory forensics has always had a setup problem. Before a single process is listed, the analyst needs a profile that matches the exact kernel build, and on Linux that build varies by distribution, by patch release and by cloud flavour. ramparser removes most of that setup: it identifies the kernel from the dump, fetches the symbols, recovers the address translation, and builds one structured snapshot of the system. This post walks through each stage and what it gives you on an investigation.
Everything below applies to x86-64 kernels.
Getting the image in: LiME, AVML, ELF core, raw
Four acquisition formats are detected on open:
- LiME. Each captured physical range is preceded by a 32-byte
header: magic
EMiL, version 1, start and end physical address. The ranges are mapped exactly where they belong, so the gaps between them (reserved and MMIO regions) are never read as memory. - AVML, uncompressed. AVML's default output uses the LiME header, so it takes the same path.
- AVML, compressed (
avml --compress). Version 2 blocks carry theAVMLmagic and a Snappy frame stream per range. ramparser indexes the blocks and decompresses only the chunks a read touches, so a compressed image is analysed as-is, without inflating it first. - ELF core. A kdump
vmcore, VirtualBoxdebugvm dumpvmcoreor QEMUdump-guest-memoryfile: eachPT_LOADsegment is mapped at itsp_paddr. An older/proc/kcore, whose segments all sit at physical 0, is only flagged and read raw.
Anything else is treated as a raw physical image, with identity mapping. For the wider format picture, see memory dump file formats.
From kernel banner to symbols
A Linux kernel carries its identity in a string:
Linux version 5.15.0-91-generic (buildd@…) (gcc-11 …) #101-Ubuntu SMP ….
ramparser scans the image for every copy of it (kernel .rodata, the
kernel log, residual copies) and picks the most frequent text,
preferring the longest variant when one is a truncated prefix of
another.
That banner keys the symbol lookup. Symbols are Volatility 3 ISF
files (Intermediate Symbol Format, JSON generated from the kernel's
debug information). The lookup tries a vendored index first, then a
server route that resolves the banner against the community
volatility3-symbols banner index in three steps: exact text, then
prefix match (for truncated banners), then kernel release plus build
tag. Only the banner string is sent; no memory content leaves the
browser. The ISF comes back still .xz-compressed and is decoded in
WebAssembly.
The engine parses raw JSON, .json.xz and .json.gz ISFs. After
loading, it also checks whether the ISF's own linux_banner text is
present in the dump, which catches a symbol file for the wrong build
before it produces nonsense.
KASLR and the page tables
Symbols give unrandomised addresses. The running kernel was relocated, physically and virtually. ramparser solves both slides the way Volatility's Linux stacker does:
- Fast path. The physical address of the
linux_bannerstring, already known from the banner scan, pins the physical slide. The candidate is accepted only ifinit_taskthen sits where expected withcomm=swapperandpid= 0. - Fallback. Scan for the
swappercomm anchor and validate each hit the same way.
The virtual slide comes from init_task.files compared with the
init_files symbol. The DTB (page-table root) is derived from the
kernel PGD symbol, and the result must translate init_task's own
virtual address back to where it was found. No guessing survives that
check.
Processes: the task_struct walk
The process list is one walk of init_task.tasks, the equivalent of
linux_pslist. Every per-process view reads from that single walk.
For each thread-group leader the snapshot records:
- PID, parent (
real_parent),comm, state, zombie/dead exit state, and whether it is a kernel thread (PF_KTHREAD). - Credentials from
cred: real, effective, saved and filesystem UID/GID, plus the effective, permitted and inheritable capability masks, shown as hex. - Command line and environment read from the process's own
address space (
mm->arg_starttoenv_end), likelinux_psauxandlinux_envars. A process that rewrote its title withsetproctitle()is handled the way the kernel handles it. exe,cwdandrootpaths, rebuilt from dentries across mount points.- Start time as wall clock, computed from the kernel timekeeper. The snapshot also records boot time and the kernel clock at capture.
A heuristic layer then ranks suspects: binaries running from /tmp,
/dev/shm or a deleted file, a shell whose standard input or output
is a socket, user
processes named like kernel threads, LD_PRELOAD in the environment,
libraries loaded from dot-directories.
Memory maps, open files and sockets
VMAs come from the mmap list or, on 6.1 and later, the maple tree,
with permissions, file offset and backing path (linux_proc_maps).
Anonymous executable regions are flagged, since that is what injected
code and in-memory loaders look like; JIT runtimes also produce them.
File descriptors come from files_struct → fdtable, as in
linux_lsof. Each descriptor is typed (file, directory, pipe, socket,
character device…). Sockets are decoded from struct sock: family,
type, protocol, local and remote endpoints, TCP state, which covers
what linux_netstat reports. Data still queued in a socket's receive
or write buffer is shown with a preview, and that is often the actual
command a backdoor received.
The Processes view also reads a process's address space through its
own page tables: a hex view of any region, raw downloads of one region
or of the whole memory (linux_dump_map), and the program or any
library rebuilt as an ELF by laying its file-backed mappings at their
file offsets (linux_procdump, linux_librarydump). In a rebuilt
image, pages the process never touched are filled from the page cache;
anything not in RAM at all comes back zero-filled.
The kernel view does the same for a loaded module's image
(linux_moddump).
Threads and saved registers
Each thread's user registers are saved in pt_regs at the top of its
kernel stack when it enters the kernel. ramparser reads them, like
linux_info_regs, and keeps the instruction pointer, the stack pointer
and the system call the thread was in, named through
sys_call_table. A thread whose instruction pointer lands in
anonymous executable memory is raised as a suspect: code that was
running at capture time and has no file behind it.
System state
The rest of the snapshot comes from kernel structures:
| Artefact | Kernel source | Book plugin |
|---|---|---|
| Interfaces, addresses, promiscuous flag | net_namespace_list → net_device | linux_ifconfig |
| ARP cache | arp_tbl neighbour hash | linux_arp |
| IPv4 routes | FIB tables (LC-trie leaves) | — |
| iptables rules and counters | init_net.ipv4 x_tables blobs | — |
| Mounts | initial mount namespace list | linux_mount |
| Namespaces per process | nsproxy (mnt, net, uts, pid, ipc) | — |
| Kernel log | log_buf (pre-5.10) or printk_ringbuffer | linux_dmesg |
Namespaces are grouped by inode number, so containerised processes
cluster together and a process with its own network namespace is
visible at a glance. The book's linux_route_cache has no equivalent:
the IPv4 route cache was removed in kernel 3.6.
Files in the page cache
ramparser walks super_blocks and every superblock's inode list, the
same ground as linux_enumerate_files. For each regular file it
records path, size, mode, owner, link count, times and how many pages
are cached. Two categories come first:
- Deleted but still in use (link count 0): a dropped binary that deleted itself after starting, still recoverable here.
- Memory-only files such as
memfd:objects, which never existed on disk.
File content is rebuilt from i_mapping->i_pages and can be
downloaded. Pages that were not cached come back zero-filled, and the
view shows how much of the file was present.
Without a symbol file
If no ISF matches, the structured snapshot is not built and ramparser
falls back to signature sweeps: kernel banners, a task_struct scan
with default 5.x/6.x offsets, module names from .modinfo strings,
and residual text such as /proc/net/tcp lines, mountinfo lines,
dmesg fragments and shell commands. These are leads. They cannot tell
a live process from freed memory. Once an ISF loads, the sweeps it
supersedes become on-demand.
Limits worth knowing
- Mounts are those of the initial mount namespace; container mounts are not listed separately.
- Routes are IPv4 only; firewall rules are legacy iptables (x_tables), not nftables.
- Files opened by the kernel itself are not enumerated.
For the kernel-integrity side of the same snapshot, including hidden processes, hidden modules and hooked tables, read the companion post on Linux rootkit detection.