This release just made it in time for Christmas! Enjoy!
For the first time Rekall includes experimental support for analysis of traditional Disk images. This release includes a full featured parser for NTFS. Some interesting plugins:
fls: List files in the filesystem.
istat: Displays information about an MFT entry.
idump: hexdump an attribute or stream.
iexport: Exports a file from the NTFS.
This release includes full support for acquisition and analysis of the windows page file. Some interesting plugins include:
pagefiles: Lists the currently active page files and their locations.
vadmap: Displays each page in the VAD and resolves its location in physical memory (or the page file).
vtop: This plugin was expanded to display where virtual pages are actually backed by the page file.
dumpfiles: This plugin was finally implemented in Rekall.
inspect_heap: Experimental support for heap enumeration on Win7 x64 allows enumeration of userspace heap allocation (e.g. malloc()).
dns_cache: This is also used to enumerate the dns cache by inspecting heap allocations.
This release adds a functional Entity layer. Currently confined to OSX analysis. Entities are a kind of query language for memory artifacts. Some useful plugins:
find: Search for entities based on a query.
analyze: Analyze the internal query optimizer’s collectors that will be run in response to a query.
Most other plugins are rewritten in terms of entities (e.g. lsof, netstat etc.)
This release brings a dedicated userspace imager to Linux. The lmap tool was expanded to write ELF core dump files and acquire directly from /proc/kcore, if the target system supports it (in this case no kernel module is needed).
MIPS address space added for support on Big Endian Machines.
Rekall can now read and write EWF files natively. There have been many performance and stability improvements too.
ewfacquire: Rekall can be used to acquire memory efficiently, writing an EWF compressed file (with an embedded ELF file).
The Profile repository is now cached locally to make subsequent runs faster.
Rekall’s advanced memory analysis capabilities are powered by a powerful binary parsing engine - capable of parsing very complex binary formats. Not only can this be applied to memory forensics, but also traditional filesystem forensics can be implemented using this capability.
Recent versions of Rekall have introduced a complete NTFS parsing subsystem using the familiar Rekall interface. This blog post introduces the NTFS filesystem plugins. In the first part of this blog post, I will show how NTFS disk images can be analysed, while in the second part I will talk a bit about the implementation details within Rekall.
Why did we add NTFS support to a memory forensic tool?
When we added support for using the windows pagefile to supplement memory analysis it became apparent that we needed to read the pagefile directly from the NTFS since the file is normally locked - so normal file APIs are not usable. We considered using tricky kernel hacking to bypass the file lock restrictions but this seems fragile and NTFS parsing is not that complicated. For memory acquisition using WinPmem we included the fcat tool from the Sleuthkit to copy the pagefile out (alternatively we could have linked libtsk directly). But one of the more important uses of Rekall is live analysis, and this does not really solve it.
We knew that Rekall’s binary parsing library was up to the task of handling NTFS. It was a good exercise to learn NTFS and document it in the Rekall implementation. I used Brian Carrier’s excellent book File System Forensic Analysis to learn about the NTFS and implement it in Rekall.
Although we also maintain pytsk as a python binding to the TSK library, it is a bit of a pain to use. The bindings are sometimes fragile and can cause crashes under some situations. They also need to be frequently updated when TSK evolves. Performance is not great - TSK needs to parse the entire MFT each time it is loaded. Pytsk has a lot of trouble parsing a live filesystems since TSK caches its analysis of the MFT and might not see new files created after this initial MFT parsing. Rebuilding the caches is quite slow too due to the IO required in reading the entire MFT each time. I felt that a pure python implementation of NTFS parsing can be useful in some situations and use cases and possibly be more efficient (Despite being written in Python :-).
Probably the most important reason for implementing NTFS parsing in Rekall was that it was a hell of a lot of fun! Rekall’s programming APIs are very easy to work with and the final plugins were really fast and powerful.
Rekall’s implementation is not supposed to be a replacement for TSK. The Sleuthkit actually converts much of the information found in NTFS into a common format to fit all filesystems. So for example, it extends the inode abstraction from other filesystems from a simple integer to a string which may contain type and id (e.g. 50-144-8). Some of the timestamps are also omitted from the tool’s output (but may be found using the low level API). This extra layer of abstraction is good in the general case (e.g. autopsy works with all filesystems in the same way) but may actually be hiding some important forensic information in some cases. Its useful to have an implementation of NTFS parsing with no abstractions at all - to allow examiners to corroborate some of the low level information available.
1. Rekall NTFS plugins.
In order to analyze an NTFS disk image, simply load it with the familiar -f switch. In the following example I use the vdfuse tool in order to export my Virtual Box VDI disk partitions as raw devices:
The istat plugin displays information about a particular MFT entry. By default it shows entry 5 (The root directory). If the entry has an I30 attribute (which represents a directory index) the plugin further parses the entry and displays all files in the directory recovered from the I30 attribute stream. Note that the I30 stream contains 3 timestamps for each entry which are separated from the timestamps actually present in the MFT’s $STANDARD_INFORMATION attribute.
The output of istat also lists the attributes and their types in a similar notation to that found in, e.g. the Sleuthkit. That is as a tuple separated by dashes, MFT-TYPE-ID.
The fls plugin works in a similar way, but lists directories based on a filename, rooted at the root of the filesystem. The filename may use forward or backslash for separators.
NTFS compression works by compressing every 16 clusters together, and inserting a sparse cluster to cover the compressed region. We can see this in the above cluster listing.
Rekall provides the idump plugin which is analogous to the regular dump plugin, and displays a hexdump of the MTF entry.
 Partition2 16:06:56> idump 89063
Offset Hex Data
-------------- ------------------------------------------------ ----------------
0x0 41 2e 20 48 49 53 54 4f 52 59 20 4f 46 20 54 48 A..HISTORY.OF.TH -
0x10 45 20 53 4f 46 54 57 41 52 45 0d 0a 3d 3d 3d 3d E.SOFTWARE..==== -
0x20 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d 3d ================ -
0x30 3d 3d 3d 3d 3d 3d 0d 0a 0d 0a 50 79 74 68 6f 6e ======....Python -
0x40 20 77 61 73 20 63 72 65 61 74 65 64 20 69 6e 20 .was.created.in. -
0x50 74 68 65 20 65 61 72 6c 79 20 31 39 39 30 73 20 the.early.1990s. -
0x60 62 79 20 47 75 69 64 6f 20 76 61 6e 20 52 6f 73 by.Guido.van.Ros -
0x70 73 75 6d 20 61 74 20 53 74 69 63 68 74 69 6e 67 sum.at.Stichting -
0x80 0d 0a 4d 61 74 68 65 6d 61 74 69 73 63 68 20 43 ..Mathematisch.C -
0x90 65 6e 74 72 75 6d 20 28 43 57 49 2c 20 73 65 65 entrum.(CWI,.see -
If you want to copy a file out of the NTFS filesystem, use the iexport plugin.
 Partition2 16:50:46> iexport 89063, dump_dir="/tmp/"
Writing MFT Entry 89063 as Python27/LICENSE.txt
 Partition2 16:51:11> !head /tmp/Python27%2fLICENSE.txt
A. HISTORY OF THE SOFTWARE
Python was created in the early 1990s by Guido van Rossum at Stichting
Mathematisch Centrum (CWI, see http://www.cwi.nl) in the Netherlands
as a successor of a language called ABC. Guido remains Python's
principal author, although it includes many contributions from others.
In 1995, Guido continued his work on Python at the Corporation for
National Research Initiatives (CNRI, see http://www.cnri.reston.va.us)
2. Rekall’s NTFS implementation notes.
This section is intended for Rekall developers who want to learn a bit about how Rekall’s NTFS implementation uses some of the common features in the Rekall API.
2.1. Autodetection of NTFS
To make Rekall as easy to use as possible, we use autodetection as much as we can. Ideally a user should simply provide the image file, and Rekall will detect the image format and the profile required. To support this, Rekall has an autodetection plugin system. A detector class simply registers by extending guess_profile.DetectionMethod:
The detector can provide a string on which to fire, or a list of offsets to check in its Offsets() method. The framework will then call it when a hit is found.
2.2. Implementing Fixups
One of the more interesting features of NTFS is the use of Fixups. When the NTFS writes to disk certain data structures, it replaces some bytes in the cluster with a random sequence. It then stores the bytes that used to be there as fixups in a list. When NTFS reads the cluster from disk it applies the fixups to get the original data.
This means that we can not simply read clusters from the disk - we must apply the relevant fixups. In Rekall we have an Address Space abstraction to read data. Address Spaces typically layer on top of other address spaces. Hence we can implement the FixupAddressSpace so it can be layered on top of another address space:
classFixupAddressSpace(addrspace.BaseAddressSpace): """An address space to implement record fixup."""def__init__(self, fixup_magic, fixup_table, base_offset, length,**kwargs):super(FixupAddressSpace, self).__init__(**kwargs)
self.as_assert(self.base isnot None,"Address space must be stacked.")
self.base_offset = base_offset
self.fixup_table = fixup_table
self.fixup_magic = fixup_magic
# We read the entire region into a mutable buffer then apply the fixups.
self.buffer = array.array("c", self.base.read(base_offset, length))for i, fixup_value inenumerate(fixup_table):
self.buffer[fixup_offset:fixup_offset+2]= array.array("c", fixup_value.v())defread(self, address, length):
buffer_offset = address - self.base_offset
We can then apply the fixup to arbitary structures. The below code will automatically apply the fixup every time we instantiate an MFT_ENTRY struct. Therefore the fixups become completely transparent now:
classMFT_ENTRY(obj.Struct):def__init__(self,**kwargs):super(MFT_ENTRY, self).__init__(**kwargs)# We implement fixup by wrapping the base address space with a fixed# one:
NTFS attributes can be fragmented. The actual blocks they occupy on disk are described using a run list. Rekall already has an address space primitive called a RunBasedAddressSpace. This type of address space is simply initialized with a list of runs specifying tuples of the form (file address, disk address length), and then layered on top of the Physical Address Space (i.e. the disk image).
Supporting compressed files makes the implementation slightly more complex, but in general all one has to do is derive an address space from the RunBasedAddressSpace and in the constructor populate the self.runs collection. The following shows the simplified implementation ignoring compression.
classRunListAddressSpace(addrspace.RunBasedAddressSpace): """An address space which is initialized from a runlist."""def__init__(self, run_list, cluster_size=None, size=0,**kwargs):super(RunListAddressSpace, self).__init__(**kwargs)
self.PAGE_SIZE = cluster_size or self.session.cluster_size
self.compression_unit_size =16* self.PAGE_SIZE
self._end = size
# In clusters.
file_offset =0for range_start, range_length in run_list:
file_offset, range_start, uncompressed_range_length)def_store_run(self, file_offset, range_start, length): """Store a new run with all items given in self.PAGE_SIZE."""
self.runs.insert([file_offset * self.PAGE_SIZE,
range_start * self.PAGE_SIZE,
length * self.PAGE_SIZE,
Once the mapping is defined, the address space takes care of efficiently locating and using the correct run for arbitrary read operations.
2.4. Further abstractions
Rekall uses rekall.obj.Struct classes to represent arbitrary structs in memory. There is a mechanism to extend these and provide methods for these structs. The methods can be used to define a kind of API for accessing other data. For example, we can attach convenience methods to an MFT_ENTRY:
defattributes(self): """Iterate over all attributes, even ones in $ATTRIBUTE_LIST."""
seen =set()for attribute in self._attributes:if attribute.type ==0xFFFFFFFF:breakif attribute in seen:continue
if attribute.type =="$ATTRIBUTE_LIST":for sub_attr in attribute.DecodeAttribute():if sub_attr.mftReference == self.mft_entry:continue
result = sub_attr.attribute
if result in seen:continue
defopen_file(self): """Returns an address space which maps the content of the file's data. If this MFT does not contain any $DATA streams, returns a NoneObject(). The returned address space is formed by joining all $DATA streams' run lists in this MFT into a contiguous mapping. """....deflist_files(self): """List the files contained in this directory. Note that any file can contain other files (i.e. be a directory) if it has an $I30 stream. Thats is directories may also contain data and behave as files! Returns: An iterator over all INDEX_RECORD_ENTRY. """....
The above is a sample of some of the convenience methods attached to the MFT_ENTRY. The first combines the attributes defined within the MFT with those defined inside the $ATTRIBUTE_LISTattribute (Typically an MFT will start with some built in attributes until it runs out of room, then it will move some attributes to an $ATTRIBUTE_LIST attribute which is non resident. But this is an implementation detail of the MFT and should really be abstracted.
Similarly we have the list_files() method which simply finds the $INDEX_ROOT and $INDEX_ALLOCATION attributes and enumerates all entries within.
Similarly file data can be stored in multiple $DATA attributes (with different VCN ranges). Its a bit tedious to combine these $DATA attributes and so we have the open_file() convenience method to return a suitable address space over the file.
3. Using the NTFS API.
Using these method it is easy to use the API to open and read arbitrary MFT entries:
$ rekal -f /tmp/mnt/Partition2
The Rekall Memory Forensic framework 1.2.0 (Col de la Croix).
"We can remember it for you wholesale!"
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License.
See http://www.rekall-forensic.com/docs/Manual/tutorial.html to get started.
# This gets a reference to the ntfs object which represents the filesystem.
 Partition2 19:28:33> ntfs = session.GetParameter("ntfs")
# The NTFS object contains a reference to the MFT
 Partition2 19:28:38> mft = ntfs.mft
# Which is just an array of MFT_ENTRY structs
 Partition2 19:28:40> print mft
[MFT_ENTRY Array ] @ 0x056F2C00
0x00 magic [String:magic]: 'FILE'
0x04 fixup_offset [unsigned short:fixup_offset]: 0x00000030
0x06 fixup_count [unsigned short:fixup_count]: 0x00000003
0x08 logfile_sequence_number [unsigned long long:logfile_sequence_number]: 0x2C601977B
0x10 sequence_value [unsigned short:sequence_value]: 0x00000001
0x12 link_count [unsigned short:link_count]: 0x00000001
0x14 attribute_offset [unsigned short:attribute_offset]: 0x00000038
0x16 flags [Flags:flags]: 0x00000001 (ALLOCATED)
0x18 mft_entry_size [unsigned short:mft_entry_size]: 0x00000178
0x1C mft_entry_allocated [unsigned short:mft_entry_allocated]: 0x00000400
0x20 base_record_reference [unsigned long long:base_record_reference]: 0x00000000
0x28 next_attribute_id [unsigned short:next_attribute_id]: 0x00000004
0x30 fixup_magic [String:fixup_magic]: '\x0f\x00'
0x32 fixup_table <Array 2 x String @ 0x056F2C32>
0x38 _attributes <ListArray 0 x NTFS_ATTRIBUTE @ 0x056F2C38>
# We use the convenience method to open the file, returning a suitable address space.
 Partition2 19:28:41> fd = mft.open_file()
# We can just read the address space.
 Partition2 19:28:45> fd.read(0, 20)
Out > 'Python News\r\n+++++++'
Note that iterating over the index produces a list of INDEX_RECORD_ENTRY structs which also contain FILE_NAME structs within them. The FILE_NAME structs contain the 4 NTFS timestamps quite independently from the timestamps stored in the actual MFT for the file itself (This FILE_NAME struct came from the directory index), this can be forensically significant.
The next example shows how to get the $STANDARD_INFORMATION record for each file:
Although the NTFS support in Rekall is still pretty immature we want to make it better and more useful. For a relatively complex filesystem, such as NTFS, the Rekall implementation is pretty small, coming in at around 1000 lines of code (not including the implementation for lznt1 - the NTFS compression algorithm. Additional lines are for plugins etc). It should be possible to support additional filesystems as well. We also want to write more interesting plugins, please let us know any ideas for a good NTFS plugin :-)
Performance is pretty good. One thing you should notice is that Rekall starts up pretty fast since it does not scan the MFT like TSK does. Of course this means that Rekall cant find orphaned files like TSK does! Rekall also does not have a cache of the MFT - making it suitable to operate on a changing live filesystem.
Reading compressed files is currently pretty slow since the lznt1 compression algorithm is implemented in pure python. This could be easily accelerated with a C implementation in future.