Memory dump
For the 2019 Volatility Plugin Contest, dumpmem was developed to acquire live memory on FreeBSD. The code still works in 2024. The code uses devinfo(3), the device and resource information utility library to retrieve the start and size of resources of the ram0 device. It reads those regions from the special file /dev/mem(4) and writes them in LiME format.
Differences between volatility2 and volatility3
The profile argument to determine which symbols to use was removed, now it is automatically guessed.
It is no longer needed to build a crafted kernel module to create a profile, dwarf2json can create a profile from the kernel that is running (see following paragraph).
Volatility3 seems faster than volatility2: 3 to 5seconds per simple plugin execution with volatility3 versus 10 to 15 seconds per simple plugin execution with volatility2.
Volatility3ISF generation
dwarf2json needs slight modifications to generate volatility3 Intermediate Symbol File (ISF) suitable for FreeBSD analysis. In the FreeBSD kernel, the version is stored in the "version" string.This "version" string is stored in the ".data" section of the kernel.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe2687129eaed61a651ec_Image%201.png)
To generate the volatility3 Intermediate Symbol File, the kernel and the kernel debug data are needed. Symbol data is taken from the kernel. Types and symbol types are taken from the kernel debug data.Note: a minimum of 8GB of ram is needed to process this data.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe29c97dc4613f4615950_Image%202.png)
The volatility3 Intermediate Symbol File contains almost all data needed for memory analysis. In the excerpt below, we can see the "char" base type, the "proc" and "proclist" user types, the "obj_type" enumeration, the "allproc" and "version" symbols:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe2b8a56a3fc3cc2c7b3c_Image%203.png)
The generated volatility3 Intermediate Symbol Files can be validated using the isfinfo plugin:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe3202438a4ee9476c69a_Image%204.png)
Extraction of FreeBSD identifiers from Volatility3 intermediate Symbol File
The identifier of the FreeBSD operating system is stored in the "version" string. MacOS also uses this string, so the existence of the "kfreebsd_brand_info" symbol is used to distinguish between the two:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe4a6b14b102c4e1c8aff_Image%205.png)
FreeBSD Intel Stacker
On FreeBSD amd64, "KPML4phys" stores the physical address of the kernel level 4 page map table.
On FreeBSD i386 with PAE (Physical Address Extension, a feature allowing a 32bit processor to access more than 4GB of physical memory), "IdlePDPT" stores the physical address of the kernel page directory pointer table.
On FreeBSD i386 without PAE, "IdlePTD" stores the physical address of the kernel page table directory.
Volatility knows how to do the address translation from this physical address.
Features implemented in FreeBSD
Banners
The banners plugin was modified to detect FreeBSD banner.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe4eba66b8c73bee8e2a6_Image%206.png)
This helps us to find the version a memory image is running in case it is not known:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe522b6f9b2138463698a_Image%207.png)
PsList
PsList displays running processes.
FreeBSD uses a "proc" structure to store information about processes, on version 14.0 it is like this:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe54b50dd7f8f43ffe99a_Image%208.png)
"allproc" is a list of all processes:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe56cb20dc12398ec9791_Image%209.png)
The PsList plugin walks the"allproc" list. "p_pid" stores the process identifier, "p_comm" the process name, and "p_pptr" points to the parent process.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe5827c2ce81a2c36b66e_Image%2010.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe6387a91343e73be54dd_Image%2011.png)
Creds
Creds displays security credentials for the processes.
FreeBSD uses "ucred" structure to store credentials of a process, on version 14.0 it is like this:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe64c29b37496c8fa9367_image%2012.png)
The Creds plugin displays the user and group identifications (effective, real and saved), the file creation mode mask, the credential flags, and the groups.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe663a837223c551b9be1_image%2013.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe66b18144ca42e9cafa6_image%2014.png)
Envars
Envars displays environment variables for the processes.
FreeBSD holds pointers to argument strings and environment strings in "ps_strings" structure.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe68f9519bcede0276827_image%2015.png)
"ps_envstr" points to the process environment vector and "ps_nenvstr" is the number of elements in "ps_envstr".
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe6a5bc92e0312339374c_image%2016.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe6b8ade92a5167888780_image%2017.png)
LsKld
LsKld displays files dynamically linked into the kernel.
FreeBSD uses "linker_file" structures to store information about files loaded by the kernel linker:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe6f2305de1d613e2aff4_image%2018.png)
"linker_files" is the list of all those "linker_file" structures:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe71372b75bfde927b53d_image%2019.png)
The LsKld plugin walks the"linker_files" list, and displays unique ids, reference counts, file sizes, load addresses and file names.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668fe734e8bbaacd86055440_image%2020.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668ff471ba763828c8e07e58_image%2021.png)
LsMod
LsMod displays kernel modules loaded into the kernel.
FreeBSD uses "module"structures to store information about modules.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/668ff48dba763828c8e09a51_image%2022.png)
"modules" is the list of all modules.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f7eb18bc882adb8d0546_image%2023.png)
The LsMod plugin walks the"modules" list and displays unique ids, names and file name.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f816dce95af5e36c6b35_image%2024.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f8641c93d8ada58fe180_image%2025.png)
Lsof
Lsof displays file descriptor information for the processes.
FreeBSD stores information about file descriptors in a "filedesc" structure, containing an open file table of "filedescent" structures.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f948b5c786bbb2fc1966_image%2026.png)
The Lsof plugin enumerates the open.
file descriptors and attempts to display a nice description (file name, socket type…).
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f9a1e49b9ed3c0d8ef5b_image%2027.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690f9b3aba666ed2218b29a_image%2028.png)
Mount
Mount displays currently mounted filesystems.
FreeBSD stores information about mounted filesystems in "mount" structures.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690fbe43b0b81ae742fab9e_image%2029png.png)
"mountlist" is a list of all mounted filesystems.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690fe3808cdeb34b14a31d4_image%2030.png)
The Mount plugin walks the "mountlist" list and displays the mounted filesystem, the directory on which it is mounted and the filesystem type name.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690fe642147682316b411fe_image%2031.png)
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690fe70f3709b75ac7265b5_image%2032.png)
Maps
Maps displays virtual memory mappings for the processes.
Each process has a "vmspace" structure describing the process address space. It contains a"vm_map" structure which contains a binary-search tree of "vm_map_entry"structures.
The Maps plugin walks those structures and is able to dump them if requested.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690fea376becaa43b814fff_image%2033.png)
PsAux
PsAux displays binary information and command line arguments for the processes.
It works similarly as the Envars plugin.
"ps_argvstr" points to the argv vector and "ps_nargvstr" is the same as the program's argc.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/6690ff9616389bf7f80bf678_image%2034.png)
PsTree
PsTree displays processes in a tree.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/669100020bd457331e16d9d6_image%2035.png)
Volshell
A freebsd flag was added to volshell to specify that the operating system is FreeBSD.
In the example below, the list of processes is retrieved and the first process in the list is displayed.
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/66911c64ede79be051f3c301_image%2036.png)
Availability
dumpmem is available at https://github.com/ant1/dumpmem.
The pull request to add FreeBSD support to dwarf2json is available at https://github.com/volatilityfoundation/dwarf2json/pull/64.
The pull request to add FreeBSD support to volatility3 is available at https://github.com/volatilityfoundation/volatility3/pull/1182/.
Bugs
Enumerations do not seem to be handled correctly.
For instance "v_type" instruct vnode:
![](https://cdn.prod.website-files.com/6602c6497b464a21af814fdd/66911eb8120d6552113e60b7_image%2037.png)
Conclusion
This work allows to perform memory analysis on FreeBSD or FreeBSD based memory images. FreeBSD is usually less covered by forensic tools.
Extending volatility3 to support FreeBSD turned out to be easier than extending volatility2 to support FreeBSD for two reasons:
- dwarf2json allows to easily create an ISF from an existing kernel, while we had to build a custom module which was not exhaustive previously
- with volatility2 the overlay was painful to develop (547 lines) while with volatility3 the automagic is quite easy (143 lines)
It should be straight forward to improve plugins or contribute new plugins. We encourage you to test, provide feedback and extend these new features.