Module Contents#




mlocate file parser


Base class for plugins.


dissect.target.plugins.os.unix.locate.mlocate.mlocate_def = Multiline-String#
Show Value
#define MAGIC 0x006d6c6f63617465             /* b'/x00mlocate' */

struct header_config {
    int32 conf_size;
    int8 version;                            /* file format version */
    int8 require_visibility;
    int8 pad[2];                             /* 32-bit total alignment */
    char root_database;
    char config_block[conf_size];
    int8 pad;

enum DBE_TYPE: uint8 {                       /* database entry type */
    FILE         = 0x0,                      /* file */
    DIRECTORY    = 0x1,                      /* directory */
    END          = 0x2                       /* end of directory */

struct directory_entry {
    /* time is the 'maximum of st_ctime and
       st_mtime of the directory' according to docs */
    int64 time_seconds;
    int32 time_nanoseconds;
    int32 padding;
    char path[];

struct entry {
    char path[];
class dissect.target.plugins.os.unix.locate.mlocate.MLocate#
ts: datetime.datetime#
ts_ns: int#
parent: str#
path: str#
dbe_type: str#
class dissect.target.plugins.os.unix.locate.mlocate.MLocateFile(fh: BinaryIO)#

mlocate file parser

__iter__() Iterable[MLocateFile]#
class dissect.target.plugins.os.unix.locate.mlocate.MLocatePlugin(target: dissect.target.Target)#

Bases: dissect.target.plugins.os.unix.locate.locate.BaseLocatePlugin

Base class for plugins.

Plugins can optionally be namespaced by specifying the __namespace__ class attribute. Namespacing results in your plugin needing to be prefixed with this namespace when being called. For example, if your plugin has specified test as namespace and a function called example, you must call your plugin with test.example:

A Plugin class has the following private class attributes:

  • __namespace__

  • __record_descriptors__

With the following three being assigned in register():

  • __plugin__

  • __functions__

  • __exports__

Additionally, the methods and attributes of Plugin receive more private attributes by using decorators.

The export() decorator adds the following private attributes

  • __exported__

  • __output__: Set with the export() decorator.

  • __record__: Set with the export() decorator.

The internal() decorator and InternalPlugin set the __internal__ attribute. Finally. args() decorator sets the __args__ attribute.


target – The Target object to load the plugin for.

__namespace__ = 'mlocate'#
path = '/var/lib/mlocate/mlocate.db'#
check_compatible() None#

Perform a compatibility check with the target.

This function should return None if the plugin is compatible with the current target (self.target). For example, check if a certain file exists. Otherwise it should raise an UnsupportedPluginError.


UnsupportedPluginError – If the plugin could not be loaded.

locate() Iterator[MLocateRecord]#

Yield file and directory names from mlocate.db file.

mlocate is a new implementation of GNU locate, but has been deprecated since Ubuntu 22.