← All posts

Recovering files from a memory dump: filescan, dumpfiles, MFT and page cache

7 min read

A running system keeps a lot of its disk in RAM. Windows maps files through the cache manager and the memory manager, Linux keeps them in the page cache, and both keep file system metadata cached. So a memory image often contains the dropper that was deleted from disk, the script that ran from %TEMP%, or the event log the attacker cleared. The Art of Memory Forensics covers this with filescan, dumpfiles, mftparser and the Linux linux_find_file family. This post describes how ramparser handles each of them, and where recovery stops.

filescan: finding the file objects

Every open file on Windows is a _FILE_OBJECT in kernel memory. It holds the file name, the device, and a SectionObjectPointer to the file's cached content. Volatility's filescan finds these objects by pool tag. On current Windows 10/11 builds, though, the tag is often missing from memory, so ramparser matches the object's layout directly:

  • Type is 5 (a file object) and Size falls in the expected range
  • DeviceObject is a kernel address
  • FileName resolves to a plausible NT path

Each hit is a row with a physical offset and a path. Because the scan covers all of physical memory, it also finds file objects that are closed but not yet overwritten, which the handle tables no longer show.

The Files view builds a directory tree from these paths. A highlights panel then lists programs and scripts (.exe, .dll, .ps1, .vbs, .hta, .lnk...) that sit in user-writable places: Temp, Downloads, AppData, Users\Public, ProgramData and the Recycle Bin. Known application folders are filtered out, and folders with random-looking names are flagged.

dumpfiles: rebuilding content from the cache

A file object's SectionObjectPointer leads to a _SECTION_OBJECT_POINTERS structure with three members, and each one is a different view of the file:

MemberWhat it isramparser
DataSectionObjectthe file as data, page-alignedrebuilt
ImageSectionObjectthe file mapped as an executable, 0x200-sector alignedrebuilt, falls back to data when unset
SharedCacheMapcache manager VACB viewsreported, not walked (falls back to data)

dumpfiles keeps only the file objects where at least one of these pointers is set, because those are the files with content you can download. Reconstruction follows the same path as Volatility. _CONTROL_AREA leads to _SEGMENT, which gives the file size. Then the tool walks the chain of _SUBSECTIONs. Each subsection holds an array of prototype PTEs, one per page, and a starting sector that places it in the file. The walk stops when a subsection's back-pointer no longer names the same control area.

For each prototype PTE:

  • Valid or Transition: the page is in RAM. ramparser reads the PFN and copies the page to its offset in the file.
  • Paged out to the pagefile: recovered only if you attached pagefile.sys next to the dump.
  • Anything else, such as nested prototype PTEs or demand-zero pages, becomes a zero-filled gap.

Two checks prevent false content. First, a pool-scanned file object may have been freed while its section pointers now lead to a control area reused for another file. So ramparser compares the name in _CONTROL_AREA.FilePointer with the file object's name and refuses the file if they differ. Second, a transition page can be reused while a stale PTE still points to it. Using the PFN database, a page is kept only when _MMPFN.PteAddress points back to the prototype PTE that names it.

In the UI, any dumpfiles row or file drawer with a cached section has a download button. The per-file download is capped at 64 MiB. The engine never builds more than 1 GiB for one file.

$MFT records cached in memory (mftscan)

NTFS caches its Master File Table like any other file. mftscan scans physical memory for 1024-byte FILE and BAAD records and validates the header offsets. For each record it extracts:

  • the record number and the in-use / directory flags
  • the $FILE_NAME name and the parent directory reference, preferring the Win32 name over the 8.3 name
  • the four $STANDARD_INFORMATION timestamps

The Files view rebuilds full paths by following parent references up to the root (record 5). It then lists files created shortly before the capture, with programs in user folders first. The timeline gets a "created" and a "modified" event per record.

The $MFT button exports every record found as a single file, with each record at number × 1024. When several copies of a record survive, the one with the highest $LogFile sequence number wins, and gaps are zero-filled. MFTECmd and analyzeMFT can read the result directly.

Limits: records cover only what was cached, only $STANDARD_INFORMATION times are extracted (so there is no $SI/$FN timestomping comparison), and file content held outside the record is not rebuilt.

Process images, DLLs and memory regions

Some evidence is not a cached file but code loaded into a process. The Processes view offers several downloads, in the spirit of procdump, dlldump and vaddump:

  • Program file (.exe) and per-module downloads read the PE at its base, up to SizeOfImage. This is the memory layout, not the file on disk.
  • Injected PE on a region flagged as an injected image, which extracts the PE found there.
  • Region gives the raw bytes of one VAD region, with pages not in RAM zero-filled.
  • Full memory zips every region of a process with a regions.csv index (up to 2 GiB in total).
  • Mapped file, when the region's backing file is in dumpfiles, rebuilds it from the file cache and prefers the image section.

A separate pedump table indexes every PE image mapped in every process (PID, base, size, path).

Linux: the page cache

With a kernel symbol profile, ramparser walks super_blocks, then each superblock's s_inodes list, and records every regular file whose inode is in memory. For each file it keeps the path (rebuilt from the dentry alias and the mount point), size, mode, owner, link count, timestamps, and how many pages are cached. Pseudo file systems such as proc, sysfs and cgroup are skipped.

File content is read from inode.i_mapping->i_pages: the tool walks the xarray (including large folios), locates each struct page through vmemmap, and copies the frame. The file panel shows "N of M pages recovered", flags ELF files, and downloads the file with missing pages zero-filled, up to 64 MiB.

Each file is then linked to the processes that map it, run it or hold it open. The "Needs a look" panel lists first:

  • Deleted but still running: link count 0 while a process executes it. This is the common way to leave no file on disk.
  • Memory-only: a file on an unmounted tmpfs/ramfs (for example memfd_create) that is being executed, meaning fileless code.
  • Out of place: ELF files, scripts, shared libraries or anything executable under /tmp, /var/tmp, /dev/shm or /run/user.
  • Families: five or more files in those directories whose names differ only by a random suffix.

The Processes view on Linux offers the same downloads as on Windows, read through each process's page tables. Program file (ELF) and the per-library download (linux_procdump, linux_librarydump) rebuild the object by laying its file-backed mappings at their file offsets. Pages the process never faulted in are taken from the page cache, while process pages win where both exist, so a patched page shows the process's copy. Region, Full memory (linux_dump_map) and Mapped file, which returns the whole cached file, work as above. In the kernel view, a module's loaded image can be downloaded too (linux_moddump).

Master Boot Records (mbrscan)

mbrscan looks for 512-byte sectors that end in 0x55AA and have a valid partition table. For each one it reports the partitions and a SHA-1 of the 440-byte boot code, so you can compare it against a known good MBR when bootkit persistence is suspected.

What you will not get back

  • Pages that were not in RAM. Unless a pagefile is attached, paged-out pages are zeros. A file can look valid at the start and be empty further in, so check coverage before drawing conclusions.
  • Files nobody touched. Only cached files exist in memory.
  • Shared cache map views. VACB-only content is not rebuilt yet.
  • On-disk PE layout from a process dump. Use the image-section download when the file is cached.
  • Closed and deleted Linux files. Once the inode is evicted, it is no longer in any list.

Check a recovered file's hash before trusting it, and treat zero-filled gaps as missing data, not as content.

Further reading