Guest Configuration for Linux
This page will detail how to properly configure a Linux guest for recording with Reven.
IMPORTANT: We strongly recommend you start with one of the VMs available on tetrane's website. These are already properly configured and tested.
- Guest system requirements
- Enabling the OSSI feature
- Maximizing the symbol coverage
- Optimizing the guest for analysis
- Final touches
Guest system requirements
Reven requires Linux guests to be running a compatible kernel: Linux 64-bit, versions 4.1 to 4.18.0 included.
- Tested distributions:
- Fedora 27 (kernel version 4.13)
- OpenSUSE 15.1 (kernel version 4.12.14)
- Debian 9 (kernel version 4.9)
- Ubuntu 16.04 (kernel version 4.13)
- CentOS 8 (kernel version 4.18.0)
- Other untested distributions in the compatibility range:
- OpenSUSE 15.0 (kernel version 4.12)
- Ubuntu 17.10 (kernel version 4.13)
- NixOS up to 18.09 (kernel version 4.14)
- ...
NOTE: each distribution and version can have its own peculiarity, and require further configuration not descibed in this guide. Moreover, there could be specific set of patches that hinders the OSSI retrieval. Again, we recommend starting with a VM available on tetrane's website. Finally, you can contact the support if you cannot get OSSI when using a distribution from the list above.
Enabling the OSSI feature
In order to ensure the OS-Specific Information (OSSI) work on recorded scenario, you must:
- Disable KASLR and PTI protections,
- Install the kernel headers in the guest.
Disabling KASLR and PTI
You need to add the nopti
and nokaslr
options to your kernel command line. On most systems, the following procedure should work almost as-is:
- Edit the file
/etc/default/grub
. - Find the variable
GRUB_CMDLINE_LINUX_DEFAULT
. - Add the
nopti
andnokaslr
options, making the line look like this:GRUB_CMDLINE_LINUX_DEFAULT="[...] nopti nokaslr"
- Regenerate your grub configuration:
update-grub
for Debiangrub2-mkconfig -o /etc/grub2.cfg
for CentOS- Other distributions should work in a similar way.
- Reboot.
- Verify that you have the options present in
/proc/cmdline
.
Installing the kernel headers
For Debian-like distributions, this should be done with a command similar to this one: sudo apt install linux-headers-$(uname -r)
For RedHat-based distributions, the command is more like the following: sudo dnf install kernel-devel kernel-headers
Maximizing the symbol coverage
NOTE: 32-bit binaries are currently not supported by the OSSI feature for Linux.
You should install as many debug symbols on the guest as possible.
By default, symbols are searched within the binaries executed in a scenario. These production binaries usually contain very few symbols.
Most distributions provide a mechanism to download debug symbol packages, which the debuggers can then use to display more context to the user. Reven can leverage those as well completely transparently, as long as you "prepare" the snapshot after installing them (see What preparing a snapshot is).
The process of recovering debug symbol packages will vary for each distribution, but here are a few pointers to get you started:
Debian-like distributions
You can follow the steps below:
- Install
apt-file
andgrep-aptavail
.apt install apt-file dctrl-tools
- Add the debug package sources to your
/etc/apt/sources.list
. For debian:
wheredeb http://deb.debian.org/debian-debug/ <your_release>-debug main
<your_release>
is the codename of the target release of Debian (e.g.stretch
,buster
,bullseye
) - Update your apt and apt-file:
apt update apt-file update
- Look for all the binaries on your system:
# https://unix.stackexchange.com/questions/40063/how-to-find-executable-filetypes/448075#448075 find /path -type f -exec sh -c "file {} | grep -Pi ': elf (32|64)-bit' > /dev/null" \; -print
- For Debian Buster and newer, you can use
find-dbgsym-packages
from thedebian-goodies
package on your binary:
And you're done!find-dbgsym-packages <binary>
- For other distributions, for each binary, look for its build id and debug link:
readelf -n <binary> | grep "Build ID" readelf -p.gnu_debuglink
- If you have a build ID, you can use it with
grep-aptavail
to recover the debug package:
And you're done!grep-aptavail --no-field-names --show-field Package --field Build-IDs <build_id>
- Without a build ID, you can build debug paths for your binary from the debug link, and pass it to
apt-file
:
And you're done!apt-file search "/usr/lib/debug/<binary_parent_dir>/<debug_link>" apt-file search "<binary_parent_dir>/<debug_link>" apt-file search "<binary_parent_dir>/.debug/<debug_link>"
Once you recovered the debug package names, you can then install them using apt install
.
More resources:
Fedora
You can use sudo dnf debuginfo-install <packagename>
for all installed packages to get their debug counterparts.
More information:
Optimizing the guest for analysis
Linux system usually display far less background activity than a default Windows 10 installation, so there is no mandatory step in that regard.
Nevertheless, there are steps you can take to make the VM lighter still:
- If you don't need a GUI:
- Disable Xorg server when not needed,
- Disable the console framebuffer if not needed. For example, on Debian systems, in file
/etc/default/grub
, add the line:GRUB_TERMINAL=console
- Install a light Desktop Manager, such as Xfce,
- Disable any unwanted background service.
Final touches
Finally, here are more general recommendations to make the experience better.
- Since Reven supports a narrow set of kernel versions, you should inhibit kernel updates:
- On Fedora: add
exclude=kernel*
to/etc/dnf/dnf.conf
- On Ubuntu: run something akin to
echo linux-image-xxx hold | dpkg --set-selections
- On Fedora: add
- Don't forget to install your favorite tools:
gcc
,htop
, etc.