Software engineer, interested in hypervisors, malwares and security research. Bringing Virtual Machine Introspection for QEMU/KVM.
Dynamic configuration of LibVMI using Rekall
23 Nov 2017
LibVMI
I have been using LibVMI since a year now, and it has been really helpful when
working on KVM-VMI and Nitro. It
provides a nice abstraction on top of Xen and KVM and deals with the low-level details of accessing content from the
virtual/physical memory (page tables), intercepting hardware events, or reading the VCPU registers.
But there is a catch: Before you are able to introspect a virtual machine, LibVMI needs to know the offsets of some
important structures like EPROCESS on Windows and task_struct on Linux.
Let’s review LibVMI configuration methods.
Configuration
LibVMI proposes 3 methods to configure a domain for instrospection:
Once your VMI application is configured, you can start introspecting your domain.
For example, look at libvmi/examples/process-list winxp to enumerate the processes running on the virtual machine !
From a file
The first and the simplest way to configure LibVMI is to use a configuration file.
LibVMI will try to find it in the following locations:
current direction
$HOME/etc/libvmi.conf
etc/libvmi.conf
In this file you have to specify the exact name of the domain you want to introspect and a few offsets.
For Windows XP:
From a string
The second method allows you to set the configuration from a string, in your application.
From a GHashTable
The last and the most flexible is to provide the offsets via a GLib GHashTable:
From a rekall profile
There is a alternative method to configure LibVMI, which makes use of Rekall profiles.
A profile is a JSON file containing all the information Rekall will need to inspect the memory of the virtual machine
and run it’s plugins like pslist or dlllist.
The procedure to create this profile is documented on the README, so i will not
detail it here.
Dynamic configuration with Rekall
But all of this is very tedius at the end.
To introspect you domain, you have to configure it in advance, get the offsets and put in a config
file/string/ghashtable or generate a rekall profile.
What if you are given an entire cloud to monitor ?
What if all of the virtual machines are different (Windows XP/7/8/10) and they don’t have the same patch level ?
(remember that Service packs changes the offsets of EPROCESS structures…
So what can we do ?
Go one by one, setup the configuration and introspect them ?
What if there was a way to dynamically configure LibVMI, on the fly ?
Well, there is: just take a memory dump with libvirt, extract the offsets with Rekall and provide this to LibVMI !
I have little example of this concept, and it uses the Python wrapper for LibVMI that i’m writing.
I will assume you already have LibVMI installed on your system.
Installing Rekall from git
We need the latestRekall from github:
Installing the LibVMI python wrapper
Now you can clone the python wrapper for LibVMI, and install it:
Perfect !
Now you have the LibVMI Python wrapper installed !
Downloading the Python module
The python module below contains the code that will take the memory dump and extract the configuration: